Dashboard 1. Download the file of the need to use yaml
wget https://www.cloudelf.cn/kubernetes/kubernetes-dashboard.yaml
Yaml modify this file are:
1) commented Dashboard Secret, otherwise unsafe website displays behind the visit, the certificate expires, we generate their own certificates.
2) Because I chose nodeport access dashboard, so the service type field to nodeport, and specify nodeport 40000, as shown below
# ------------------- Dashboard Secret ------------------- #
将这些都注释掉
#apiVersion: v1
#kind: Secret
#metadata:
# labels:
# k8s-app: kubernetes-dashboard
# name: kubernetes-dashboard-certs
# namespace: kube-system
#type: Opaque
#---
# ------------------- Dashboard Service Account ------------------- #
省略
---
# ------------------- Dashboard Role & Role Binding ------------------- #
省略
---
省略
---
# ------------------- Dashboard Deployment ------------------- #
不用修改,省略
# ------------------- Dashboard Service ------------------- #
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
- port: 443
nodePort: 40000
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
生成pod
kubectl apply -f kubernetes-dashboard.yaml
2, finished build kubernetes will have the following tips when accessing the dashboard through Google browser, this is my own personal trip pit, a search of the major sites, have tried at least a dozen methods, but I did not dare I determined that a hundred percent correct, but true, since much of the middle of the test method.
Since they finished pit times, and then I start to tell you, from the source to solve it,
can successfully open kubernetes UI interface their deployed by Google browser
mkdir key && cd key
#生成证书
openssl genrsa -out dashboard.key 2048
#我这里写的自己的node1节点,因为我是通过nodeport访问的;如果通过apiserver访问,可以写成自己的master节点ip
openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=192.168.135.129'
openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
#删除原有的证书secret
kubectl delete secret kubernetes-dashboard-certs -n kube-system
#创建新的证书secret
kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kube-system
#查看pod
kubectl get pod -n kube-system
#重启pod
kubectl delete pod kubernetes-dashboard-78dc5f9d6b-zgvr6 -n kube-system
POD once again create Dashboard
kubectl the Apply -f Kubernetes-dashboard.yaml
3. Create a user bind
1.创建一个叫admin-user的服务账号:
[root@k8s01 ~]# cat admin-user.yaml
# admin-user.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
[root@k8s01 ~]# kubectl create -f admin-user.yaml
2.直接绑定admin角色:
[root@k8s01 ~]# cat admin-user-role-binding.yaml
# admin-user-role-binding.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
[root@k8s01 ~]# kubectl create -f admin-user-role-binding.yaml
View binding information
4.Heapster is a container cluster monitoring and performance analysis tools (non-essential)
wget https://www.cloudelf.cn/kubernetes/influxdb.yaml
wget https://www.cloudelf.cn/kubernetes/grafana.yaml
wget https://www.cloudelf.cn/kubernetes/heapster.yaml
wget https://www.cloudelf.cn/kubernetes/heapster-rbac.yaml
[root@k8s01 ~] # kubectl create -f influxdb.yaml
[root@k8s01 ~] # kubectl create -f grafana.yaml
[root@k8s01 ~] # kubectl create -f heapster.yaml
[root@k8s01 ~] # kubectl create -f heapster-rbac.yaml
[root@k8s01 ~] # kubectl get pods --namespace=kube-system
NAME READY STATUS RESTARTS AGE
heapster-844d66dcb7-xzhjs 1/1 Running 0 1h
kubernetes-dashboard-78dc5f9d6b-qglnd 1/1 Running 0 2h
monitoring-grafana-555bb9c5c9-597j7 1/1 Running 0 1h
monitoring-influxdb-ddbcd4f99-8lp7z 1/1 Running 0 1h
[root@master yaml]# kubectl cluster-info
Kubernetes master is running at http://localhost:8080
Heapster is running at http://localhost:8080/api/v1/namespaces/kube-system/services/heapster/proxy
monitoring-grafana is running at http://localhost:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
monitoring-influxdb is running at http://localhost:8080/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy
[root@master yaml]# kubectl -n kube-system get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
heapster ClusterIP 10.0.0.206 <none> 80/TCP 3h
kubernetes-dashboard NodePort 10.0.0.30 <none> 443:40000/TCP 1h
monitoring-grafana ClusterIP 10.0.0.152 <none> 80/TCP 3h
monitoring-influxdb ClusterIP 10.0.0.32 <none> 8086/TCP 3h
5. Google browser to access https://192.168.135.129:40000
Login required token acquisition method:
kubectl -n kube-system get secret
The query user token authentication, copy this token
kubectl -n kube-system describe secret admin-user-token-wvlxs
success!
Summary question: If the master node designated nodeport view the port is not it, to see whether the normal running kube-proxy
if the port up, but not even telnet into the port, turn on Route Forwarding