在kubernetes中完成的所有操作都是通过命令行工具kubectl完成的。其实,为了提供更丰富的用户体验,kubernetes还开发了一个基于web的用户界面(Dashboard)。用户可以使用Dashboard部署容器化的应用,还可以监控应用的状态,执行故障排查以及管理kubernetes中各种资源。
#下载
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.1.0/aio/deploy/recommended.yaml
官方的kubernetes-dashboard.yaml文件中service的type类型为clusterIp(service默认类型),这种方式要访问dashboard需要通过代理,所以我们改为NodePort方式,这样部署完后,就可以直接通过
image.png
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort
ports:
- port: 30009
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
kubectl apply -f recommended.yaml
kubectl get pod,svc -n kubernetes-dashboard -o wide
image.png
访问:https://192.168.100.201:32707/#/login
使用创建的用户的token 登录
创建账户,获取token:
#创建账户
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard
#授权
kubectl create clusterrolebinding dashboard-admin-rb --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:dashboard-admin
#获取账号token
kubectl get secrets -n kubernetes-dashboard |grep dashboard-admin
kubectl describe secrets dashboard-admin-token-27s7l -n kubernetes-dashboard
token:
eyJhbGciOiJSUzI1NiIsImtpZCI6IjFHOFZiQ0htSXFOTDVzeW5DUXprZHA5dS1PeERWbTRfeDExTFVpQ2VnX1EifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tMjdzN2wiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiYjY2NTdiMWEtZDE5My00MmM4LWE5NTYtNWRhNTUxYmY4ZmFmIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmVybmV0ZXMtZGFzaGJvYXJkOmRhc2hib2FyZC1hZG1pbiJ9.ntLGXQlqitITjmST19lB9s9SbuwNLNDq6Z-9l6Oh8iv0EoGDVYdYqcUg8HLoNm3OMJTpalYh6MyfGLsIXST44pkjdjBssOcGu1GPVdCrw4QQWcBA9T5o9jndt81mcbxPMpay8tb99Cn-oBnL4YRA8duFhBQmyNwKCBApGVspd1UgQBF2Gmtpwy8PUY2_GZ7-aPDxOcFj1ffcjSMDWVTR5eNgPxNtiAXrEqOxUcDSH0xgKyPNmzpTstrppqXUJ9JUlQzptPhGw44PGb7_n_PaNz6eDG8HO_I982EVzZVM-sQLlCpXuqsOa_vH8P-5y6OB7AvOY1a0qcpB7WTCfsCCug
作者:前浪浪奔浪流
链接:https://www.jianshu.com/p/54e41e73d8a4
相关资源: