CC00088.CloudKubernetes——|KuberNetes&kubeadm.V17|5台Server|——|kubernetes验证|dashboard配置|

一、dashboard配置
1、查看dashboard配置
#1、查看dashboard服务pod

[root@k8s-master01 ~]# kubectl get po -n kubernetes-dashboard -owide
NAME                                         READY   STATUS    RESTARTS   AGE   IP              NODE           NOMINATED NODE   READINESS GATES
dashboard-metrics-scraper-86bb69c5f6-5mbh5   1/1     Running   0          57m   172.169.92.65   k8s-master02   <none>           <none>
kubernetes-dashboard-6576c84894-snkjz        1/1     Running   0          57m   172.162.195.3   k8s-master03   <none>           <none>
#2、查看kubernetes-dashboard.service信息

[root@k8s-master01 ~]# kubectl get svc -n kubernetes-dashboard -owide
NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE    SELECTOR
dashboard-metrics-scraper   ClusterIP   10.105.204.160   <none>        8000/TCP        147m   k8s-app=dashboard-metrics-scraper
kubernetes-dashboard        NodePort    10.103.63.205    <none>        443:32418/TCP   147m   k8s-app=kubernetes-dashboard
#3、更改为NodePort的方式就可以访问到dashboard
//注:NodePort就是在每个宿主机上去启动一个端口,这个端口就可以访问到对应的服务上
[root@k8s-master01 ~]# kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard
   selector:
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: NodePort                  // 默认是NodePort;若不是可更改为NodePort
#4、查看dashboard端口号

[root@k8s-master01 ~]# kubectl get svc -n kubernetes-dashboard -owide
NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE    SELECTOR
dashboard-metrics-scraper   ClusterIP   10.105.204.160   <none>        8000/TCP        150m   k8s-app=dashboard-metrics-scraper
kubernetes-dashboard        NodePort    10.103.63.205    <none>        443:32418/TCP   150m   k8s-app=kubernetes-dashboard
二、通过Chrome访问:https://192.168.1.15:32418/
### --- 通过Chrome访问:https://192.168.1.15:32418/
~~~     查看是否自动创建管理员用户;若是没有需要手动创建管理员用户
~~~     # 查看是否生成管理原用户
~~~     已经创建了管理员用户;若是没有创建;依据以下方案进行手动创建

[root@k8s-master01 ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Name:         admin-user-token-c6vjm
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: admin-user
              kubernetes.io/service-account.uid: fefcaad0-712b-4703-bb9a-37375064dae7

Type:  kubernetes.io/service-account-token

Data
====
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IkdSYmlxZHVVdVdMakNGTC1wT3JBUm5YdGliM3pFMXNMcE55Z09wcmU2czAifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLWM2dmptIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJmZWZjYWFkMC03MTJiLTQ3MDMtYmI5YS0zNzM3NTA2NGRhZTciLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.vI2ohgnmyWDqg0FpTDrywvTgwIB1DtfFHI5hhP_48MU9hSvjWOAyh0HBEDuV7b-yxq7Zc3bfRrvHPqS18geJluCiCGY3X_A-VHoY08X7XqKtzQQeEPdoyU9_slWjODR9TY61bmWpVujzlIUJPrsBk_Z_8uBX0MoRpr4Z2aLf87m6KSvQUM-SgEkTEgVrPnlUBgur-7pR4X_1D_cBDROFQ2B_9Lul_do88a41FsAPgs0nZZ5JliIdwRm7ILs6ABP5hiArRXR366P0XfGk7yUW0B9_7suYgcC4VTtNR79r0QwLQj9LEsA8u9g_ttyP-KzlziwD56xI2MaaD96kiL7tlg
ca.crt:     1066 bytes
### --- 手动创建管理员用户
~~~     # 手动创建管理员用户配置文件

[root@k8s-master01 ~]# vim admin.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding 
metadata: 
  name: admin-user
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system
#1、手动创建管理员用户配置文件
[root@k8s-master01 ~]# vim admin.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding 
metadata: 
  name: admin-user
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system
#2、创建超级管理员用户
[root@k8s-master01 ~]# kubectl create -f admin.yaml -n kube-system
serviceaccount/admin-user created
三、登录dashboard;进入kubernetes-dashboard管理后台
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yanqi_vip

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值