Deploying Kubernetes Dashboard with Custom Service Configuration and Admin Token
This guide walks through pulling and retagging the Kubernetes Dashboard image, applying the deployment manifest, modifying the Service to use a NodePort, creating an admin ServiceAccount and ClusterRoleBinding, and retrieving the admin token and service port for external access.
First, pull the Kubernetes Dashboard image from the Aliyun registry and retag it to the official k8s.gcr.io repository.
docker pull registry.cn-beijing.aliyuncs.com/kubernetesdevops/kubernetes-dashboard-amd64:v1.10.0
docker tag registry.cn-beijing.aliyuncs.com/kubernetesdevops/kubernetes-dashboard-amd64:v1.10.0 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0Then apply the official deployment manifest.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yamlModify the Service definition to expose the dashboard via NodePort 31234.
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
ports:
- port: 443
targetPort: 8443
nodePort: 31234
selector:
k8s-app: kubernetes-dashboard
type: NodePortCreate a ClusterRoleBinding and ServiceAccount for an admin user.
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: admin
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: admin
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: ReconcileRetrieve the admin token and the service port.
kubectl get secret -n kube-system | grep "admin"
kubectl describe secret admin-token-gb7db-n kube-system
kubectl get service --namespace=kube-systemThe dashboard becomes accessible at the NodePort with the obtained token, as shown in the screenshots.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.