The dashboard features are as follows:

1. Can intuitively see the running status and log information of RC, Deployment, POD, Services and other K8S components. 2. After combining heapster and InfluxDB, the CPU and memory consumption of POD can be seen on the dashboard monitoring chart.Copy the code

Deploying Dashboard requires two laborious images note: Normally, you only need to configure the YAML file and do not need to download the image to the node in advance. That is, if the image used in the YAML configuration file does not exist in node, it will be automatically downloaded from the docker source. However, the image we are using now does not have a domestic source, so download it and import it into each node first.

Prepare image: foreign download, domestic import

Core operation: pull down the corresponding image from the overseas server, then save it into a tar package through docker save, send the tar package back to China, perform docker load on each node to import the image (also want to dump on the master).

Image 1:

Dashboard. yaml defines the images used by dashboards: Daocloud. IO/daocloud/google_containers_kubernetes - dashboard - amd64: v1.6.1 version can also choose other note: this download mirror each node # docker pull Daocloud. IO/daocloud/google_containers_kubernetes - dashboard - amd64: v1.6.1Copy the code

Image 2:

Starting k8S 'POD also requires an additional image: Registry.access.redhat.com/rhel7/pod-infrastructure:latest (node, / etc/kubernetes/kubelet configuration), due to some reasons known to all, This image can not be downloaded in ChinaCopy the code

Us server:

# yum install docker -y # yum install docker -y # yum install docker -y # yum install docker -y # yum install docker -y # yum install docker docker pull docker.io/tianyebj/pod-infrastructure # docker save -o podinfrastructure.tar docker.io/tianyebj/pod-infrastructureCopy the code

Local machine node1:

# SCP server IP in the United States: / podinfrastructure. Tar / & emsp; Download it, copy it to all nodes, and import it: # docker images REPOSITORY TAG IMAGE ID CREATED SIZE # docker images REPOSITORY TAG CREATED SIZE Daocloud. IO/daocloud/google_containers_kubernetes - dashboard - amd64 v1.6.1 71 dfe833ce74 10 have a line of 134 MB docker.io/tianyebj/pod-infrastructure latest 34d3450d733b 14 months ago 205 MBCopy the code

Modify the configuration file (for each node) :

# vim /etc/kubernetes/kubelet // KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=docker.io/tianyebj/pod-infrastructure:latest"Copy the code

Restart service (each node is restarted) :

# systemctl  restart kubelet
Copy the code

Edit dashboard.yaml on master:

Yaml apiVersion: Extensions /v1beta1 kind: Deployment metadata: # Keep the name in sync with image version and # gce/coreos/kube-manifests/addons/dashboard counterparts name: kubernetes-dashboard-latest namespace: kube-system spec: replicas: 1 template: metadata: labels: k8s-app: kubernetes-dashboard version: latest kubernetes.io/cluster-service: "true" spec: containers: - name: * * image kubernetes - dashboard: daocloud. IO/daocloud/google_containers_kubernetes - dashboard - amd64: v1.6.1 resources: # keep request = limit to keep this container in guaranteed class limits: cpu: 100m memory: 50Mi requests: cpu: 100m memory: 50Mi ports: - containerPort: 9090 args: * * - - apiserver - host = http://192.168.245.250:8080 # note here because no DNS service deployment, must now write IP livenessProbe: httpGet: path: / port: 9090 initialDelaySeconds: 30 timeoutSeconds: 30Copy the code

Edit the dashboardsvc.yaml file on master

[root@k8s-master /]# vim dashboardSvc. yaml apiVersion: v1 kind: Service metadata: name: kubernetes-dashboard namespace: kube-system labels: k8s-app: kubernetes-dashboard kubernetes.io/cluster-service: "true" spec: selector: k8s-app: kubernetes-dashboard ports: - port: 80 targetPort: 9090Copy the code

Start the

Run the following command on master: # kubectl create -f dashboard.yaml # kubectl create -f dashboardsvc.   The dashboard is set up.Copy the code

validation

To verify the command, run the following command on the master:

[root@k8s-master /]# kubectl get deployment --all-namespaces NAMESPACE NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE kube-system kubernetes-dashboard-latest 1 1 1 1 19s [root@k8s-master /]# kubectl get svc --all-namespaces NAMESPACE NAME Cluster-ip external-ip PORT(S) AGE default kubernetes 10.254.0.1 < None > 443/TCP 4d kube-system kubernetes-dashboard 10.254.231.52 <none> 80/TCP 32s [root@k8s-master /]# kubectl get pod -o wide --all-namespaces NAMESPACE NAME READY RESTARTS for AGE IP NODE kube-system kubernetes-dashboard-latest-1231782504-t79t7 1/1 Running 0 1M 10.0.27.2 k8s-node-2Copy the code

Interface verification, browser access:http://192.168.245.250:8080/ui

Destroy apps (only when you don’t want to use them)

Execute on master:

# kubectl delete deployment kubernetes-dashboard-latest --namespace=kube-system
# kubectl delete svc  kubernetes-dashboard --namespace=kube-system
Copy the code

supplement

The following error occurs when the browser accesses the Dashboard page:

Error: 'dial tcp 172.17.34.2:9090: getsockopt: connection refused'
Trying to reach: 'http://172.17.34.2:9090/'
Copy the code

1. Run the following command for all nodes to reset the Flannel network

[root@k8s-node1 ~]# systemctl daemon-reload
[root@k8s-node1 ~]# systemctl restart flanneld
Copy the code

2. Create the Dashboard application on the master

[root@k8s-master yaml]# kubectl delete deployment kubernetes-dashboard-latest --namespace=kube-system
deployment "kubernetes-dashboard-latest" deleted

[root@k8s-master yaml]# kubectl delete svc  kubernetes-dashboard --namespace=kube-system
service "kubernetes-dashboard" deleted

[root@k8s-master yaml]# kubectl create -f dashboard.yaml
deployment "kubernetes-dashboard-latest" created

[root@k8s-master yaml]#  kubectl create -f dashboardsvc.yaml
service "kubernetes-dashboard" created

[root@k8s-master yaml]# kubectl get deployment --all-namespaces
NAMESPACE     NAME                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
default       mynginx                       2         2         2            2           26d
kube-system   kubernetes-dashboard-latest   1         1         1            1           12s
Copy the code