본문 바로가기

가상화/Kubernetes

kubernetes dashboard 설치

반응형

+++++ 버전: Dashboard v2.4.0+0.ge75ebcf68 +++++
1. Manifest(yaml) 파일 다운로드
 > wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml

2. 적용
 > kubectl apply -f recommanded.yaml

3. dashboard ingress 생성
 > vi dashboard-ingress.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: kubernetes-dashboard
  name: kubernetes-dashboard-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    # Uncomment next if you use https://cert-manager.io/
    #cert-manager.io/cluster-issuer: "<YOUR CLUSTER ISSUER>"
spec:
  tls:
  - hosts:
    - dashboard.k8s.stage
    secretName: kubernetes-dashboard-cert
  rules:
  - host: dashboard.k8s.stage
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: kubernetes-dashboard
            port:
              number: 443

---
 > kubectl apply -f dashboard-ingress.yaml

 

4. 계정 및 토큰 생성
 4.1 계정 생성
  > vi kubernetes-dashboard-service-account.yam

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
---
 4.2 Secret(토큰) 생성
  > vi admin-user-acoount-token.yaml 
---
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
  name: admin-user-account-token
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/service-account.name: admin-user
---
  > kubectl apply -f admin-user-acoount-token.yaml

 4.3 token 확인
 > kubectl describe secret  admin-user-account-token  -n kubernetes-dashboard

 4.4 임시 token 생성
 > kubectl  -n kubernetes-dashboard create token admin-user

5. kubernetes-dashboard 삭제
 > kubectl  delete -f recommended.yaml

반응형