Skip to content

Instantly share code, notes, and snippets.

@deskoh
Last active June 28, 2019 00:24
Show Gist options
  • Save deskoh/9062552889ec51d6e4c16d00ebb4903c to your computer and use it in GitHub Desktop.
Save deskoh/9062552889ec51d6e4c16d00ebb4903c to your computer and use it in GitHub Desktop.
Kubernetes

Kubernetes Dashboard

Deploy dashboard.

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml

Create service account to access dashboard

# Run following command
kubectl -n kube-system create serviceaccount admin-user
kubectl create clusterrolebinding admin-user --clusterrole cluster-admin --serviceaccount=kube-system:admin-user

# Or apply the following
kubectl apply -f dashboard-adminuser.yaml
# dashboard-adminuser.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system

Get token

$ kubectl -n kube-system get secret | grep admin-user | awk '{print $1}'
admin-user-token-2cd9k
$ kubectl -n kube-system describe secret admin-user-token-2cd9k

# Or
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Access Proxy

$ kubectl proxy
# URL: http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment