๐ŸŒฑ Infra/Container_ Kubernetes

[์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ฌด์ž‘์ • ๋”ฐ๋ผํ•˜๊ธฐ] Step 5 . Kube DashBoard ์›นUI ์„ค์น˜ํ•˜๊ธฐ :)

mini_world 2020. 12. 11. 17:39
๋ชฉ์ฐจ ์ ‘๊ธฐ

 

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์›น ๋Œ€์‹œ๋ณด๋“œ UI๋ฅผ ์„ค์น˜ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ UI๋ฅผ ํ•จ๊ป˜ ๋ฐฐํฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๋ณ„๋„๋กœ ๋ฐฐํฌํ•ด์ฃผ์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์—์„œ ๊ณต์‹ ๋ฌธ์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ž, ์ง€๊ธˆ๋ถ€ํ„ฐ ๋Œ€์‹œ๋ณด๋“œ UI ๋ฐฐํฌ๋ฅผ ์ง„ํ–‰ํ•ด๋ด…์‹œ๋‹ค.

 

1. DashBoard ์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ

์•„๋ž˜ ๋ช…๋ น์–ด๋กœ Kubernetes DashBoard ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋‹ค์šด๋กœ๋“œ ํ•ฉ๋‹ˆ๋‹ค.
apply ๋ช…๋ น์–ด๋กœ ๋‹ค์šด๋ฐ›์•„ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด ์™ธ๋ถ€์—์„œ ์ ‘์†ํ• ์ˆ˜ ์—†๊ธฐ๋•Œ๋ฌธ์—, ๋‹ค์šด๋กœ๋“œ๋ฐ›์€ ํ›„ ymalํŒŒ์ผ์„ ์กฐ๊ธˆ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

[root@kube-manager /]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml

๋‹ค์šด๋ฐ›์€ ํ›„ ๋‚ด์šฉ์„ ์กฐ๊ธˆ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค. 
41๋ฒˆ, 46๋ฒˆ ์ค„์— ๊ฐ๊ฐ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ค๋‹ˆ๋‹ค.

[root@kube-manager /]# vi recommended.yaml 

์ด์ œ, ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค!

[root@kube-manager /]# kubectl apply -f recommended.yaml 

์ƒ์„ฑ๋œ ๋ฆฌ์†Œ์Šค๋ฅผ ํ™•์ธํ•ด๋ด…์‹œ๋‹ค.
๋จผ์ €, Namespace ์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

[root@kube-manager /]# kubectl get namespace

์—ฌ๊ธฐ์— kubenetes-dashboard ์ธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

[root@kube-manager /]# kubens kubernetes-dashboard

 

2. DashBoard ์˜ค๋ธŒ์ ํŠธ ํ™•์ธ

์ด์ œ kubenetes-dashboard ๋„ค์ž„์ŠคํŽ˜์ด์Šค์˜ ์˜ค๋ธŒ์ ํŠธ(๋ฆฌ์†Œ์Šค)๋“ค์„ ์‚ดํŽด๋ด…์‹œ๋‹ค!
๋ช…๋ น์–ด๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

[root@kube-manager /]# kubectl get svc -o wide

[root@kube-manager /]# kubectl get pods -o wide

[root@kube-manager /]# kubectl get secrets

 

3. DashBoard ์‚ฌ์šฉ์ž ์ƒ์„ฑํ•˜๊ธฐ

๋Œ€์‹œ๋ณด๋“œ๋Š” Bearer ํ† ํฐ์œผ๋กœ ๋กœ๊ทธ์ธ ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
์ด ๋กœ๊ทธ์ธ ํ† ํฐ์„ ๋ฐœ๊ธ‰ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ์ž/๊ถŒํ•œ์„ ์ด๋ฒˆ ๋‹จ๊ณ„์—์„œ ์ƒ์„ฑํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค ;) ๊ณต์‹๋ฌธ์„œ๋งํฌ

๋จผ์ €, ์„œ๋น„์Šค ๊ณ„์ •(service Account) ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. 
์•„๋ž˜ ๋ช…๋ น์–ด ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•˜์‹  ํ›„ ์‹คํ–‰ ํ•˜๋ฉด "serviceaccount/admin-user created" ๋ผ๋Š” ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•„๋ž˜ ๋ช…๋ น์–ด๋Š” kubernetes-dashboard ๋„ค์ž„์ŠคํŽ˜์ด์Šค์— admin-user๋ผ๋Š” ๊ณ„์ •์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

[root@kube-manager /]# cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
EOF

์ด์ œ ์‚ฌ์šฉ์ž๋ฅผ ๋งŒ๋“ค์—ˆ์œผ๋‹ˆ, ์ด ์‚ฌ์šฉ์ž์— ๊ถŒํ•œ์„ ๋„ฃ์–ด์ค๋‹ˆ๋‹ค.
์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•œ ํ›„ ์‹คํ–‰ํ•˜๋ฉด "clusterrolebinding.rbac.authorization.k8s.io/admin-user created" ๋ผ๊ณ  ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.

[root@kube-manager /]# cat <<EOF | kubectl apply -f -
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
EOF

์ž, ์ด์ œ ๋งˆ์ง€๋ง‰์„ Bearerํ† ํฐ์„ ํ™•์ธํ•ด๋ด…์‹œ๋‹ค!!
๋จผ์ € secret ์˜ค๋ธŒ์ ํŠธ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.  'admin-user'๊ฐ€ ๋ณด์ž…๋‹ˆ๋‹ค. 

[root@kube-manager /]# kubectl get secret

์ด์ œ ํ† ํฐ์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ๋ณต๋ถ™ํ•˜์‹œ๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์ดํ† ํฐ๊ฐ’์ด ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค. 
ํ† ํฐ๊ฐ’์„ ํ™•์ธํ–ˆ์œผ๋‹ˆ, ์ฝ˜์†”๋กœ ์ ‘์†ํ•ด๋ด…์‹œ๋‹ค!!!

[root@kube-manager /]# kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $ 1}')

 

4. DashBoard ์ ‘์†ํ•˜๊ธฐ

Kubenetes DashBoard๋Š” ๋ฐ˜๋“œ์‹œ https ๋กœ ์ ‘์†ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ https://<Node IP>:30331 ๋กœ ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค. 
์ €๊ฐ™์€ ๊ฒฝ์šฐ๋Š” ํฌ๋กฌ์ด๋‚˜, ์‚ฌํŒŒ๋ฆฌ(MAC์‚ฌ์šฉ์ž์ž…๋‹ˆ๋‹ค)๋Š” ์•„์˜ˆ ์ ‘์†์ด ๋ถˆ๊ฐ€ํ–ˆ๊ณ , FireFox๋ฅผ ๋‹ค์šด๋ฐ›์•„ ์•„๋ž˜ ์บก์ณ ์‚ฌ์ง„์ฒ˜๋Ÿผ ์œ„ํ—˜์„ ๊ฐ์ˆ˜ํ•˜๊ณ  ์ ‘์†์œผ ๋ˆŒ๋Ÿฌ ๊ฒจ์šฐ ๋“ค์–ด์™”์Šต๋‹ˆ๋‹ค ใ… ใ… ใ…Ž

์ €๋Š” ํ…Œ์ŠคํŠธ ํ˜ธ์ŠคํŠธ๊ฐ€ ๋ชจ๋‘ AWS EC2๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
์™ธ๋ถ€์—์„œ ์ ‘์†ํ•˜๊ธฐ ์œ„ํ•ด์„œ EIP๋ฅผ ํ• ๋‹นํ•˜์—ฌ ์•„๋ž˜์—์„œ์ฒ˜๋Ÿผ ๊ณต์ธIP๋กœ ์ ‘์†ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—ฌ๋Ÿฌ๋ถ„์€ ์—ฌ๋Ÿฌ๋ถ„์˜ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์— ๋งž๋„๋ก ์ ‘์† ํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค!

๊ณ ๊ธ‰์„ ํด๋ฆญํ•œ ํ›„ "์œ„ํ—˜์„ ๊ฐ์ˆ˜ํ•˜๊ณ  ๊ณ„์† ์ง„ํ–‰"์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋Œ€์‹œ๋ณด๋“œ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๊ฐ€ ๋‚˜์™”๋„ค์š”!
์ด์ œ ์—ฌ๊ธฐ์—์„œ ํ† ํฐ์„ ํด๋ฆญํ•˜๊ณ , ์•„๊นŒ ํ™•์ธํ–ˆ๋˜ ํ† ํฐ๊ฐ’์„ ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•ฉ๋‹ˆ๋‹ค :)

๋กœ๊ทธ์ธ์ด ์™„๋ฃŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.!
๋งŒ์•ฝ ๋กœ๊ทธ์ธ ํ›„์— ์•„๋ฌด๊ฒƒ๋„ ๋ณด์ด์ง€ ์•Š๋Š”๋‹ค๋ฉด 10๋ถ„์ •๋„ ์‹œ๊ฐ„ ์ง€๋‚œ ํ›„ ๋กœ๊ทธ์•„์›ƒ ํ›„ ๋‹ค์‹œ ๋กœ๊ทธ์ธ ํ•ด๋ณด์„ธ์š”!

์ด๋ฒˆ๋‹จ๊ณ„๊ฐ€ ๋งˆ๋ฌด๋ฆฌ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค :)

728x90