参考链接:https://cloud.tencent.com/developer/article/1487532

拉取镜像

docker pull registry.cn-hangzhou.aliyuncs.com/rsqlh/kubernetes-dashboard:v1.10.1
docker tag registry.cn-hangzhou.aliyuncs.com/rsqlh/kubernetes-dashboard:v1.10.1 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1

生成yml,映射端口

wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
sed -i '/targetPort:/a\ \ \ \ \ \ nodePort: 32500\n\ \ type: NodePort' kubernetes-dashboard.yaml

yaml运行等命令

  1. 安装服务
    kubectl create -f kubernetes-dashboard.yaml
  2. 删除服务
    kubectl delete -f kubernetes-dashboard.yaml
  3. 查看服务
    kubectl get pods -n kube-system
  4. 其他命令
    kubectl get service --namespace=kube-system
    kubectl describe service kubernetes-dashboard --namespace=kube-system
    kubectl get pods --namespace=kube-system -o wide
  5. 访问https:/masterNodeIP:32500/

token令牌认证

  1. kubectl create serviceaccount dashboard-admin -n kube-system

  2. 把serviceaccount绑定在clusteradmin,授权serviceaccount用户具有整个集群的访问管理权限
    kubectl create clusterrolebinding dashboard-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin

  3. 获取serviceaccount的secret信息,可得到token(令牌)的信息
    kubectl get secret -n kube-system
    #dashboard-admin-token-slfcr 通过上边命令获取到的

  4. kubectl describe secret dashboard-admin-token-slfcr -n kube-system

  5. 快速查看token
    kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk ‘/admin/{print $1}’)

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐