一看必会系列:k8s 练习23 多master高用集群1.14.1增加dashboard 1.10.1

No Comments Kubernetes

 

1.安装 kubernetes-dashboard

Images 列表,按前几章的方式进行获取
k8s.gcr.io/kubernetes-dashboard-arm64:v1.10.1
k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
k8s.gcr.io/kubernetes-dashboard-ppc64le:v1.10.1
k8s.gcr.io/kubernetes-dashboard-arm:v1.10.1
k8s.gcr.io/kubernetes-dashboard-s390x:v1.10.1

先下载 再apply
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

修改配置,这样就可以直接访问,本文提供对应行数

149 # ——————- Dashboard Service ——————- #
150
151 kind: Service
152 apiVersion: v1
153 metadata:
154   labels:
155     k8s-app: kubernetes-dashboard
156   name: kubernetes-dashboard
157   namespace: kube-system
158 spec:
159   type: NodePort #加
160   ports:
161     – port: 443
162       targetPort: 8443
163       nodePort: 30001 #加,提供对外访问

随便在哪个master上执行
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

kubectl apply -f kubernetes-dashboard.yaml
过程
secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created

 

随便在哪个master上执行查看,确认 kube-dashboard 运行在哪个node
#这里运行在node1上面
[root@host0 script]# kubectl get pod -n kube-system -o wide |grep dash
kubernetes-dashboard-5694f87d87-8295d      1/1     Running   0          5m22s   10.168.36.72    k8s-node1   <none>           <none>
[root@host0 script]#

------中间广告---------

2,登陆 kube-dashboard

#创建管理用户
admin-user.yaml 此内容不用改直接复制
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    k8s-app: kubernetes-dashboard  #要管理的app和 上面155行配置一致
  name: admin
  namespace: kube-system

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
– kind: ServiceAccount
  name: admin
  namespace: kube-system

 

[root@host0 script]# vim admin-user.yaml
[root@host0 script]# kubectl apply -f admin-user.yaml   #执行
serviceaccount/admin created
clusterrolebinding.rbac.authorization.k8s.io/admin created
[root@host0 script]# kubectl describe serviceaccount admin -n kube-system
Name:                admin
Namespace:           kube-system
Mountable secrets:   admin-token-8z8rt
Tokens:              admin-token-8z8rt
—–略–下面就是登陆token
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi10b2tlbi04ejhydCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJhZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjVhZDVkMTU5LTYxMDItMTFlOS1hNDFhLTAwNTA1Njk2NDJiOCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTphZG1pbiJ9.LotrTsWwExcOJ3WZcEIke9LeWI-XqHV89VaLi_LJ69qOe9UuTxrQpnQ3owcZ1Y7Q0OLOHi90o4sa2y89gzzPSRI2_jT3FWPERFyWEb0hn-9cFmTDLfURboUiWDJbTL4p2z5ul990eFdIPpzyigQGbq7TFdNSUVr9YaeuHHKAr5zvzjjpsTEyXJgGP1bxido-kPnl58lYT9Qvbwt58kIh7f85uICls6Xfc16Qj2GWpjlJl4_M4P_9RVeKzFI_H3dnaloOPLkHIgjyA445qltmKvrlfT8_Fn7aRe5IIC117PcN1dYGaqBC93VTaMa2wAaeuK-OObqM31FVcBz8YJsWJw
[root@host0 script]#

3.打开页面登陆    https://node1 IP:nodePort

https://192.168.10.69:30001/#!/overview?namespace=default

成功

 

image

————知识扩殿
https://github.com/kubernetes/dashboard/wiki/Installation
https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard—1.7.X-and-above

发表评论