一、dashboard:简而言之,k8s的页面展示。效果更加直观。
二、安装dashboard
1)github官网地址和版本选择地址
地址:https://github.com/kubernetes/dashboard
版本选择地址:https://github.com/kubernetes/dashboard/tags
说明:一定要选打了√的,完全支持版本
2)下载安装文件
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml
不直接apply是因为,为了加速镜像下载
修改部分为
image: kubernetesui/dashboard:v2.4.0 改成 image: registry.aliyuncs.com/google_containers/dashboard:v2.4.0
image: kubernetesui/metrics-scraper:v1.0.7 改成 image: registry.aliyuncs.com/google_containers/metrics-scraper:v1.0.7
3)执行安装
kubectl apply -f recommended.yaml
4)安装完成后,可以查看服务
5)暴露服务,添加ingress
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: dashboard-ing namespace: kubernetes-dashboard annotations: nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" spec: ingressClassName: "nginx" rules: - host: xbd.dashboard.com http: paths: - path: / pathType: Prefix backend: service: name: kubernetes-dashboard port: number: 443
6)访问:
在hosts里面加入
192.168.5.201 xbd.dashboard.com
通过https访问
这里基本上就安装完成了,接下来主要是登录
三、登录
1)建立账号,kubectl apply -f dashboard-admin.yml
apiVersion: v1 kind: ServiceAccount metadata: labels: k8s-app: kubernetes-dashboard name: dashboard-admin namespace: kubernetes-dashboard --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: dashboard-admin-cluster-role roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: dashboard-admin namespace: kubernetes-dashboard
2)查看token
第一种方式:
1.查询用户 kubectl get sa -n kubernetes-dashboard 2.用户详情 kubectl describe sa dashboard-admin -n kubernetes-dashboard 3.找到token属性对应的secret值 kubectl describe secrets dashboard-admin-token-6qlxd -n kubernetes-dashboard
第二种方式:(快速查看)
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep dashboard-admin | awk '{print $1}')
3)复制token,登录查看
四、到此kubernetes-dashboard就安装完成了。
总结:dashboard的安装不算很复杂,但是需要观察的东西很多,包括使用等。
标签:kubectl,kubernetes,admin,dashboard,k8s,com From: https://www.cnblogs.com/ll409546297/p/16739351.html