Mac installs kubernetes and runs echoserver.

  kubernetes

Order

Last time, although I wrote two kubernetes installed on mac, it was only limited to the initial installation. This time, I added a demo to catch up with Aliyun’s image, so I recorded it again.

Install minikube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.15.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

Install kubectl

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/

Start up

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

Problem

The status of pod is in ContainerCreating.

kubectl describe pods

Error section log

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\""

Solve the problem

ReferencesK8s Initial Tour: minikube Starts docker MirroringThe method of this article, here we use Ali’s mirror image

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

Remove pod and observe again.

kubectl delete pods xxxx
kubectl get pod --all-namespaces

Now it’s running.

NAME                             READY     STATUS    RESTARTS   AGE
hello-minikube-957602326-gf17s   1/1       Running   0          40s

Run down demo

curl $(minikube service hello-minikube --url)

Output

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:

Resolve the ImagePullBackOff problem for kube-addon-manager-minikube

View details

kubectl describe --namespace=kube-system po kube-addon-manager-minikube

Found that pulling gcr.io/google-containers/kube-addon-manager:v6.1 failed, use Aliyun’s mirror fix

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

Use

kubectl get pods --all-namespaces

Normal

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

minikube dashboard

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

Check it out

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

Finally, open dashboard again.

minikube dashboard

See the long-lost interface
图片描述

doc