Skip to content
Snippets Groups Projects

Support webeos namespace annotations for overrides

Merged Alexandre Lossent requested to merge namespace-annotations-overrides into master
3 unresolved threads
Files
4
@@ -299,6 +299,7 @@ var _ = Describe("GitlabPagesSite controller", func() {
}
}
})
It("GPS sites in blocked projects are unavailable", func() {
gpsSite := newGpsSite(gpsName, gpsNamespace)
gpsSite.Spec.Hosts = webservicescernchv1alpha1.SiteUrls{"my-gps-site.web.cern.ch"}
@@ -336,9 +337,107 @@ var _ = Describe("GitlabPagesSite controller", func() {
Expect(len(routes.Items)).To(Equal(1))
for _, route := range routes.Items {
Expect(route.Spec.Host).To(Equal("my-gps-site.web.cern.ch"))
Please register or sign in to reply
Expect(route.Spec.To.Name).To(Equal(blockedServiceName))
}
})
It("GPS's Route is assigned to the default router shard", func() {
gpsSite := newGpsSite(gpsName, gpsNamespace)
gpsSite.Spec.Hosts = webservicescernchv1alpha1.SiteUrls{"my-gps-site.web.cern.ch"}
// create a GPS site as usual
Expect(k8sClient.Create(ctx, gpsSite)).Should(Succeed())
Eventually(func() bool {
err := k8sClient.Get(ctx, gpsLookupKey, gpsSite)
if err != nil {
return false
}
return len(gpsSite.Status.Conditions) == 1 &&
gpsSite.Status.Conditions[0].Type == webservicescernchv1alpha1.ConditionTypeGitlabPagesSiteCreated &&
gpsSite.Status.Conditions[0].Status == metav1.ConditionTrue
}, timeout, interval).Should(BeTrue())
route := &routev1.Route{}
routeName := generateRouteName(gpsSite, "my-gps-site.web.cern.ch")
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: routeName, Namespace: operatorNamespace}, route)).Should(Succeed())
Expect(route.Labels[routerShardLabel]).To(Equal(defaultRouterShard))
})
It("GPS's Route is assigned to a custom router shard if configured properly", func() {
gpsSite := newGpsSite(gpsName, gpsNamespace)
gpsSite.Spec.Hosts = webservicescernchv1alpha1.SiteUrls{"my-gps-site.web.cern.ch"}
gpsNs := &corev1.Namespace{}
nsKey := types.NamespacedName{Name: gpsNamespace, Namespace: gpsNamespace}
Expect(k8sClient.Get(ctx, nsKey, gpsNs)).Should(Succeed())
if gpsNs.Annotations == nil {
gpsNs.Annotations = map[string]string{}
}
gpsNs.Annotations[forceRouterShardNamespaceAnnotation] = "example-router-shard"
Expect(k8sClient.Update(ctx, gpsNs)).Should(Succeed())
// create a GPS site as usual
Expect(k8sClient.Create(ctx, gpsSite)).Should(Succeed())
Eventually(func() bool {
err := k8sClient.Get(ctx, gpsLookupKey, gpsSite)
if err != nil {
return false
}
return len(gpsSite.Status.Conditions) == 1 &&
gpsSite.Status.Conditions[0].Type == webservicescernchv1alpha1.ConditionTypeGitlabPagesSiteCreated &&
gpsSite.Status.Conditions[0].Status == metav1.ConditionTrue
}, timeout, interval).Should(BeTrue())
// confirm that the proper shard-related labels/annotations have been applied on the Route
route := &routev1.Route{}
routeName := generateRouteName(gpsSite, "my-gps-site.web.cern.ch")
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: routeName, Namespace: operatorNamespace}, route)).Should(Succeed())
Expect(route.Labels[routerShardLabel]).To(Equal("example-router-shard"))
})
It("Namespace's IP whitelist is propagated to the Route", func() {
gpsSite := newGpsSite(gpsName, gpsNamespace)
gpsSite.Spec.Hosts = webservicescernchv1alpha1.SiteUrls{"my-gps-site.web.cern.ch"}
gpsNs := &corev1.Namespace{}
nsKey := types.NamespacedName{Name: gpsNamespace, Namespace: gpsNamespace}
Expect(k8sClient.Get(ctx, nsKey, gpsNs)).Should(Succeed())
if gpsNs.Annotations == nil {
gpsNs.Annotations = map[string]string{}
}
gpsNs.Annotations[forceIpWhitelistNamespaceAnnotation] = "example-ip-whitelist"
Expect(k8sClient.Update(ctx, gpsNs)).Should(Succeed())
// create a GPS site as usual
Expect(k8sClient.Create(ctx, gpsSite)).Should(Succeed())
Eventually(func() bool {
err := k8sClient.Get(ctx, gpsLookupKey, gpsSite)
if err != nil {
return false
}
return len(gpsSite.Status.Conditions) == 1 &&
gpsSite.Status.Conditions[0].Type == webservicescernchv1alpha1.ConditionTypeGitlabPagesSiteCreated &&
gpsSite.Status.Conditions[0].Status == metav1.ConditionTrue
}, timeout, interval).Should(BeTrue())
route := &routev1.Route{}
routeName := generateRouteName(gpsSite, "my-gps-site.web.cern.ch")
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: routeName, Namespace: operatorNamespace}, route)).Should(Succeed())
Expect(route.Annotations["haproxy.router.openshift.io/ip_whitelist"]).To(Equal("example-ip-whitelist"))
})
})
})
Loading