Intro
The Kubernetes Web UI Dashboard (often simply "the Dashboard") is a critical administrative interface for many clusters. Losing its configuration, access tokens, or custom settings can disrupt cluster management. This guide explains how to back up and restore the Dashboard, covering version inventory, safe configuration, verification, failure recovery, and operational checklists.
You'll learn concrete commands for observing the current state, exporting and importing resources, validating a restore, and recovering from common failures. The focus is on practical, repeatable procedures using kubectl and YAML manifests. We assume you have a running Kubernetes cluster with the Dashboard deployed, likely via the recommended manifest or Helm chart.
Always test these procedures in a non-production environment first. The goal is to make backup and restore routine, low-risk, and verifiable.
Version and Environment Inventory
Before touching anything, know exactly what you're running. Start by checking the Kubernetes server version and the Dashboard deployment details.
kubectl version --short
kubectl get pods -n kubernetes-dashboard -o wide
Expected output shows the client and server versions, and a list of dashboard pods with their status, age, and node. For example:
Client Version: v1.27.3
Server Version: v1.27.3
NAME READY STATUS RESTARTS AGE IP NODE
dashboard-metrics-scraper-7c8f8b8d-9x2k 1/1 Running 0 5d 10.244.1.5 node-1
kubernetes-dashboard-6c8b8d8d-7z2k 1/1 Running 0 5d 10.244.1.6 node-1
Next, inspect the dashboard deployments and service:
kubectl get deployment -n kubernetes-dashboard
kubectl get service -n kubernetes-dashboard kubernetes-dashboard-kong-proxy -o yaml
Look for the image version, replicas, resource limits, and any custom annotations or labels. Record these for later comparison. Also check the secrets used by the dashboard. For authentication, follow the guide at https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md to create a sample user and obtain its token.
kubectl get secrets -n kubernetes-dashboard
Note any created service account tokens or secret names, because some backup methods include secrets. Verify RBAC bindings:
kubectl get clusterrolebinding kubernetes-dashboard
kubectl get rolebinding -n kubernetes-dashboard
This inventory ensures you know what components exist, their versions, and their dependencies. Without it, a backup might miss critical pieces like custom roles or annotations.
Safe Configuration Path
Configuring the Dashboard safely means understanding what can be changed without breaking access. Common configuration items include:
- Service type (ClusterIP, NodePort, LoadBalancer)
- Ingress rules
- TLS certificates
- Authentication mode (token vs. basic)
- Custom resource definitions (CRDs) for plugins
To avoid losing configuration during a backup, export the current YAML definitions:
kubectl get deployment -n kubernetes-dashboard -o yaml > dashboard-deployment-backup.yaml
kubectl get service -n kubernetes-dashboard kubernetes-dashboard-kong-proxy -o yaml > dashboard-service-backup.yaml
kubectl get configmap -n kubernetes-dashboard -o yaml > dashboard-configmaps-backup.yaml
If you use Helm, you can capture the release values:
helm get values kubernetes-dashboard -n kubernetes-dashboard > dashboard-values.yaml
helm get manifest kubernetes-dashboard -n kubernetes-dashboard > dashboard-manifest.yaml
Store these files in version control. When making configuration changes, apply them in a controlled way:
kubectl apply -f dashboard-deployment-backup.yaml --dry-run=client
kubectl apply -f dashboard-deployment-backup.yaml
kubectl wait --for=condition=available deployment --all -n kubernetes-dashboard --timeout=300s
Always verify the rollout completes before moving on. Use kubectl port-forward to test access locally:
kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard-kong-proxy 8443:443
Then open https://localhost:8443 in a browser (accept the self-signed certificate) and log in with a valid token. This ensures the Dashboard is functioning after each change.
Verification and Diagnostics
Verifying the state of the Dashboard before and after backup/restore is essential. Here are diagnostic commands:
List the dashboard pods and check logs from one of them:
kubectl get pods -n kubernetes-dashboard
kubectl logs -n kubernetes-dashboard <dashboard-pod-name> --tail=50
Look for errors like Failed to watch *v1.Secret or Unauthorized. If a pod is crash-looping:
kubectl describe pod -n kubernetes-dashboard <pod-name>
kubectl logs -n kubernetes-dashboard <pod-name> --previous
Verify the service endpoints:
kubectl get endpoints -n kubernetes-dashboard kubernetes-dashboard-kong-proxy
Expected output should show at least one IP address and port, matching the pod IPs. If endpoints are empty, the service selector may be wrong or pods are not ready.
Test API access from within the cluster:
kubectl run -it --rm debug --image=curlimages/curl --restart=Never -n kubernetes-dashboard -- curl -k https://kubernetes-dashboard-kong-proxy:443
This should return the dashboard's HTML or redirect. For authentication, use a valid bearer token (for example, from the sample user created per the guide). Copy the token and use it to log in. After a restore, you must repeat these checks to confirm the Dashboard is fully functional.
Failure Modes and Recovery
Backup and restore operations can go wrong in several ways. Understanding likely failure modes helps you recover quickly.
Common failure: missing secret or token
Symptom: Dashboard pods fail to start with MountVolume.SetUp failed for volume "kubernetes-dashboard-certs" or secret "kubernetes-dashboard-certs" not found.
The dashboard expects certain secrets. If you only backed up the deployment, the secrets may be lost. Recovery:
kubectl get secret -n kubernetes-dashboard
If missing, recreate the secret. For TLS certs, you can generate a new one:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout dashboard.key -out dashboard.crt -subj "/CN=kubernetes-dashboard"
kubectl create secret tls kubernetes-dashboard-certs --key dashboard.key --cert dashboard.crt -n kubernetes-dashboard
Then restart the deployment(s):
kubectl rollout restart deployment --all -n kubernetes-dashboard
Common failure: wrong image version
Symptom: ImagePullBackOff or pods crash due to API mismatch.
Always check the image tag matches your Kubernetes version. The dashboard image is kubernetesui/dashboard:<version>. For Kubernetes 1.27, use v2.7.0. If you restored an old manifest with an incompatible image, update the image tag and re-apply:
spec:
containers:
- name: kubernetes-dashboard
image: kubernetesui/dashboard:v2.7.0
Then:
kubectl apply -f dashboard-deployment-backup.yaml
kubectl wait --for=condition=available deployment --all -n kubernetes-dashboard --timeout=300s
Common failure: broken RBAC
Symptom: Dashboard loads but shows Forbidden or no resources.
Check the service account and role bindings:
kubectl auth can-i list pods --as=system:serviceaccount:kubernetes-dashboard:kubernetes-dashboard -n default
If it says no, restore the ClusterRoleBinding:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kubernetes-dashboard
Apply and re-test.
Common failure: configuration drift
Symptom: Dashboard works but custom settings (like resource limits or annotations) are gone.
Keep a complete backup of all YAML in version control. After restore, diff against the original:
diff <(kubectl get deployment -n kubernetes-dashboard -o yaml) dashboard-deployment-backup.yaml
If differences exist beyond expected metadata (e.g., resourceVersion), investigate and reconcile.
Common Pitfalls
Here are frequent mistakes in Dashboard backup/restore and how to avoid them.
Pitfall 1: backing up only the deployment, not the full state
Why it happens: People assume the dashboard is just a pod. But it needs secrets, configmaps, services, and RBAC.
How to avoid: Use a comprehensive backup command:
kubectl get all,secret,configmap,serviceaccount,role,rolebinding,clusterrole,clusterrolebinding -n kubernetes-dashboard -o yaml > dashboard-full-backup.yaml
This captures everything in the namespace. For cluster-scoped resources (ClusterRole, ClusterRoleBinding), use:
kubectl get clusterrole,clusterrolebinding -o yaml | grep -A 20 kubernetes-dashboard > dashboard-cluster-backup.yaml
Store both files.
Pitfall 2: not testing the restore process
Why it happens: Backups are made but never restored until an incident, and then they fail due to missing components or version incompatibilities.
How to avoid: Regularly test restoration in a staging cluster. Automate with a script that deploys the backup and runs verification commands.
Pitfall 3: using a static token or password in the backup file
Why it happens: Secrets are exported as part of the backup and may be stored in plain text.
How to avoid: Encrypt backup files or store them in a secure vault. Avoid committing raw secrets to Git. If you must use Git, use a tool like Sealed Secrets or SOPS.
Pitfall 4: not pinning image versions
Why it happens: Manifests may use latest tag, which changes over time.
How to avoid: Always specify a specific version in the backup YAML. For example, kubernetesui/dashboard:v2.7.0.
Pitfall 5: ignoring RBAC during restore
Why it happens: The dashboard may start but users can't log in due to missing permissions.
How to avoid: Include RBAC resources in backup and verify with kubectl auth can-i after restore.
Operations Checklist
Use this checklist for every backup or restore operation.
Backup Checklist
- [ ] Confirm cluster access:
kubectl cluster-info - [ ] Record current dashboard version:
kubectl get deployment -n kubernetes-dashboard -o jsonpath='{.items[].spec.template.spec.containers[].image}' - [ ] Export all namespace resources:
kubectl get all,secret,configmap,serviceaccount -n kubernetes-dashboard -o yaml > dashboard-ns-backup-$(date +%Y%m%d).yaml - [ ] Export cluster-scoped RBAC:
kubectl get clusterrole,clusterrolebinding -o yaml | grep -B 2 -A 10 kubernetes-dashboard > dashboard-rbac-backup-$(date +%Y%m%d).yaml - [ ] Store backup files in a secure location (e.g., encrypted S3 bucket or Git with SOPS)
- [ ] Record the kubectl and Kubernetes versions for later reference
- [ ] Owner: DevOps Engineer (e.g., Priya Shah) reviews the backup quarterly
Restore Checklist
- [ ] Verify target cluster version matches backup source (or note differences)
- [ ] Create namespace if missing:
kubectl create namespace kubernetes-dashboard - [ ] Apply namespace resources:
kubectl apply -f dashboard-ns-backup.yaml - [ ] Apply RBAC:
kubectl apply -f dashboard-rbac-backup.yaml - [ ] Check pod status:
kubectl get pods -n kubernetes-dashboard - [ ] Verify service:
kubectl get svc -n kubernetes-dashboard - [ ] Test access:
kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard-kong-proxy 8443:443and login with token - [ ] Run diagnostics:
kubectl get pods -n kubernetes-dashboardandkubectl logs -n kubernetes-dashboard <dashboard-pod-name> --tail=50 - [ ] Document restore outcome and any differences in a runbook
- [ ] Owner: Platform Lead (e.g., Alex Chen) signs off on restore tests
Post-Verification
- [ ] Confirm all pods are
RunningandReady - [ ] Confirm no
CrashLoopBackOfforErrorstates - [ ] Confirm token authentication works for a test user
- [ ] Confirm Dashboard UI renders and can list pods in default namespace
- [ ] Schedule next backup test: monthly, with a reminder in the team calendar
Conclusion
Backing up and restoring the Kubernetes Web UI Dashboard is a critical operational skill. By following the procedures outlined here, you can ensure your dashboard configuration is safe, recoverable, and verifiable. Start with a full inventory, export all relevant resources, test the restore process, and keep your team trained on the recovery steps.
Remember to version your backups, secure your secrets, and regularly validate that restoration works. With these practices, you'll minimize downtime and maintain a reliable administrative interface for your Kubernetes cluster.