你們可能都知道k8s默認有個ui界面,可是呢,通常都使用的是1版本的,今天給你們部署的是2版本頁面node
完整部署文件 Github 地址:https://github.com/my-dlq/blog-example/tree/master/kubernetes/kubernetes-dashboard2.0.0-deploylinux
接下來開始部署git
部署一共分5個步驟:
一、建立RBAC
二、建立configmap和secret
三、建立dashboard
四、建立metrics-scraper
五、建立訪問的serviceaccountgithub
我吧文件直接都配好了放到了百度網盤,大家能夠直接下載解壓使用web
連接:https://pan.baidu.com/s/1wdp-zJE6FqpuJdGYgyESmg
提取碼:stzw api
完成以後就能夠經過web頁面訪問了app
這裏使用的是kubeadmin部署的,若是是二進制,須要修改api-server的參數否則沒法支持metrics-server服務的ide
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
rules:ui
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
rules:spa
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: kubernetes-dashboard
subjects:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubernetes-dashboard
subjects:
部署
kubectl apply -f k8s-dashboard-rbac.yaml
kind: ConfigMap
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-settings
namespace: kube-system
EOF
三、部署 Dashboard Config & Secret
kubectl apply -f k8s-dashboard-configmap-secret.yaml
建立 Dashboard Deploy 部署文件
cat >k8s-dashboard-deploy.yaml<<EOF
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-dashboard
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
spec:
containers:
部署 Dashboard Deploy
kubectl apply -f k8s-dashboard-deploy.yaml
四、建立 Dashboard Metrics 部署文件
cat >k8s-dashboard-metrics.yaml<<EOF
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: dashboard-metrics-scraper
name: dashboard-metrics-scraper
namespace: kube-system
spec:
ports:
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: dashboard-metrics-scraper
name: dashboard-metrics-scraper
namespace: kube-system
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: dashboard-metrics-scraper
template:
metadata:
labels:
k8s-app: dashboard-metrics-scraper
annotations:
seccomp.security.alpha.kubernetes.io/pod: 'runtime/default'
spec:
containers:
EOF
部署 Dashboard Metrics
kubectl apply -f k8s-dashboard-metrics.yaml
五、建立 Dashboard ServiceAccount 部署文件
cat > k8s-dashboard-token.yaml<<EOF
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: admin
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
subjects:
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
EOF
部署訪問的 ServiceAccount
kubectl apply -f k8s-dashboard-token.yaml
獲取 Token
kubectl describe secret/$(kubectl get secret -n kube-system |grep admin|awk '{print $1}') -n kube-system
完成以後登錄頁面而後看看
看到了數據
好了2版本的web-ui就完成了有什麼問題能夠私信我哈