1、直接 kubectl apply google上面搜索到的一个yaml编排文件
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
2、直接 使用这个编排文件不需要任何配置就可以部署成功,部署完成 后修改service,对外爆露端口才能用浏览器进行访问
---
---
kubectl -n kubernetes-dashboard edit svc kubernetes-dashboard
spec:
clusterIP: 10.0.0.38
externalTrafficPolicy: Cluster
ports:
nodePort: 30220
port: 443
protocol: TCP
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort
---
3、获取token用于在浏览器访问时的验证
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk ‘{print $1}‘)
---
Data
====
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IlNHRWkyUEdUNzJQLVRGWXJUczNUWF8xbEpDUDktLUJ0YjZuUEZ4M2dpc1EifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuZ2lueC1pbmdyZXNzLXNlcnZpY2VhY2NvdW50LXRva2VuLW1iZnM1Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Im5naW54LWluZ3Jlc3Mtc2VydmljZWFjY291bnQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4NGZhNTU5Ni1iMTBjLTQ3YjktODhmMy01YjFhY2EzYTcwOTAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06bmdpbngtaW5ncmVzcy1zZXJ2aWNlYWNjb3VudCJ9.c8uSX7MseuXpk87IVvLnIHiwthUTgh4k9Fivp9Wt2ZwXm3uhemPGiSE6sqI7Yiku4gDCl5z43TAtTnuneoRIpJ6g7olvicy2ta0b8FqIxvs9HX9WbcJUd0uxjjS1nMnM-pbadYY7Zpzd7UT41kKUti0Q5iWxKA_xBsvuLCZdgSDyk-QBWrQYyUswjMePi79LXuKx7qxQe2Kw1tLndBWdB0PJBT46KUyDYgVMsQEyFAufQ66hrdZ4jGXcA9XzLgC5Q4iuZ5380L48YsuppSPQFiJ9T3lCXH28mEKZHaCU-978XLBhy1Pmd52qAwXOhiJNm-_1qED8CufYqdxR2Ancsg
ca.crt: 1354 bytes
namespace: 11 bytes
---
4、使用浏览器进行访问,粘贴上面得到的token