kubernetes dashboard安装
nginx集群部署
[root@huangzhenhua bin]# ./kubectl run nginx --image=nginx--port=8000 --replicas=2
deployment "nginx" created
[root@huangzhenhua bin]# ./kubectl create -f ./nginx-service.yaml
service "nginx" created
查看nginx集群状态
[root@huangzhenhua bin]# ./kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-824979794-kqhm4 0/1 ContainerCreating 0 18s
nginx-824979794-lp3h1 0/1 ContainerCreating 0 18s
查看具体原因:ContainerCreating镜像下载失败,由于国外镜像无法下载
[root@huangzhenhua bin]#./kubectl describe pod nginx
删除nginx集群
[root@huangzhenhua bin]#./kubectl delete -f ./nginx-service.yaml
从阿里云国内地址下载pause镜像
[root@huangzhenhua bin]#docker pullregistry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0
[root@huangzhenhua bin]#docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0gcr.io/google_containers/pause-amd64:3.0
设置nginx pause本地镜像路径,重新部署
[root@huangzhenhua bin]# ./kubectl run nginx--image=gcr.io/google_containers/pause-amd64:3.0 --port=8000 --replicas=2
deployment "nginx" created
[root@huangzhenhua bin]# ./kubectl create -f ./nginx-service.yaml
service "nginx" created
查看nginx集群pod状态:Running为成功状态
[root@huangzhenhua bin]# ./kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-1034722000-50gmc 1/1 Running 0 19s
nginx-1034722000-b6qf9 1/1 Running 0 19s
查看nginx集群services状态
[root@huangzhenhua bin]# ./kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.10.10.1
nginx 10.10.10.147
kubernetes-dashboard正式部署
下载kube-dashboard.yaml模板
[root@huangzhenhua bin]# wgethttp://docs.minunix.com/docker/kubernetes-dashboard.yaml -O./kube-dashboard.yaml
修改kube-dashboard.yaml模板,设置api-server地址
[root@huangzhenhua bin]# vi kube-dashboard.yaml
- --apiserver-host=http://192.169.21.128:8080
部署kubernetes-dashboard
[root@huangzhenhua bin]# ./kubectl create -f kube-dashboard.yaml
查看kubernetes-dashboard部署状态
[root@huangzhenhua bin]# ./kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default nginx-1034722000-dptdw 1/1 Running 0 28m
default nginx-1034722000-l08b6 1/1 Running 0 28m
kube-system kubernetes-dashboard-2245610742-dv97j 0/1 ImagePullBackOff 0 5m
查看详细错误日志:状态为ContainerCreating或者ImagePullBackOff,从国外下载kubernetes-dashboard镜像失败
[root@huangzhenhua bin]# ./kubectl describe --namespace=kube-system pokubernetes-dashboard-2245610742-dv97j
从阿里云国内地址下载kubernetes-dashboard镜像
[root@huangzhenhua bin]# docker pullregistry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.0
[root@huangzhenhua bin]# docker tagregistry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.0gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1
修改kube-dashboard.yaml模板,设置从本地镜像安装
[root@huangzhenhua bin]# vi kube-dashboard.yaml
image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1 #使用本地镜像
imagePullPolicy: Never #使用本地镜像
删除kube-dashboard部署配置
[root@huangzhenhua bin]# ./kubectl delete -f kube-dashboard.yaml
deployment "kubernetes-dashboard" deleted
service "kubernetes-dashboard" deleted
重新部署kubernetes-dashboard
[root@huangzhenhua bin]# ./kubectl create -f kube-dashboard.yaml
deployment "kubernetes-dashboard" created
service "kubernetes-dashboard" created
查看kubernetes-dashboard部署状态
[root@huangzhenhua bin]# ./kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default nginx-1034722000-dptdw 1/1 Running 0 33m
default nginx-1034722000-l08b6 1/1 Running 0 33m
kube-system kubernetes-dashboard-2752587873-bdmjv 1/1 Running 0 11s
查看kubernetes-dashboard部署日志
[root@huangzhenhua bin]# ./kubectl logs -fkubernetes-dashboard-2752587873-bdmjv --namespace=kube-system
Using HTTP port: 9090
Using apiserver-host location: http://192.169.21.128:8080
Creating API server client for http://192.169.21.128:8080
Successful initial request to the apiserver, version: v1.7.15
Creating in-cluster Heapster client
访问kubernetes-dashboard
http://192.169.21.128:8080/ui