Notice
Recent Posts
Recent Comments
Link
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

감사합니다.

Single k8s Master - dashboard 설치하기 본문

Kubernetes 따라하기

Single k8s Master - dashboard 설치하기

springjunny 2023. 9. 23. 15:42

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

공식 사이트 및 블로그 문서 참고하여 k8s 대시 보드 만드는 절차를 작성해 보았다.

1. Deploying the Dashboard UI

admin@ubuntuk8s:~$kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

 2. 계정 생성

# service account 생성
admin@ubuntuk8s:~$cat serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
admin@ubuntuk8s:~$kubectl apply -f serviceaccount.yaml

# cluster role binding
admin@ubuntuk8s:~$cat ClusterRoleBinding.yaml
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
admin@ubuntuk8s:~$kubectl apply -f ClusterRoleBinding.yaml

#long-lived bearer token 생성
admin@ubuntuk8s:~$cat secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/service-account.name: "admin-user"   
type: kubernetes.io/service-account-token  
kubectl apply -f secret.yaml

# secret 확인
admin@ubuntuk8s:~$kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath={".data.token"} | base64 -d

3. Dashboard service 생성

admin@ubuntuk8s:~$cat dashboard-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: k8s-dashboard-service
  namespace: kubernetes-dashboard
  labels:
    k8s-app: kubernetes-dashboard
spec:
  type: NodePort
  ports:
  - nodePort: 32767
    port: 10443
    targetPort: 8443
    protocol: TCP
    name: http
  selector:
    k8s-app: kubernetes-dashboard
admin@ubuntuk8s:~$kubectl apply -f dashboard-service.yaml

service 를 사용하는 방법이 가장 좋아 보인다. 32767 포트로 접속하기 위한 service를 작성하였다.

4. Browser 접속 확인

https://서버IP:32767 주소로 접속

5. Remove the admin ServiceAccount and ClusterRoleBinding

kubectl -n kubernetes-dashboard delete serviceaccount admin-user
kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user