K8s安装仪表盘-最新简明教程
kubernetes-dashboard,K8s仪表盘
·
1. 创建服务
# 创建dashboard服务
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.0/aio/deploy/recommended.yaml
kubectl apply -f recommended.yaml
# 查看服务,此时的Type为ClusterIP,无法对外提供服务
kubectl get svc -A
查看
recommended.yaml
, 其中已包含了ServiceAccount, ClusterRoleBinding项,即默认的「用户」和「角色」,如需自定义用户角色,可参考kubernetes-dashboard官方文档。
2. 修改端口配置
export KUBE_EDITOR="vim"
kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard
修改如下两处配置项:
apiVersion: v1
kind: Service
metadata:
spec:
clusterIP: 10.104.42.244
clusterIPs:
- 10.104.42.244
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- nodePort: 30001 # 自定义的外部端口(30000+)
port: 443
protocol: TCP
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort # 改为NodePort
status:
loadBalancer: {}
3. 获取令牌
# 先获取token名称,再获取令牌信息
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret|grep admin-user|awk '{print $1}')
4. 浏览器查看
使用上一步获得的token,访问任意集群节点,⚠️ 如:https://10.0.0.11:30001
5. 删除服务
# 用于服务异常或其他原因
kubectl delete service kubernetes-dashboard -n kubernetes-dashboard
参考资料:
更多推荐
已为社区贡献1条内容
所有评论(0)