Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topology CM lookup, inject into console-plugin deployment #920

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/consoleplugin_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion pkg/openshift/consoleplugin/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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(),
Expand Down
3 changes: 3 additions & 0 deletions pkg/openshift/consoleplugin/nginx_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ http {
location / {
root /usr/share/nginx/html;
}
location /config.js {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity. What is this doing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically:

  • there's a new custom entrypoint script in the plugin image
  • that script injects the two env vars into config.js
  • the topology view in plugin loads this config.js, with the correct pointers to the ns/name of the topology configmap

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

root /tmp;
}
}
}
`,
Expand Down
Loading