Container Infrastructure/Side Project_202108

11. kubernetes dashboard 생성

11mia 2021. 8. 28. 05:04

1. 대시보드 배포

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml

2. 로그인 계정 생성

# Service Account 생성
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard


# ClusterRoleBinding
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: kubernetes-dashboard

# get token
kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"

3. 대시보드 실행

kubectl proxy

# 접속url
# http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

앞서 생성한 토큰 입력

+) kubectl proxy 로 접속시엔 해당 커멘드가 실행된 머신에서만 접근이 가능하며,

이는  kubectl proxy의 특성때문

# 어디까지 했나

 

 

# 참고

https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

 

Deploy and Access the Kubernetes Dashboard

Deploy the web UI (Kubernetes Dashboard) and access it.

kubernetes.io

 

https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md