上次雖然寫了兩篇在mac裝kubernetes的,可是僅僅限於初步安裝,此次再補上跑個demo,正好也遇上阿里雲有相關鏡像,因而這裏再次記錄下。nginx
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.15.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.5.1/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
minikube start kubectl run hello-minikube --image=registry.cn-hangzhou.aliyuncs.com/google-container/echoserver:1.4 --port=8080 kubectl expose deployment hello-minikube --type=NodePort kubectl get pod
pod的status都在ContainerCreating,查看git
kubectl describe pods
出錯部分loggithub
Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 8m 8m 1 {default-scheduler } Normal Scheduled Successfully assigned hello-minikube-957602326-t9mzf to minikube 6m 3m 2 {kubelet minikube} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for gcr.io/google_containers/pause-amd64:3.0, this may be because there are no credentials on this request. details: (Error response from daemon: Get https://gcr.io/v1/_ping: dial tcp 64.233.187.82:443: i/o timeout)" 6m 1m 10 {kubelet minikube} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\""
參考k8s初遊: minikube啓動docker鏡像這篇文章的方法,這裏咱們用阿里的鏡像docker
minikube ssh docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
刪除pod再觀察下segmentfault
kubectl delete pods xxxx kubectl get pod --all-namespaces
這下變成running了api
NAME READY STATUS RESTARTS AGE hello-minikube-957602326-gf17s 1/1 Running 0 40s
curl $(minikube service hello-minikube --url)
輸出ssh
CLIENT VALUES: client_address=172.17.0.1 command=GET real path=/ query=nil request_version=1.1 request_uri=http://192.168.99.101:8080/ SERVER VALUES: server_version=nginx: 1.10.0 - lua: 10001 HEADERS RECEIVED: accept=*/* host=192.168.99.101:31860 user-agent=curl/7.43.0 BODY:
查看詳情curl
kubectl describe --namespace=kube-system po kube-addon-manager-minikube
發現拉取gcr.io/google-containers/kube-addon-manager:v6.1失敗,使用阿里雲的鏡像fix一下tcp
minikube ssh docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kube-addon-manager-amd64:v6.1 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kube-addon-manager-amd64:v6.1 gcr.io/google-containers/kube-addon-manager:v6.1
使用this
kubectl get pods --all-namespaces
正常了
NAMESPACE NAME READY STATUS RESTARTS AGE default hello-minikube-957602326-gf17s 1/1 Running 1 44m kube-system kube-addon-manager-minikube 1/1 Running 0 55m
kubectl get pod --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE default hello-minikube-957602326-gf17s 1/1 Running 1 47m kube-system kube-addon-manager-minikube 1/1 Running 0 58m kube-system kube-dns-v20-m9p7t 0/3 ContainerCreating 0 2m kube-system kubernetes-dashboard-k6z7w 0/1 ImagePullBackOff 0 2m
查看下
kubectl describe --namespace=kube-system po kube-dns-v20-m9p7t
fix
minikube ssh docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kubedns-amd64:1.9 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kubedns-amd64:1.9 gcr.io/google_containers/kubedns-amd64:1.9 docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kube-dnsmasq-amd64:1.4 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kube-dnsmasq-amd64:1.4 gcr.io/google_containers/kube-dnsmasq-amd64:1.4 docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/exechealthz-amd64:1.2 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/exechealthz-amd64:1.2 gcr.io/google_containers/exechealthz-amd64:1.2
fix
kubectl describe --namespace=kube-system po kubernetes-dashboard-k6z7w docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.0 docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.0 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1
最後再次打開dashboard
minikube dashboard
看到久違的界面了