原创

k8s安装笔记-部署Dashboard

温馨提示:
本文最后更新于 2024年05月21日 ,已超过 348 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

默认情况下不会部署Dashboard,需要我们手工安装

curl -OL https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

# 执行部署
kubectl apply -f recommended.yaml

kubectl edit -n kubernetes-dashboard services kuberneters-dashboard

## type ClusterIP --> NodePort

# kubectl get service -n kubernetes-dashboard -o wide # 默认情况下是开放的 443CLusterIp的方式,我们要修改成功
NAME                        TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)         AGE   SELECTOR
dashboard-metrics-scraper   ClusterIP   10.1.166.64   <none>        8000/TCP        91m   k8s-app=dashboard-metrics-scraper
kubernetes-dashboard        NodePort    10.1.88.31    <none>        443:31300/TCP   91m   k8s-app=kubernetes-dashboard

访问地址

# 获取登录的token 
kubectl -n kubernetes-dashboard create token admin-user
# 登录访问节点
https://IP:31300/

# 访问用户使用下面的步骤操作。 需要使用token 进行登录

Creating a Service Account

We are creating Service Account with the name admin-user in namespace kubernetes-dashboard first.

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard

Creating a ClusterRoleBinding

In most cases after provisioning the cluster using kops, kubeadm or any other popular tool, the ClusterRole cluster-admin already exists in the cluster. We can use it and create only a ClusterRoleBinding for our ServiceAccount. If it does not exist then you need to create this role first and grant required privileges manually.

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

Getting a Bearer Token

Now we need to find the token we can use to log in. Execute the following command:

kubectl -n kubernetes-dashboard create token admin-user

## 访问地址
https://IP:31300/
正文到此结束
本文目录