Kubernetes集群管理 --3Kubernetes集群部署Dashboard应用

1. 确定Kubernetes集群正常运行

通过确定kubenetes集群处于正常运行状态。

$ kubectl get pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-fb8b8dccf-mpczg            0/1     Running   0          2m31s
coredns-fb8b8dccf-v9vzl            0/1     Running   0          2m31s
etcd-ubuntu00                      1/1     Running   0          86s
kube-apiserver-ubuntu00            1/1     Running   0          93s
kube-controller-manager-ubuntu00   1/1     Running   0          100s
kube-flannel-ds-amd64-k78lf        1/1     Running   0          21s
kube-proxy-c8kfl                   1/1     Running   0          2m31s
kube-scheduler-ubuntu00            1/1     Running   0          112s


2. 部署Dashboard应用

Dashboard应用的具体配置信息,包括镜像,冗余备份数等,写在https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml配置文件中。我们可以通过kubectl apply -f命令部署该配置文件。

$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
podsecuritypolicy.extensions/psp.flannel.unprivileged created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.extensions/kube-flannel-ds-amd64 created
daemonset.extensions/kube-flannel-ds-arm64 created
daemonset.extensions/kube-flannel-ds-arm created
daemonset.extensions/kube-flannel-ds-ppc64le created
daemonset.extensions/kube-flannel-ds-s390x created


3. 访问Dashboard

3.1. 启动Kubernetes Proxy

通过kubectl proxy命令启动代理服务器。注意:服务器处于运行过程,不要关闭中断。

$ kubectl proxy
Starting to serve on 127.0.0.1:8001

3.2. 浏览器访问应用

进入Kubernetes中的Master节点。打开火狐浏览器。在浏览器中输入命令如下。

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

选择"Token"
Kubernetes集群管理 --3Kubernetes集群部署Dashboard应用_第1张图片

3.3. 获取Dashboard访问Token

另外打开一个新的终端,查看Dashboard的Token (credits and special thanks to VincentFF)。

$ kubectl -n kube-system describe $(kubectl -n kube-system get secret -n kube-system -o name | grep namespace) | grep token
Name:         kubernetes-dashboard-token-gn5qq
Namespace:    kube-system
Labels:       
Annotations:  kubernetes.io/service-account.name: kubernetes-dashboard
              kubernetes.io/service-account.uid: eba09c33-7619-11e9-8ae0-c85b76e10a11

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1025 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi1nbjVxcSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImViYTA5YzMzLTc2MTktMTFlOS04YWUwLWM4NWI3NmUxMGExMSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.Lg_VY6sVJsVBZN_GNMfxWkVhNZRw5zkd6MmlTFIdBg0jpEOwZgOgSzcYmXYJfkqt8Loj3_sHCgiXNk6XxQDWpO36udk6PcgqdhnHZyq5Uf2TxsmMCvfkRw_b4cKgfH36YBI6tdjG_92fK7YgHJn5B3Z3lDJ0tvjSbTd53LvZsoMNxTa1ds_tNNC4OIntSHKsWym2ta4Rz8W7gNSRTunyj2-dqoeXqz9vLUHhw0Jmlb-rLJuw2qQPtjIIm1II1BtAP3oxbZfqG6eUtHV_nbe23atkl-t7XbnuJD1roJ7v3X6ASO6hyK0CrOLtIBHTzda7j86Wd7F8So2d5eCvac7Ivg
joe@ubuntu00:~$ kubectl -n kube-system describe $(kubectl -n kube-system get secret -n kube-system -o name | grep namespace) | grep token
Name:         namespace-controller-token-bffhm
Type:  kubernetes.io/service-account-token
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlci10b2tlbi1iZmZobSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjQ0MmY2MDVlLTc2MTktMTFlOS04YWUwLWM4NWI3NmUxMGExMSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTpuYW1lc3BhY2UtY29udHJvbGxlciJ9.OXMN34Dga6iD17KD6TM5Qk0tu3oEFiVUVD_oJhsSoMOYH6797osgeHohL6kiXW8PxtqxIa3YHLm13e3P7JfBsnnOxBoUuWETPsa8Xio_NkT0gACLW1QdXNg3tUA_wp3Kz-0oTIxLZ2i99yl-DbM-UvSRhtfcKCQoO8LQPW6IPTEOQf2kCFpsWIfoYFG5dTc0FgQhcOP_OGVqY0fQqU9zszXLSRyePV3KoBvgHQ2sryEzU4H_skpmQMU8VsUFOzxQELu6cAEa1hCknrVmg9lHN_gMPVo3cH6bciXNZOXebk52rPwoeMql021zv3EGYu2FzgDvM9V7X2eAivNZh_RA8w

成功获得Dashboard应用的访问Token。


3.4. 访问Token输入到浏览器

将上述Token字符串,即
eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlci10b2tlbi1iZmZobSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjQ0MmY2MDVlLTc2MTktMTFlOS04YWUwLWM4NWI3NmUxMGExMSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTpuYW1lc3BhY2UtY29udHJvbGxlciJ9.OXMN34Dga6iD17KD6TM5Qk0tu3oEFiVUVD_oJhsSoMOYH6797osgeHohL6kiXW8PxtqxIa3YHLm13e3P7JfBsnnOxBoUuWETPsa8Xio_NkT0gACLW1QdXNg3tUA_wp3Kz-0oTIxLZ2i99yl-DbM-UvSRhtfcKCQoO8LQPW6IPTEOQf2kCFpsWIfoYFG5dTc0FgQhcOP_OGVqY0fQqU9zszXLSRyePV3KoBvgHQ2sryEzU4H_skpmQMU8VsUFOzxQELu6cAEa1hCknrVmg9lHN_gMPVo3cH6bciXNZOXebk52rPwoeMql021zv3EGYu2FzgDvM9V7X2eAivNZh_RA8w
复制粘贴到浏览器的输入窗口,点击登录。
Kubernetes集群管理 --3Kubernetes集群部署Dashboard应用_第2张图片

获得Dashboard资源管理界面信息如下。
Kubernetes集群管理 --3Kubernetes集群部署Dashboard应用_第3张图片



参考文献

[1. Dashboard部署] https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
[2. Dashboard访问Token获取] https://segmentfault.com/a/1190000013681047

你可能感兴趣的:(分布式集群,分布式集群)