Kubernetes Dashboard(https://github.com/kubernetes/dashboard)是Kubernetes的Web UI管理工具,能夠支持多種K8s運行環境,在Docker for Mac上能夠快速安裝使用(http://www.javashuo.com/article/p-zfwamaum-me.html),但在Ubuntu上有一些區別,這裏是安裝過程的記錄。node
執行下面的命令,安裝flannel網絡驅動(是不一樣pod互訪必須的驅動,可選其它的網絡驅動): git
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
!!!安裝flannel網絡出現pending掛起問題(podCidr參數丟失,即使在kubeadm運行時已指定):github
#查看日誌: kubectl get pods --namespace kube-system kubectl --namespace kube-system logs kube-flannel-ds-bvxd2 #上面的kube-flannel-ds-bvxd2爲flannel的pod名稱,根據get pods返回的名稱輸入。 #編輯 /etc/kubernetes/manifests/kube-controller-manager.yaml 在command節,加入: - --allocate-node-cidrs=true - --cluster-cidr=10.244.0.0/16 而後systemctl restart kubelet便可。
該問題解決辦法的詳細參考:https://github.com/coreos/flannel/issues/728docker
運行下面的命令,安裝Dashboard service pod:api
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
注意:瀏覽器
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.3/src/deploy/recommended/kubernetes-dashboard.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml
查看安裝結果狀況:bash
kubectl get pod --namespaces kube-system
docker pull k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.3
將下面的內容保存爲文件,如dashboard-rbac.yaml。網絡
apiVersion: v1 kind: ServiceAccount metadata: name: dashboard namespace: kube-system --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: dashboard subjects: - kind: ServiceAccount name: dashboard namespace: kube-system roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.io
而後執行安裝(所創建的帳號爲dashboard):app
kubectl create -f dashboard-rbac.yaml
若是建立失敗,可使用kubectl delete sa/podid-xxx --all-namespaces的方式刪除,再從新運行上面的yaml文件進行安裝。工具
kubectl delete sa/dashboard --namespace kube-system kubectl delete clusterrolebindings/dashboard --namespace kube-system
查看帳號是否成功創建:
kubectl get sa --all-namespaces
可使用端口轉發或者kubelet內置的Web服務來提供後臺服務。
kubectl port-forward kubernetes-dashboard-7798c48646-wkgk4 8443:8443 --namespace=kube-system &
kubectl proxy
打開瀏覽器,輸入下面的URL地址,點擊 Sign in
按鈕進入登陸界面。
得到登陸受權的Token,運行:
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep dashboard | awk '{print $1}')
返回結果以下所示:
Name: dashboard-token-kl5ns Namespace: kube-system Labels: <none> Annotations: kubernetes.io/service-account.name=dashboard kubernetes.io/service-account.uid=5832bfe3-219f-11e8-982a-0800275005f0 Type: kubernetes.io/service-account-token Data ==== namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtdG9rZW4ta2w1bnMiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNTgzMmJmZTMtMjE5Zi0xMWU4LTk4MmEtMDgwMDI3NTAwNWYwIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZCJ9.OIo391SDxMDlnzHF0PYbAUNnS_QK9vdbyCx8ZBy3DAdBpBKaKq3U01sPX6H8w_UzP96Mu3Hhh3Xu8ar5nMi5AZLYcct9zR3LepOBdFTQ_YNTJNOjsqMuyD-dWYx6NoQW5lARRtjWSO2UAjrj7Mz4NsfWy8JDUEZZJQ31rtog-Bxgp8K_nxtJiCdROvvd6eM7zNEYOzxYJavsKARyGfJcBRZ6OgxfnH0-8PpwbMEy9qpIQw_sfxVPEaZ-z_y06CX6vbps_-JsFSBDjpVmQQBsNsBxz3Dwm0E8_T9V5z9T13HqUccuGydgp7bYz4PEbDBSD5-xbOIniBwniP3ak1mn_w ca.crt: 1025 bytes
將上面的token內容拷貝下來,而後進入Web界面的 token
,複製到Enter Token下面的編輯框中。
Kubernetes Dashboard運行起來的界面以下,能夠查看信息,管理各類服務。