下載官方yaml文件 最新的配置文件v2.0.0 beta8版本recommended.yaml, "UI地址" 原文件: 修改為: 原文件內容 修改為: 下載鏡像和啟動 在master節點執行 執行 查看pod和service狀態 如果發現 kubernetes dashboard crashlo ...
下載官方yaml文件
最新的配置文件v2.0.0-beta8版本recommended.yaml,UI地址
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml
原文件:
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
ports:
- port: 443
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
修改為:
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort #新增
ports:
- port: 443
nodePort: 30001 #新增
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
原文件內容
spec:
containers:
- name: kubernetes-dashboard
image: kubernetesui/dashboard:v2.0.0-beta8
imagePullPolicy: Always
ports:
- containerPort: 8443
protocol: TCP
修改為:
spec:
# nodeName: master.node 指定到master節點,指不指定根據需要
containers:
- name: kubernetes-dashboard
image: kubernetesui/dashboard:v2.0.0-beta8
# imagePullPolicy: Always
imagePullPolicy: IfNotPresent #不存在再下載
ports:
- containerPort: 8443
protocol: TCP
下載鏡像和啟動
在master節點執行
docker pull kubernetesui/dashboard:v2.0.0-beta8
執行
kubectl apply -f recommended.yaml
查看pod和service狀態
kubectl get pods,svc -n kubernetes-dashboard -o wide
kubectl describe po kubernetes-dashboard --namespace=kubernetes-dashboard
如果發現
kubernetes-dashboard crashloopbackoff
kubectl get pods --all-namespaces
systemctl stop kubelet
systemctl stop docker
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start docker
kubectl delete -f recommended.yaml
列出所有nodes: kubectl get node
刪除節點:kubectl delete node node3
查看對應node上的pods信息: kubectl get pods -o wide | grep node3
重新加入
在刪除的node3對應的伺服器上執行:kubeadm reset
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -L -n
mkdir cert
cd cert/
openssl genrsa -out dashboard.key 2048
openssl req -days 36000 -new -out dashboard.csr -key dashboard.key -subj '/CN=**192.168.56.106**'
openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
新建create-admin.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
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
運行
kubectl apply -f create-admin.yaml
查看sa和secret
kubectl get sa,secrets -n kubernetes-dashboard
kubectl describe secret admin-user-token-t79xh -n kubernetes-dashboard
獲取token登錄成功:
本文由博客一文多發平臺 OpenWrite 發佈!