Kubernetes : ダッシュボードを有効にする2026/08/07 |
|
ダッシュボードを有効にして、Web UI で Kubernetes クラスターの管理ができるようにします。 当例では以下のように 4 台のノードを使用して Kubernetes クラスターを構成しています。
+----------------------+ +----------------------+
| [ ctrl.srv.world ] | | [ dlp.srv.world ] |
| Manager Node | | Control Plane |
+-----------+----------+ +-----------+----------+
eth0|10.0.0.25 eth0|10.0.0.30
| |
------------+--------------------------+-----------
| |
eth0|10.0.0.51 eth0|10.0.0.52
+-----------+----------+ +-----------+----------+
| [ node01.srv.world ] | | [ node02.srv.world ] |
| Worker Node#1 | | Worker Node#2 |
+----------------------+ +----------------------+
|
| [1] | |
| [2] | Headlamp ダッシュボードをインストールします。 |
|
[centos@ctrl ~]$
helm repo add headlamp https://kubernetes-sigs.github.io/headlamp/ "headlamp" has been added to your repositories # ダッシュボード用のネームスペース作成 [centos@ctrl ~]$ kubectl create namespace dashboard namespace/dashboard created helm install headlamp headlamp/headlamp -n dashboard
NAME: headlamp
LAST DEPLOYED: Fri Aug 7 11:37:23 2026
NAMESPACE: dashboard
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace dashboard -l "app.kubernetes.io/name=headlamp,app.kubernetes.io/instance=headlamp" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace dashboard $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace dashboard port-forward $POD_NAME 8080:$CONTAINER_PORT
2. Get the token using
kubectl create token headlamp --namespace dashboard
[centos@ctrl ~]$ kubectl get pods -n dashboard NAME READY STATUS RESTARTS AGE headlamp-df975c6f4-fp4qc 1/1 Running 0 22s |
| [3] | ダッシュボード用のセキュリティトークンを取得して、ダッシュボードにアクセスできるように設定します。 |
|
# headlamp アカウントのセキュリティトークン取得 [centos@ctrl ~]$ kubectl create token headlamp -n dashboard eyJhbGciOiJSUzI1NiIsI..... # ダッシュボードアクセス用にポートフォワードをセット [centos@ctrl ~]$ kubectl port-forward -n dashboard service/headlamp --address 0.0.0.0 8443:80 Forwarding from 0.0.0.0:8443 -> 8443 |
| [4] |
ローカルネットワーク内の任意のコンピューターで Web ブラウザーを起動して、以下の URL にアクセスします。 ⇒ http://(Manager ノードのホスト名 または IP アドレス):(設定したポート)/ アクセス後、以下のような画面が表示されたら、[3] で取得したセキュリティトークンを コピー & ペーストして [Sing In] ボタンをクリックします。 |
|
| [5] | 認証が成功すると Kubernetes クラスターのダッシュボードが表示されます。 |
|
|
|
|
| Sponsored Link |
|
|