nwcdheap / kops-cn

AWS中国宁夏区域/北京区域,快速Kops部署K8S集群
Apache License 2.0
121 stars 74 forks source link

install kubernetes-dashboard #95

Closed liangruibupt closed 5 years ago

liangruibupt commented 5 years ago

Problem description

If you directly use the official command, the default image registry will be k8s.gcr.io, you have to through http proxy.

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

otherwise, you will encounter error

[ec2-user@ip-172-16-180-167 kops-cn-master]$ kubectl -n kube-system get pod | grep kubernetes-dashboard
kubernetes-dashboard-65c76f6c97-d8x77                                   0/1     ImagePullBackOff   0          3m56s

[ec2-user@ip-172-16-180-167 kops-cn-master]$ kubectl describe pod -n kube-system kubernetes-dashboard
Warning  Failed     6m2s (x4 over 8m8s)    kubelet, ip-172-16-86-107.cn-northwest-1.compute.internal  Failed to pull image "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1": rpc error: code = Unknown desc = Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
  Warning  Failed     6m2s (x4 over 8m8s)    kubelet, ip-172-16-86-107.cn-northwest-1.compute.internal  Error: ErrImagePull

How to fix it?

1. curl -sS https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml -o kubernetes-dashboard.yaml
2. change the kubernetes-dashboard.yaml image: from 
k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1 to 937788672844.dkr.ecr.cn-north-1.amazonaws.com.cn/kubernetes-dashboard-amd64:v1.10.1
3. kubectl apply -f kubernetes-dashboard.yaml

Verify

[ec2-user@ip-172-16-40-249 kops-cn-master]$ kubectl -n kube-system get pod | grep kubernetes-dashboard
kubernetes-dashboard-f84788947-ns222                                        1/1     Running   0          7m16s

[ec2-user@ip-172-16-40-249 kops-cn-master]$ kubectl describe pod -n kube-system kubernetes-dashboard
....
Events:
  Type    Reason     Age   From                                                        Message
  ----    ------     ----  ----                                                        -------
  Normal  Scheduled  49s   default-scheduler                                           Successfully assigned kube-system/kubernetes-dashboard-f84788947-ns222 to ip-172-16-117-181.cn-northwest-1.compute.internal
  Normal  Pulling    49s   kubelet, ip-172-16-117-181.cn-northwest-1.compute.internal  pulling image "937788672844.dkr.ecr.cn-north-1.amazonaws.com.cn/kubernetes-dashboard-amd64:v1.10.1"
  Normal  Pulled     45s   kubelet, ip-172-16-117-181.cn-northwest-1.compute.internal  Successfully pulled image "937788672844.dkr.ecr.cn-north-1.amazonaws.com.cn/kubernetes-dashboard-amd64:v1.10.1"
  Normal  Created    45s   kubelet, ip-172-16-117-181.cn-northwest-1.compute.internal  Created container
  Normal  Started    45s   kubelet, ip-172-16-117-181.cn-northwest-1.compute.internal  Started container
liangruibupt commented 5 years ago

close it as know issue

pahud commented 5 years ago

Maybe this would be better.

Haven't tried it yet. But should work.

 helm install stable/kubernetes-dashboard \
--name kubernetes-dashboard \
--set image.repository=937788672844.dkr.ecr.cn-north-1.amazonaws.com.cn/kubernete
s-dashboard-amd64 \
--namespace kube-system

ref: https://github.com/helm/charts/tree/master/stable/kubernetes-dashboard