From df87130c2a8c64e46f4b92c8b68253504c3a2768 Mon Sep 17 00:00:00 2001 From: Jason Madigan Date: Thu, 10 Oct 2024 14:37:36 +0100 Subject: [PATCH] topology CM lookup, inject into console-plugin deployment (#920) * topology CM lookup, inject into console-plugin deployment Signed-off-by: Jason Madigan * console-plugin: reuse topology configmap name and namespace (#929) Signed-off-by: Eguzki Astiz Lezaun --------- Signed-off-by: Jason Madigan Signed-off-by: Eguzki Astiz Lezaun Co-authored-by: Eguzki Astiz Lezaun --- controllers/consoleplugin_reconciler.go | 2 +- pkg/openshift/consoleplugin/deployment.go | 6 +++++- pkg/openshift/consoleplugin/nginx_configmap.go | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/controllers/consoleplugin_reconciler.go b/controllers/consoleplugin_reconciler.go index 0c80e656e..10b12a900 100644 --- a/controllers/consoleplugin_reconciler.go +++ b/controllers/consoleplugin_reconciler.go @@ -89,7 +89,7 @@ func (r *ConsolePluginReconciler) Run(eventCtx context.Context, _ []controller.R } // Deployment - deployment := consoleplugin.Deployment(r.namespace, ConsolePluginImageURL) + deployment := consoleplugin.Deployment(r.namespace, ConsolePluginImageURL, TopologyConfigMapName) deploymentMutators := make([]reconcilers.DeploymentMutateFn, 0) deploymentMutators = append(deploymentMutators, reconcilers.DeploymentImageMutator) if !topologyExists { diff --git a/pkg/openshift/consoleplugin/deployment.go b/pkg/openshift/consoleplugin/deployment.go index cd40bfb83..39360c7ec 100644 --- a/pkg/openshift/consoleplugin/deployment.go +++ b/pkg/openshift/consoleplugin/deployment.go @@ -80,7 +80,7 @@ func DeploymentLabels(namespace string) map[string]string { return result } -func Deployment(ns, image string) *appsv1.Deployment { +func Deployment(ns, image, topologyName string) *appsv1.Deployment { return &appsv1.Deployment{ TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"}, ObjectMeta: metav1.ObjectMeta{ @@ -108,6 +108,10 @@ func Deployment(ns, image string) *appsv1.Deployment { }, ImagePullPolicy: corev1.PullAlways, VolumeMounts: DeploymentVolumeMounts(), + Env: []corev1.EnvVar{ + {Name: "TOPOLOGY_CONFIGMAP_NAME", Value: topologyName}, + {Name: "TOPOLOGY_CONFIGMAP_NAMESPACE", Value: ns}, + }, }, }, Volumes: DeploymentVolumes(), diff --git a/pkg/openshift/consoleplugin/nginx_configmap.go b/pkg/openshift/consoleplugin/nginx_configmap.go index f3e3c0fbf..95a166ce3 100644 --- a/pkg/openshift/consoleplugin/nginx_configmap.go +++ b/pkg/openshift/consoleplugin/nginx_configmap.go @@ -34,6 +34,9 @@ http { location / { root /usr/share/nginx/html; } + location /config.js { + root /tmp; + } } } `,