diff --git a/controllers/ensure.go b/controllers/ensure.go index a001b2a..178cc2f 100644 --- a/controllers/ensure.go +++ b/controllers/ensure.go @@ -90,7 +90,7 @@ func (r *DevfileRegistryReconciler) generateResourceObject(cr *registryv1alpha1. case *appsv1.Deployment: return registry.GenerateDeployment(cr, r.Scheme, labels) case *corev1.ConfigMap: - return registry.GenerateOCIRegistryConfigMap(cr, r.Scheme, labels) + return registry.GenerateRegistryConfigMap(cr, r.Scheme, labels) case *corev1.PersistentVolumeClaim: return registry.GeneratePVC(cr, r.Scheme, labels) case *corev1.Service: diff --git a/pkg/registry/configmap.go b/pkg/registry/configmap.go index b3497ff..3cdc547 100644 --- a/pkg/registry/configmap.go +++ b/pkg/registry/configmap.go @@ -19,8 +19,8 @@ import ( registryv1alpha1 "github.com/devfile/registry-operator/api/v1alpha1" ) -// GenerateOCIRegistryConfigMap returns a configmap that is used to configure the OCI registry container -func GenerateOCIRegistryConfigMap(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Scheme, labels map[string]string) *corev1.ConfigMap { +// GenerateRegistryConfigMap returns a configmap that is used to configure the devfile registry +func GenerateRegistryConfigMap(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Scheme, labels map[string]string) *corev1.ConfigMap { configMapData := make(map[string]string, 0) registryConfig := ` @@ -45,6 +45,15 @@ http: configMapData["registry-config.yml"] = registryConfig + viewerConfig := ` +{ + "Community": { + "url": "http://localhost:8080" + } +}` + + configMapData["devfile-registry-hosts.json"] = viewerConfig + cm := &corev1.ConfigMap{ ObjectMeta: generateObjectMeta(ConfigMapName(cr.Name), cr.Namespace, labels), Data: configMapData, diff --git a/pkg/registry/deployment.go b/pkg/registry/deployment.go index 2404ea8..d849979 100644 --- a/pkg/registry/deployment.go +++ b/pkg/registry/deployment.go @@ -73,7 +73,28 @@ func GenerateDeployment(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Sc }, }, }, + StartupProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/viewer", + Port: intstr.FromInt(DevfileIndexPort), + }, + }, + InitialDelaySeconds: 30, + PeriodSeconds: 10, + }, + VolumeMounts: []corev1.VolumeMount{ + { + Name: "viewer-config", + MountPath: "/app/config", + ReadOnly: false, + }, + }, Env: []corev1.EnvVar{ + { + Name: "DEVFILE_VIEWER_ROOT", + Value: "/viewer", + }, { Name: "ENABLE_TELEMETRY", Value: strconv.FormatBool(IsTelemetryEnabled(cr)), @@ -131,6 +152,22 @@ func GenerateDeployment(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Sc }, }, }, + { + Name: "viewer-config", + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: ConfigMapName(cr.Name), + }, + Items: []corev1.KeyToPath{ + { + Key: "devfile-registry-hosts.json", + Path: "devfile-registry-hosts.json", + }, + }, + }, + }, + }, }, }, }, diff --git a/pkg/registry/naming.go b/pkg/registry/naming.go index 488a404..d308f06 100644 --- a/pkg/registry/naming.go +++ b/pkg/registry/naming.go @@ -29,7 +29,6 @@ func ServiceName(devfileRegistryName string) string { } // ConfigMapName returns the name of the service object associated with the DevfileRegistry CR -// Just returns the CR name right now, but extracting to a function to avoid relying on that assumption in the future func ConfigMapName(devfileRegistryName string) string { return devfileRegistryName + "-registry-config" } diff --git a/tests/integration/pkg/tests/devfileregistry_tests.go b/tests/integration/pkg/tests/devfileregistry_tests.go index f7bb86c..9c0b4f3 100644 --- a/tests/integration/pkg/tests/devfileregistry_tests.go +++ b/tests/integration/pkg/tests/devfileregistry_tests.go @@ -45,13 +45,13 @@ var _ = ginkgo.Describe("[Create Devfile Registry resource]", func() { gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Wait for the registry instance to become ready - err = K8sClient.WaitForRegistryInstance(crName, 30*time.Second) + err = K8sClient.WaitForRegistryInstance(crName, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Retrieve the registry URL and verify the server is up and running registry, err := K8sClient.GetRegistryInstance(crName) gomega.Expect(err).NotTo(gomega.HaveOccurred()) - err = util.WaitForServer(registry.Status.URL, 30*time.Second) + err = util.WaitForServer(registry.Status.URL, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Verify that the index metrics endpoint is running @@ -94,7 +94,7 @@ var _ = ginkgo.Describe("[Create Devfile Registry resource with TLS enabled]", f gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Wait for the registry instance to become ready - err = K8sClient.WaitForRegistryInstance(crName, 30*time.Second) + err = K8sClient.WaitForRegistryInstance(crName, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Retrieve the registry URL and verify that its protocol is https @@ -103,7 +103,7 @@ var _ = ginkgo.Describe("[Create Devfile Registry resource with TLS enabled]", f gomega.Expect(registry.Status.URL).To(gomega.ContainSubstring("https://")) // Verify that the server is accessible. - err = util.WaitForServer(registry.Status.URL, 30*time.Second) + err = util.WaitForServer(registry.Status.URL, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) }) @@ -130,13 +130,13 @@ var _ = ginkgo.Describe("[Update Devfile Registry resource]", func() { gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Wait for the registry instance to become ready - err = K8sClient.WaitForRegistryInstance(crName, 30*time.Second) + err = K8sClient.WaitForRegistryInstance(crName, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Retrieve the registry URL and verify the server is up and running registry, err := K8sClient.GetRegistryInstance(crName) gomega.Expect(err).NotTo(gomega.HaveOccurred()) - err = util.WaitForServer(registry.Status.URL, 30*time.Second) + err = util.WaitForServer(registry.Status.URL, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) // Update the devfileregistry resource for this test case @@ -147,12 +147,12 @@ var _ = ginkgo.Describe("[Update Devfile Registry resource]", func() { } // Retrieve the registry URL and verify that its protocol is https - url, err := K8sClient.WaitForURLChange(crName, registry.Status.URL, 30*time.Second) + url, err := K8sClient.WaitForURLChange(crName, registry.Status.URL, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) gomega.Expect(url).To(gomega.ContainSubstring("https://")) // Verify that the server is accessible. - err = util.WaitForServer(url, 30*time.Second) + err = util.WaitForServer(url, 5*time.Minute) gomega.Expect(err).NotTo(gomega.HaveOccurred()) })