Kubernetes : ダッシュボードを有効にする2024/11/06 |
|
ダッシュボードを有効にして、Web UI で Kubernetes クラスターの管理ができるようにします。 当例では以下のような Kubernetes クラスター環境で設定します。
-----------+---------------------------+--------------------------+------------
| | |
eth0|10.0.0.30 eth0|10.0.0.51 eth0|10.0.0.52
+----------+-----------+ +-----------+----------+ +-----------+----------+
| [ dlp.srv.world ] | | [ node01.srv.world ] | | [ node02.srv.world ] |
| Control Plane | | Worker Node | | Worker Node |
+----------------------+ +----------------------+ +----------------------+
|
| [1] | Control Plane ノードでダッシュボードを有効にします。 |
|
[root@dlp ~]#
[root@dlp ~]# dnf -y install helm helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ "kubernetes-dashboard" has been added to your repositories [root@dlp ~]# helm install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
NAME: kubernetes-dashboard
LAST DEPLOYED: Wed Nov 6 11:11:15 2024
NAMESPACE: kubernetes-dashboard
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
*************************************************************************************************
*** PLEASE BE PATIENT: Kubernetes Dashboard may need a few minutes to get up and become ready ***
*************************************************************************************************
Congratulations! You have just installed Kubernetes Dashboard in your cluster.
To access Dashboard run:
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443
NOTE: In case port-forward command does not work, make sure that kong service name is correct.
Check the services in Kubernetes Dashboard namespace using:
kubectl -n kubernetes-dashboard get svc
Dashboard will be available at:
https://localhost:8443
[root@dlp ~]# kubectl get pods -n kubernetes-dashboard NAME READY STATUS RESTARTS AGE kubernetes-dashboard-api-74d899fc87-ltcpz 1/1 Running 0 28s kubernetes-dashboard-auth-57898dc475-8q4zs 1/1 Running 0 28s kubernetes-dashboard-kong-75bb76dd5f-9xbnx 1/1 Running 0 28s kubernetes-dashboard-metrics-scraper-5f645f778c-wb6g8 1/1 Running 0 28s kubernetes-dashboard-web-5bf7668478-9wmrd 1/1 Running 0 28s |
| [2] | ダッシュボード用のアカウントを追加して、ダッシュボードにアクセスできるように設定します。 |
|
[root@dlp ~]#
kubectl create serviceaccount -n kubernetes-dashboard admin-user serviceaccount/admin-user created
[root@dlp ~]#
vi rbac.yml # 新規作成 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
[root@dlp ~]#
kubectl apply -f rbac.yml clusterrolebinding.rbac.authorization.k8s.io/admin-user created # 追加したアカウントのセキュリティトークン取得 [root@dlp ~]# kubectl -n kubernetes-dashboard create token admin-user eyJhbGciOiJSUzI1Ni..... # ダッシュボードアクセス用にポートフォワードをセット [root@dlp ~]# kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard --address 0.0.0.0 8443:443 Forwarding from 0.0.0.0:8443 -> 8443 |
| [3] |
ローカルネットワーク内の任意のコンピューターで Web ブラウザーを起動して、以下の URL にアクセスします。
⇒ https://(Control Plane ノードのホスト名 または IP アドレス):(設定したポート)/
アクセス後、以下のような画面が表示されたら、[2] で取得したセキュリティトークンを コピー & ペーストして [Sing In]
ボタンをクリックします。
|
|
| [4] | 認証が成功すると Kubernetes クラスターのダッシュボードが表示されます。 |
|
|
| Sponsored Link |
|
|