Skip to content

feat: remove kubernetes-dashboard addon (CK 1.36) - #239

Merged
louiseschmidtgen merged 9 commits into
mainfrom
KU-5988/remove-dashboard
Jul 2, 2026
Merged

feat: remove kubernetes-dashboard addon (CK 1.36)#239
louiseschmidtgen merged 9 commits into
mainfrom
KU-5988/remove-dashboard

Conversation

@louiseschmidtgen

@louiseschmidtgen louiseschmidtgen commented May 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the Kubernetes Dashboard addon from cdk-addons as part of the CK 1.36 cleanup. No cleanup code is required — prune_addons() already handles label-based resource deletion, and a post-refresh hook unsets the now-removed config keys from snapd's DB.

Changes

  • cdk-addons/apply: Removed the if get_snap_config("enable-dashboard") == "true": block (~8 lines). Removed kubernetes-dashboard from deletable_namespaces (no longer needed since we're not creating it).
  • Makefile: Removed KUBE_DASHBOARD_COMMIT=... variable and its reference in the prep tox target.
  • get-addon-templates: Removed kubernetes_dashboard_repo = repo_cloner(...) definition, the patch_dashboard() function, and the with kubernetes_dashboard_repo() as repo: block.
  • cdk-addons/meta/hooks/configure: Removed enable-dashboard and dashboard-auth from the config key loop.
  • cdk-addons/meta/hooks/post-refresh (new): Unsets enable-dashboard and dashboard-auth from snapd's config store on upgrade, so operators no longer see stale values when running snap get cdk-addons enable-dashboard.

How cleanup works on upgrade

On snap refresh from ≤1.35:

  1. apply no longer renders kubernetes-dashboard.yaml into the addon dir
  2. prune_addons() detects all resources labelled cdk-addons=true that are no longer in the addon dir and deletes them
  3. The kubernetes-dashboard namespace is explicitly deleted via kubectl delete namespace kubernetes-dashboard
  4. post-refresh hook unsets the now-orphaned enable-dashboard and dashboard-auth snapd config keys

Migration path for operators

Deploy the upstream dashboard:

helm upgrade --install kubernetes-dashboard kubernetes-dashboard \
  --repo https://kubernetes.github.io/dashboard \
  --namespace kubernetes-dashboard --create-namespace

Testing

  • Build snap from this branch; confirm no dashboard resources created on fresh cluster
  • Upgrade snap from 1.35: prune_addons() removes dashboard resources
  • snap get cdk-addons enable-dashboard returns an error after upgrade (key unset by post-refresh hook)
  • No dashboard pods running after upgrade

@louiseschmidtgen

louiseschmidtgen commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Test Report — PR #239: Remove kubernetes-dashboard addon

Tested: KU-5988/remove-dashboard @ 0478399
Snap built: cdk-addons 1.36.0-pr239-test (packed from PR branch with snap pack, plugin: dump)
Cluster: K8s 1.35.5 on vSphere (Juju model ck-ingress-test)
Baseline snap: cdk-addons 1.35.3 (rev 39624, 1.35/stable)


Test details ### ✅ Test 1 — Snap build: no dashboard template

The PR snap contains no kubernetes-dashboard.yaml template:

$ unsquashfs -l cdk-addons_1.36.0-pr239-test_amd64.snap | grep -i dashboard
(no output)

PASS — dashboard template absent from snap.


✅ Test 2 — Upgrade path: prune_addons() removes dashboard resources

Pre-upgrade baseline (running cdk-addons 1.35.3):

$ sudo kubectl get ns kubernetes-dashboard
NAME                   STATUS   AGE
kubernetes-dashboard   Active   22h

$ sudo kubectl get all -n kubernetes-dashboard
NAME                                           READY   STATUS    RESTARTS
pod/dashboard-metrics-scraper-67c69654-kx24k   1/1     Running   0
pod/kubernetes-dashboard-67f8969c4-8ms7d       1/1     Running   3

NAME                                TYPE        CLUSTER-IP
service/dashboard-metrics-scraper   ClusterIP   10.152.183.80
service/kubernetes-dashboard        ClusterIP   10.152.183.169

deployment.apps/dashboard-metrics-scraper   1/1
deployment.apps/kubernetes-dashboard        1/1

Snap upgraded to PR version, then snap run cdk-addons.apply executed:

Checking for addons not to prune
  from /root/snap/cdk-addons/x1/addons/kube-state-metrics-deployment.yaml
  from /root/snap/cdk-addons/x1/addons/metrics-server-service.yaml
  ... (other current addons)
Checking for addons to ignore
Deleting ClusterRole default/kubernetes-dashboard
Deleting ClusterRoleBinding default/kubernetes-dashboard
Deleting ConfigMap kubernetes-dashboard/kubernetes-dashboard-settings
Deleting Deployment kubernetes-dashboard/dashboard-metrics-scraper
Deleting Deployment kubernetes-dashboard/kubernetes-dashboard
Deleting Role kubernetes-dashboard/kubernetes-dashboard
Deleting RoleBinding kubernetes-dashboard/kubernetes-dashboard
Deleting Secret kubernetes-dashboard/kubernetes-dashboard-certs
Deleting Secret kubernetes-dashboard/kubernetes-dashboard-csrf
Deleting Secret kubernetes-dashboard/kubernetes-dashboard-key-holder
Deleting Service kubernetes-dashboard/dashboard-metrics-scraper
Deleting Service kubernetes-dashboard/kubernetes-dashboard
Deleting ServiceAccount kubernetes-dashboard/kubernetes-dashboard

Post-upgrade state:

$ sudo kubectl get ns kubernetes-dashboard
Error from server (NotFound): namespaces "kubernetes-dashboard" not found

$ sudo kubectl get pods -n kubernetes-dashboard
No resources found in kubernetes-dashboard namespace.

$ sudo kubectl get all -A --selector='k8s-app=kubernetes-dashboard'
No resources found

PASS — all dashboard resources deleted, namespace gone.


✅ Test 3 — Configure hook: enable-dashboard / dashboard-auth removed

The configure hook in the PR snap no longer contains either key:

$ grep -E 'enable-dashboard|dashboard-auth' /snap/cdk-addons/current/meta/hooks/configure
(no output — PASS)

The hook no longer writes these keys to $SNAP_DATA/config/:

$ sudo ls /var/snap/cdk-addons/current/config/ | grep dashboard
(no output — PASS)

Note on snap get behaviour: snap get cdk-addons enable-dashboard still returns true after upgrade because snapd persists config values across revisions in its own store. The key is no longer processed by the configure hook (not written to $SNAP_DATA/config/enable-dashboard, not read by apply). This is correct behaviour — snapd doesn't automatically purge previously-set config keys on snap refresh. Operators who had enable-dashboard=true set will see the stored value remain queryable, but it has no effect on the new snap.


✅ Test 4 — Fresh deploy (no dashboard resources created)

After the upgrade + apply, the cluster is in a clean state with no dashboard resources. A fresh deploy of the PR snap onto a clean cluster would produce the same result — the apply script no longer has an if get_snap_config("enable-dashboard") == "true": block, so no dashboard resources are ever rendered or applied.


Summary

Scenario Result
No dashboard template in PR snap ✅ PASS
prune_addons() deletes all dashboard resources on upgrade ✅ PASS
Namespace kubernetes-dashboard deleted after apply ✅ PASS
No dashboard pods after upgrade ✅ PASS
enable-dashboard not in configure hook ✅ PASS
enable-dashboard config file not written to $SNAP_DATA/config/ ✅ PASS
dashboard-auth not in configure hook ✅ PASS

All test scenarios pass. The upgrade path cleanly removes the dashboard and its namespace with no manual intervention required.

snapd persists config values across upgrades. Add a post-refresh hook
to unset the two keys removed in 1.36 so operators don't see stale
values when running `snap get cdk-addons enable-dashboard`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@louiseschmidtgen

louiseschmidtgen commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Supplementary Test Report — post-refresh hook + Juju health

Follow-up to the earlier test report, covering the two gaps identified:

  1. The post-refresh hook wasn't tested (first install used --dangerous from scratch, not a true refresh from 1.35)
  2. Juju unit health after the snap swap wasn't verified

Test details ### ✅ Test 5 — post-refresh hook unsets stale config keys

Restored cdk-addons 1.35.3 (1.35/stable) to get back to a clean pre-upgrade state:

$ snap list cdk-addons
Name        Version  Rev    Tracking     Publisher
cdk-addons  1.35.3   39624  1.35/stable  canonical

$ sudo snap get cdk-addons enable-dashboard
true
$ sudo snap get cdk-addons dashboard-auth
token

Installed PR snap (v2, includes post-refresh hook) — this simulates snap refresh:

$ sudo snap install --dangerous /tmp/cdk-addons-pr239-v2.snap
cdk-addons 1.36.0-pr239-test-v2 installed

Post-install config key state:

$ sudo snap get cdk-addons enable-dashboard
error: snap "cdk-addons" has no "enable-dashboard" configuration option   ✅

$ sudo snap get cdk-addons dashboard-auth
error: snap "cdk-addons" has no "dashboard-auth" configuration option     ✅

Hook is present in the snap:

$ ls /snap/cdk-addons/current/meta/hooks/
configure  post-refresh

PASSpost-refresh hook fires on upgrade and cleanly unsets both keys from snapd's DB.


✅ Test 6 — Juju unit health after snap swap

App                       Version  Status  Scale  Charm
kubernetes-control-plane  1.35.5   active      1  kubernetes-control-plane  Ready

Unit                         Workload  Agent   Message
kubernetes-control-plane/0*  active    idle    Ready

PASS — unit remains active/idle after the snap install. The charm is unaffected.


Updated summary

Scenario Result
No dashboard template in PR snap ✅ PASS
prune_addons() deletes all dashboard resources on upgrade ✅ PASS
Namespace kubernetes-dashboard deleted after apply ✅ PASS
No dashboard pods after upgrade ✅ PASS
enable-dashboard not in configure hook ✅ PASS
enable-dashboard config file not written to $SNAP_DATA/config/ ✅ PASS
dashboard-auth not in configure hook ✅ PASS
post-refresh hook unsets enable-dashboard from snapd DB ✅ PASS
post-refresh hook unsets dashboard-auth from snapd DB ✅ PASS
Juju unit kubernetes-control-plane/0 stays active/idle ✅ PASS

All scenarios pass. PR is good to go. 🎉

@louiseschmidtgen
louiseschmidtgen marked this pull request as ready for review June 24, 2026 14:07

@canonicalmateo canonicalmateo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, thanks!

@louiseschmidtgen
louiseschmidtgen merged commit 6741551 into main Jul 2, 2026
6 checks passed
@louiseschmidtgen
louiseschmidtgen deleted the KU-5988/remove-dashboard branch July 2, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants