k8s部署Web UI界面(dashboard)

1,下载kubernetes-dashboard.yaml

 wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

在这里插入图片描述

2,编辑kubernetes-dashboard.yaml

[root@master ~]# vi kubernetes-dashboard.yaml 

k8s部署Web UI界面(dashboard)_第1张图片
k8s部署Web UI界面(dashboard)_第2张图片

# ------------------- Dashboard Deployment ------------------- #

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: kubernetes-dashboard
  template:
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
    spec:
      containers:
      - name: kubernetes-dashboard
        image: lizhenliang/kubernetes-dashboard-amd64:v1.10.1
        ....

# ------------------- Dashboard Service ------------------- #

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort

3,启动kubernetes-dashboard.yaml 文件,并查看状态

[root@master ~]# kubectl apply -f kubernetes-dashboard.yaml 
[root@master ~]# kubectl get pods -n kube-system
NAME                                READY   STATUS    RESTARTS   AGE
coredns-5c98db65d4-77hpt            1/1     Running   8          2d5h
coredns-5c98db65d4-9ftmb            1/1     Running   10         2d5h
etcd-master                         1/1     Running   6          2d5h
kube-apiserver-master               1/1     Running   6          2d5h
kube-controller-manager-master      1/1     Running   6          2d5h
kube-flannel-ds-amd64-6hmdd         1/1     Running   3          2d2h
kube-flannel-ds-amd64-bb5rd         1/1     Running   1          2d2h
kube-flannel-ds-amd64-jhxsq         1/1     Running   2          2d2h
kube-flannel-ds-amd64-k7jpv         1/1     Running   7          2d5h
kube-proxy-7whp6                    1/1     Running   3          2d2h
kube-proxy-8rjkb                    1/1     Running   2          2d2h
kube-proxy-r76s5                    1/1     Running   1          2d2h
kube-proxy-rvr56                    1/1     Running   7          2d5h
kube-scheduler-master               1/1     Running   7          2d5h
kubernetes-dashboard-79ddd5-5hprt   1/1     Running   0          40m
查看详细信息:
[root@master ~]# kubectl get pods -n kube-system -o wide
NAME                                READY   STATUS    RESTARTS   AGE    IP                NODE     NOMINATED NODE   READINESS GATES
coredns-5c98db65d4-77hpt            1/1     Running   8          2d5h   10.244.0.16       master              
coredns-5c98db65d4-9ftmb            1/1     Running   10         2d5h   10.244.0.15       master              
etcd-master                         1/1     Running   6          2d5h   192.168.200.129   master              
kube-apiserver-master               1/1     Running   6          2d5h   192.168.200.129   master              
kube-controller-manager-master      1/1     Running   6          2d5h   192.168.200.129   master              
kube-flannel-ds-amd64-6hmdd         1/1     Running   3          2d2h   192.168.200.131   node02              
kube-flannel-ds-amd64-bb5rd         1/1     Running   1          2d2h   192.168.200.130   node01              
kube-flannel-ds-amd64-jhxsq         1/1     Running   2          2d2h   192.168.200.132   node03              
kube-flannel-ds-amd64-k7jpv         1/1     Running   7          2d5h   192.168.200.129   master              
kube-proxy-7whp6                    1/1     Running   3          2d2h   192.168.200.131   node02              
kube-proxy-8rjkb                    1/1     Running   2          2d2h   192.168.200.132   node03              
kube-proxy-r76s5                    1/1     Running   1          2d2h   192.168.200.130   node01              
kube-proxy-rvr56                    1/1     Running   7          2d5h   192.168.200.129   master              
kube-scheduler-master               1/1     Running   7          2d5h   192.168.200.129   master              
kubernetes-dashboard-79ddd5-5hprt   1/1     Running   0          40m    10.244.0.17       master              
查询端口号:
kubectl get svc -n kube-system -o wide
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE    SELECTOR
kube-dns               ClusterIP   10.96.0.10               53/UDP,53/TCP,9153/TCP   2d5h   k8s-app=kube-dns
kubernetes-dashboard   NodePort    10.103.174.152           443:31061/TCP            41m    k8s-app=kubernetes-dashboard

在这里插入图片描述
通过浏览器访问:
k8s部署Web UI界面(dashboard)_第3张图片

4,生成令牌

[root@master ~]# kubectl create serviceaccount dashboard-admin -n kube-system
[root@master ~]# kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
[root@master ~]#  kubectl get secret -n kube-system
NAME                                             TYPE                                  DATA   AGE
attachdetach-controller-token-gvf8m              kubernetes.io/service-account-token   3      2d5h
bootstrap-signer-token-l788b                     kubernetes.io/service-account-token   3      2d5h
certificate-controller-token-slcml               kubernetes.io/service-account-token   3      2d5h
clusterrole-aggregation-controller-token-sq5lq   kubernetes.io/service-account-token   3      2d5h
coredns-token-g874c                              kubernetes.io/service-account-token   3      2d5h
cronjob-controller-token-67mgj                   kubernetes.io/service-account-token   3      2d5h
daemon-set-controller-token-vb9ls                kubernetes.io/service-account-token   3      2d5h
dashboard-admin-token-968gs                      kubernetes.io/service-account-token   3      15m

k8s部署Web UI界面(dashboard)_第4张图片
生成令牌:

[root@master ~]# kubectl describe secret dashboard-admin-token-968gs -n kube-system
Name:         dashboard-admin-token-968gs
Namespace:    kube-system
Labels:       
Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 251f6434-7bb4-43d0-b601-eff14b22ecd1

Type:  kubernetes.io/service-account-token

Data
====
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tOTY4Z3MiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiMjUxZjY0MzQtN2JiNC00M2QwLWI2MDEtZWZmMTRiMjJlY2QxIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.lwoiB42d_JBkTf-UE3_Mc7ZiWZkjjjycg-_11F1aNXLPJDlwV85dra-Azr9CUVHoeadN90CUMRw0BwNPSA7fMoUg7OHBV1i97CiMzqF-jSiYiH567ERD7coFNReWv6olLJhzq60rhQFH8GrQ6ekWQ6-W4XNc_oCk-NfyjVOhxsdtt7vfyGqUgkolvK7C_iSnn1fJWQK4whC9gN_v822byePFUkUUSkzErqlT_1UE__glrndf4vYYoXAYWU2E64cwkxQ32X3OU7wI3g9eRhGaFBBnAQIJ9AOlRGoRMeqsDiPdhffvVZlm6lNG4z-f4-R_JczSFMn_QEJ9Ou8_vbnC9w
ca.crt:     1025 bytes
[root@master ~]# 

k8s部署Web UI界面(dashboard)_第5张图片
复制令牌到浏览器中:
k8s部署Web UI界面(dashboard)_第6张图片
k8s部署Web UI界面(dashboard)_第7张图片

你可能感兴趣的:(dashboard)