k8s安装dashboard

2021-04-28 14:32:27 浏览数 (2)

1.下载dashboard的yaml文件,并查看对应的镜像信息

代码语言:javascript复制
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

2.由于基本都没翻墙环境,使用docker的镜像源获取该镜像

代码语言:javascript复制
docker search kubernetes-dashboard-amd64:v1.10.0
docker pull docker.io/mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.0
docker tag docker.io/mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.0 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0

3.根据yaml文件创建dashboard

代码语言:javascript复制
kubectl apply -f kubernetes-dashboard.yaml 

4.设置访问代理

代码语言:javascript复制
kubectl proxy --address=0.0.0.0 --disable-filter=true &

5.访问地址

代码语言:javascript复制
http://kubernetes-master:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default

6.生成访问token

代码语言:javascript复制
cat <<EOF >  ./kubernetes-dashboard-admin.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-dashboard
  labels:
    k8s-app: kubernetes-dashboard
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: kubernetes-dashboard
  namespace: kube-system

EOF

kubectl apply -f kubernetes-dashboard-admin.yaml
kubectl -n kube-system get secret | grep kubernetes-dashboard-token
获取到kubernetes-dashboard-token-g7w88
kubectl describe -n kube-system secret/kubernetes-dashboard-token-g7w88

0 人点赞