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

Conversation

jasonmadigan
Copy link
Member

@jasonmadigan jasonmadigan commented Oct 8, 2024

What

Load the location of the topology ConfigMap dynamically. An update to the kuadrant-operator now sets some env-vars on the ConsolePlugin deployment, which the plugin uses to discover the topology resource.

Resolves: Kuadrant/kuadrant-console-plugin#48

Verification

Verified on OpenShift v4.15

  • Install Gateway API
make gateway-api-install
  • Install Istio

Follow user guide

  • Deploy the kuadrant operator to a NS other than kuadrant-system
kubectl create ns quadrant-system

Install the operator from this branch (dynamic-topology):

kubectl apply -f - <<EOF
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: kuadrant-operator-catalog
  namespace: quadrant-system
spec:
  sourceType: grpc
  image: quay.io/kuadrant/kuadrant-operator-catalog:dynamic-topology
  displayName: Kuadrant Operators
  publisher: grpc
  updateStrategy:
    registryPoll:
      interval: 45m
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: kuadrant-operator
  namespace: quadrant-system
spec:
  channel: preview
  installPlanApproval: Automatic
  name: kuadrant-operator
  source: kuadrant-operator-catalog
  sourceNamespace: quadrant-system
---
kind: OperatorGroup
apiVersion: operators.coreos.com/v1
metadata:
  name: kuadrant
  namespace: quadrant-system
spec:
  upgradeStrategy: Default
EOF

Wait for the Kuadrant Operators to be installed as follows:

kubectl get installplan -n quadrant-system -o=jsonpath='{.items[0].status.phase}'

After some time, this command should return complete.

Apply the Kuadrant custom resource

kubectl -n quadrant-system apply -f - <<EOF
---
apiVersion: kuadrant.io/v1beta1
kind: Kuadrant
metadata:
  name: quadrant-sample
spec: {}
EOF

Note: a patched version of the kuadrant-console-plugin has already been published as :latest, because I like to live dangerously.

Ensure the topology is loaded OK on the Kuadrant > Policy Topology view

Verify the two env vars are set in the kuadrant-console deployment:

kubectl get deployment kuadrant-console -n quadrant-system -o jsonpath='{.spec.template.spec.containers}' | yq e -P
- env:
    - name: TOPOLOGY_CONFIGMAP_NAME
      value: topology
    - name: TOPOLOGY_CONFIGMAP_NAMESPACE
      value: quadrant-system
  image: quay.io/kuadrant/console-plugin:latest
  imagePullPolicy: Always
  name: kuadrant-console
  ports:
    - containerPort: 9443
      protocol: TCP
  resources: {}
  terminationMessagePath: /dev/termination-log
  terminationMessagePolicy: File
  volumeMounts:
    - mountPath: /var/serving-cert
      name: plugin-serving-cert
      readOnly: true
    - mountPath: /etc/nginx/nginx.conf
      name: nginx-conf
      readOnly: true
      subPath: nginx.conf

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.40%. Comparing base (63f1d28) to head (4e9caf3).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #920      +/-   ##
==========================================
- Coverage   81.49%   81.40%   -0.10%     
==========================================
  Files         102      115      +13     
  Lines        7177     7700     +523     
==========================================
+ Hits         5849     6268     +419     
- Misses        898      996      +98     
- Partials      430      436       +6     
Flag Coverage Δ
bare-k8s-integration 9.66% <0.00%> (+0.77%) ⬆️
controllers-integration 71.57% <0.00%> (+6.24%) ⬆️
envoygateway-integration 48.83% <0.00%> (-1.47%) ⬇️
gatewayapi-integration 14.56% <0.00%> (+0.16%) ⬆️
istio-integration 51.79% <0.00%> (-1.72%) ⬇️
unit 30.55% <100.00%> (+2.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
api/v1beta1 (u) 90.90% <ø> (ø)
api/v1beta2 (u) 86.61% <ø> (ø)
pkg/common (u) 88.13% <ø> (ø)
pkg/istio (u) 71.51% <100.00%> (ø)
pkg/log (u) 94.73% <ø> (ø)
pkg/reconcilers (u) ∅ <ø> (∅)
pkg/rlptools (u) 85.00% <ø> (-0.84%) ⬇️
controllers (i) 82.50% <65.30%> (-0.56%) ⬇️
Files with missing lines Coverage Δ
controllers/consoleplugin_reconciler.go 81.25% <100.00%> (ø)
pkg/openshift/consoleplugin/deployment.go 100.00% <100.00%> (ø)
pkg/openshift/consoleplugin/nginx_configmap.go 100.00% <100.00%> (ø)

... and 18 files with indirect coverage changes

@eguzki
Copy link
Contributor

eguzki commented Oct 10, 2024

Thanks for the verification steps. Working like a charm!!

@@ -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.

@jasonmadigan jasonmadigan merged commit df87130 into main Oct 10, 2024
31 of 32 checks passed
@jasonmadigan jasonmadigan deleted the dynamic-topology branch October 10, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

topology: read ConfigMap colcated with Kuadrant instance (currently hard-coded)
2 participants