k8s笔记4-Web UI dashboard设置

Web UI设置

cd k8s/soft/kubernetes/
tar zxf kubernetes-src.tar.gz
cd cluster/addons/
cd dashboard/
kubectl create -f dashboard-configmap.yaml
kubectl create -f dashboard-rbac.yaml
kubectl create -f dashboard-secret.yaml
vi dashboard-controller.yaml

*****************
------------------------
      containers:
      - name: kubernetes-dashboard
        image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0
---------------------------
修改为
---------------------------
      containers:
      - name: kubernetes-dashboard
        image: registry.cn-hangzhou.aliyuncs.com/kuberneters/kubernetes-dashboard-amd64:v1.10.1
-----------------------
**********************
kubectl create -f dashboard-controller.yaml

直接在 dev.aliyun.com 中搜索kubernetes-dashboard-amd64,
找到最新版,复制并更改在dashboard-controller.yaml中。

kubectl get pods
kubectl get pods -n kube-system
kubectl logs kubernetes-dashboard-6d9698df7b-wvmcf -n kube-system

在这里插入图片描述

vi dashboard-service.yaml

添加NodePort类型:
type: NodePort
k8s笔记4-Web UI dashboard设置_第1张图片

kubectl create -f dashboard-service.yaml
kubectl get pods -n kube-system

有错误的话可查看日志

kubectl logs kubernetes-dashboard-5f5bfdc89f-jt7k6 -n kube-system

结果如果有HTTPS port: 8443,则说明外部连接https成功。
在这里插入图片描述

kubectl get svc -n kube-system

Note:重新生成dashboard,需要先删除再运行

kubectl delete -f dashboard-controller.yaml
kubectl delete -f dashboard-service.yaml
kubectl create -f dashboard-controller.yaml
kubectl create -f dashboard-service.yaml

k8s笔记4-Web UI dashboard设置_第2张图片
https://Node01:39623/

vi k8s-admin.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: dashboard-admin
  namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: dashboard-admin
subjects:
  - kind: ServiceAccount
    name: dashboard-admin
    namespace: kube-system
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

生成token

kubectl get secret -n kube-system

k8s笔记4-Web UI dashboard设置_第3张图片
token使用即可

kubectl describe secret dashboard-admin-token-cmk9j -n kube-system

k8s笔记4-Web UI dashboard设置_第4张图片
在firefox浏览器中输入任一Node::
k8s笔记4-Web UI dashboard设置_第5张图片

k8s笔记4-Web UI dashboard设置_第6张图片
当出现很多不能访问的waring时,建立如下文件

apiVersion: v1
kind: ServiceAccount
metadata:
  name: aks-dashboard-admin
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: aks-dashboard-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: aks-dashboard-admin
  namespace: kube-system

重新生成secret,如下面第一条
k8s笔记4-Web UI dashboard设置_第7张图片

你可能感兴趣的:(k8s搭建)