Build k8s DashBoard
Cluster structure:
type |
Host name |
IP |
Master |
K8s_master |
192.168.3.216 |
Node |
K8s_client1 |
192.168.3.217 |
Node |
K8s_client2 |
192.168.3.219 |
The following actions are performed on K8s_master:
One, Mirror download
[[Email protected]_master ~]# Docker Pull docker.io/siriuszg/ kubernetes-dashboard-amd64:v1.5.1
Trying to pull repository docker.io/siriuszg/kubernetes-dashboard-amd64 ...
Sha256:d0aebe2567a6b11d090403746f63df9dccd32aec9192decfd3794b0cce528930:Pulling from docker.io/siriuszg/ KUBERNETES-DASHBOARD-AMD64
9d25d3817204:pull Complete
digest:sha256: d0aebe2567a6b11d090403746f63df9dccd32aec9192decfd3794b0cce528930
status:downloaded Newer image for docker.io/ siriuszg/kubernetes-dashboard-amd64:v1.5.1
[Email protected]_master ~]# Docker Pull Registry.access.redhat.com/rhel7/pod-infrastructure
Using default Tag:latest
Trying to Repository Registry.access.redhat.com/rhel7/pod-infrastructure ...
Pulling Repository Registry.access.redhat.com/rhel7/pod-infrastructure
C99574180d51:pull Complete
1ada7c88ed3d:pull Complete
Bcb4a96d0b39:pull Complete
status:downloaded newer image for Registry.access.redhat.com/rhel7/pod-infrastructure:latest
Second, the configuration of Kubernetes Dashboard
1, the following two Kubernetes-dashboard and Dashboard-service configuration files are required.
Kubernetes-dashboard.yaml
#需修改images和增加---apiserver-host=http://192.168.3.216:8080
Kind:deployment
Apiversion:extensions/v1beta1
Metadata
Labels
App:kubernetes-dashboard
Name:kubernetes-dashboard
Namespace:kube-system
Spec
Replicas:1
Revisionhistorylimit:10
Selector
Matchlabels:
App:kubernetes-dashboard
Template
Metadata
Labels
App:kubernetes-dashboard
Comment the following annotation if Dashboard must not being deployed on master
annotations:scheduler.alpha.kubernetes.io/tolerations: | [{"Key": "Dedicated", "operator": "Equal", "Value": "Master", "Effect": "Nosc Hedule "}]spec:containers:-Name:kubernetes-dashboard image:docker.io/siriuszg/kubernetes-dashboard- amd64:v1.5.1 imagepullpolicy:ifnotpresent Ports:-containerport:9090 protocol:tcp args: # Uncomm Ent The following line to manually specify Kubernetes API server Host # If not specified, Dashboard would attempt to a UTO discover the API server and connect # to it. Uncomment only if the default does isn't work. ---apiserver-host=http://192.168.3.216:8080 LivenessProbe:httpGet:path:/port:9090 Initial delayseconds:30 timeoutseconds:30
Dashboard-service.yaml
#不需要做修改
Kind:service
Apiversion:v1
Metadata
Labels
App:kubernetes-dashboard
Name:kubernetes-dashboard
Namespace:kube-system
Spec
Type:nodeport
Ports
- Port:80
targetport:9090
Selector
App:kubernetes-dashboard
2, the implementation of the start, dashboard construction completed.
[Email protected]_master ~]# kubectl create-f Kubernetes-dashboard.yaml
Deployment "Kubernetes-dashboard" created
[Email protected]_master ~]# kubectl create-f Dashboard-service.yaml
Service "Kubernetes-dashboard" created
3. Verification:
Execute the following command
[[Email Protected]_master ~]# kubectl Get Deployment--all-namespaces
NAMESPACE NAME desired current up-to-date AVAILABLE age
Kube-system Kubernetes-dashboard 1 1 1 1 1m
[[Email Protected]_master ~]# Kubectl Get Svc--all-namespaces
NAMESPACE NAME cluster-ip external-ip PORT (S) Age
Default Kubernetes 10.254.0.1 <none> 443/tcp 5d
Kube-system kubernetes-dashboard 10.254.141.158 <nodes> 80:31633/tcp 1m
[[Email Protected]_master ~]# kubectl get pod-o wide--all-namespaces
NAMESPACE NAME Ready STATUS restarts IP NODE
Kube-system kubernetes-dashboard-1270457039-t1z15 1/1 Running 0 2m 10.8.43.2 192.168.3.219
4, interface view, browser input: Http://192.168.3.216:8080/ui
5. Deleting apps
[[Email protected]_master ~]# kubectl Delete deployment Kubernetes-dashboard--namespace=kube-system
Deployment "Kubernetes-dashboard" deleted
[[Email protected]_master ~]# kubectl Delete svc kubernetes-dashboard--namespace=kube-system
Service "Kubernetes-dashboard" deleted
Error Resolution:
1. Unable to pull the mirror registry.access.redhat.com/rhel7/pod-infrastructure:latest
[Email protected]_master ~]# Docker Pull Registry.access.redhat.com/rhel7/pod-infrastructure:latest
Trying to Repository Registry.access.redhat.com/rhel7/pod-infrastructure ...
Open/etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt:no such file or directory
Workaround:
[email protected] ~]# Yum install rhsm -y
2, the browser open UI interface error
{
"Kind": "Status",
"Apiversion": "V1",
"Metadata": {},
"Status": "Failure",
"Message": "No endpoints available for service \" Kubernetes-dashboard\ "",
"Reason": "Serviceunavailable",
"Code": 503
}
Workaround:
Kube_admission_control configuration requires authentication by default, edit config file, Kube_admission_control, remove Securitycontextdeny,serviceaccount
[Email protected]_master ~]# vim/etc/kubernetes/apiserver
Kube_admission_control= "--admission-control=namespacelifecycle,namespaceexists,limitranger,resourcequota"
Restart the service, open normally
Kubernetes Cluster Deployment Dashboard