k8s deployment UI interface deployment

The function of UI page in kubernetes platform

  • K8s Web UI management interface can be better, more intuitive and more convenient for us to manage our k8s cluster.

Experimental deployment

Experimental environment

  • lb01: 192.168.80.19 (load balancing server)
  • lb01: 192.168.80.20 (load balancing server)
  • Master01:192.168.80.12
  • Master01:192.168.80.11
  • Node01:192.168.80.13
  • Node02:192.168.80.14
  • This article continues with the previous multi node deployment and load balancing deployment, and the experimental environment remains the same.

web page deployment

  • To deploy the web page, we need to download the yaml file from GitHub. I have already downloaded it. You can download it directly
  • Official file download Extraction code: tj0d
  • GitHub download address

  • Operate on the master01 server

    [root@master01 ~]# mkdir abc / / create mount directory
    [root@master01 ~]# mount.cifs //192.168.80.2/Shares/K8S/k8s03 /root/abc / / mount the prepared yaml file to the abc directory
    Password for root@//192.168.80.2/Shares/K8S/k8s03:
    [root@master01 ~]# cd abc/
    [root@master01 abc]# ls
    dashboard-configmap.yaml   dashboard-rbac.yaml    dashboard-service.yaml
    dashboard-controller.yaml  dashboard-secret.yaml  k8s-admin.yaml
    [root@master01 abc]# cd /root/k8s/
    [root@master01 k8s]# mkdir dashboard / / create working directory
    [root@master01 dashboard]# cp /root/abc/*.yaml /root/k8s/dashboard / / / copy files to working directory
    [root@master01 dashboard]# ls
    dashboard-configmap.yaml   dashboard-rbac.yaml    dashboard-service.yaml
    dashboard-controller.yaml  dashboard-secret.yaml  k8s-admin.yaml
    [root@master01 dashboard]# kubectl create -f dashboard-rbac.yaml
    role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
    rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
    [root@master01 dashboard]# kubectl create -f dashboard-secret.yaml
    secret/kubernetes-dashboard-certs created
    secret/kubernetes-dashboard-key-holder created
    [root@master01 dashboard]# kubectl create -f dashboard-configmap.yaml
    configmap/kubernetes-dashboard-settings created
    [root@master01 dashboard]# kubectl create -f dashboard-controller.yaml
    serviceaccount/kubernetes-dashboard created
    deployment.apps/kubernetes-dashboard created
    [root@master01 dashboard]# kubectl create -f dashboard-service.yaml
    service/kubernetes-dashboard created
    [root@master01 dashboard]# Kubectl get Pods - n Kube system / / after completion, view and create under the specified Kube system namespace
    NAME                                    READY   STATUS              RESTARTS   AGE
    kubernetes-dashboard-65f974f565-72cs2   0/1     ContainerCreating   0          3m42s
    [root@master01 dashboard]# Kubectl get pods, SVC - n Kube system / / check how to access
    NAME                                        READY   STATUS    RESTARTS   AGE
    pod/kubernetes-dashboard-65f974f565-72cs2   1/1     Running   1          25m
    
    NAME                           TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
    service/kubernetes-dashboard   NodePort   10.0.0.89    <none>        443:30001/TCP   23m
  • Directly access the IP address of the node node in the host
  • When visiting the page, an error will be reported and there will be an unreachable problem. Let's solve this problem
  • Back to master01 server operation

    [root@master01 dashboard]# vim dashboard-cert.sh / / create a certificate file
    cat > dashboard-csr.json <<EOF
    {
    "CN": "Dashboard",
    "hosts": [],
    "key": {
       "algo": "rsa",
       "size": 2048
    },
    "names": [
       {
           "C": "CN",
           "L": "BeiJing",
           "ST": "BeiJing"
       }
    ]
    }
    EOF
    
    K8S_CA=$1
    cfssl gencert -ca=$K8S_CA/ca.pem -ca-key=$K8S_CA/ca-key.pem -config=$K8S_CA/ca-config.json -profile=kubernetes dashboard-csr.json | cfssljson -bare dashboard
    kubectl delete secret kubernetes-dashboard-certs -n kube-system
    kubectl create secret generic kubernetes-dashboard-certs --from-file=./ -n kube-system
    :wq
    [root@master01 dashboard]# Bash dashboard cert.sh / root / k8s / k8s Cert / / / execute script
    2020/02/12 11:51:38 [INFO] generate received request
    2020/02/12 11:51:38 [INFO] received CSR
    2020/02/12 11:51:38 [INFO] generating key: rsa-2048
    2020/02/12 11:51:39 [INFO] encoded CSR
    2020/02/12 11:51:39 [INFO] signed certificate with serial number 681019580324880598304565567389099666263132072953
    2020/02/12 11:51:39 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
    websites. For more information see the Baseline Requirements for the Issuance and Management
    of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
    specifically, section 10.2.3 ("Information Requirements").
    secret "kubernetes-dashboard-certs" deleted
    secret/kubernetes-dashboard-certs created
    [root@master01 dashboard]# vim dashboard-controller.yaml / / edit the yaml file
    ...
    protocol: TCP
        args:
          # PLATFORM-SPECIFIC ARGS HERE
          - --auto-generate-certificates
          - --tls-key-file=dashboard-key.pem
          - --tls-cert-file=dashboard.pem
        volumeMounts:
        - name: kubernetes-dashboard-certs
    ...
    :wq
    [root@master01 dashboard]# Kubectl apply - f dashboard controller.yaml / / redeploy the application
    Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
    serviceaccount/kubernetes-dashboard configured
    Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
    deployment.apps/kubernetes-dashboard configured
  • Visit the web page again after redeploying the app
  • Back to master01 node server operation generate token

    [root@master01 dashboard]# kubectl create -f k8s-admin.yaml / / create token in specified file mode
    serviceaccount/dashboard-admin created
    clusterrolebinding.rbac.authorization.k8s.io/dashboard-admin created
    [root@master01 dashboard]# Kubectl get secret - n Kube system / / save token
    NAME                               TYPE                                  DATA   AGE
    dashboard-admin-token-2slr4        kubernetes.io/service-account-token   3      44s
    default-token-g6klk                kubernetes.io/service-account-token   3      26h
    kubernetes-dashboard-certs         Opaque                                11     124m
    kubernetes-dashboard-key-holder    Opaque                                2      160m
    kubernetes-dashboard-token-42q89   kubernetes.io/service-account-token   3      159m
    [root@master01 dashboard]# Kubectl describe secret dashboard-admin-token-2slr4 - n Kube system / / view the newly saved dashboard-admin-token-2slr4 token file,
    Name:         dashboard-admin-token-2slr4
    Namespace:    kube-system
    Labels:       <none>
    Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 3f7a81ec-4d5c-11ea-8ed9-000c297d4201
    
    Type:  kubernetes.io/service-account-token
    
    Data
    ====
    ca.crt:     1359 bytes
    namespace:  11 bytes
    token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tMnNscjQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiM2Y3YTgxZWMtNGQ1Yy0xMWVhLThlZDktMDAwYzI5N2Q0MjAxIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.db1SgMq37OagIsRiPMgR-zWpneHpzTVGun3Di4VYdVY1XBmmD_DraAGElLal6fm7t5nMVwIqOI3SH2w_0B8iZbHYJUwowMjW6GSSg_W4SP0E4Dfec29MhyIX8NMRRIWqJKRsf9vTj5F5Drjs1PSBAYLOWPibNVp81KzyzvIdHVW_o8x7apYz_uU7GxvvYasEtY5xjJIbzs9BjHfWE2vEPDm04B6Gs9x_dHw89o2izYQwisKpaiqepWyMP6uHj6gZk9ksvzg7bz_t5NpEczJmoZNNjXhkjLyZ8k2Y_3Zl0N5T55i5SPXIae46wt-G-Q7ezuYWJjL5EP-wR7gEuE7IyA
  • Copy token file paste in browser

    Successfully set up Web UI interface

Keywords: Linux Kubernetes JSON github vim

Added by updwebmaster on Thu, 13 Feb 2020 21:28:47 +0200