博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mac安装kubernetes并运行echoserver
阅读量:5734 次
发布时间:2019-06-18

本文共 4776 字,大约阅读时间需要 15 分钟。

上次虽然写了两篇在mac装kubernetes的,但是仅仅限于初步安装,这次再补上跑个demo,正好也赶上阿里云有相关镜像,于是这里再次记录下。

安装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/

安装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/

启动

minikube startkubectl run hello-minikube --image=registry.cn-hangzhou.aliyuncs.com/google-container/echoserver:1.4 --port=8080kubectl expose deployment hello-minikube --type=NodePortkubectl get pod

问题

pod的status都在ContainerCreating,查看

kubectl describe pods

出错部分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\""

解决问题

参考这篇文章的方法,这里我们用阿里的镜像

minikube sshdocker pull registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0

删除pod再观察下

kubectl delete pods xxxxkubectl get pod --all-namespaces

这下变成running了

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

跑下demo

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

输出

CLIENT VALUES:client_address=172.17.0.1command=GETreal path=/query=nilrequest_version=1.1request_uri=http://192.168.99.101:8080/SERVER VALUES:server_version=nginx: 1.10.0 - lua: 10001HEADERS RECEIVED:accept=*/*host=192.168.99.101:31860user-agent=curl/7.43.0BODY:

解决kube-addon-manager-minikube的ImagePullBackOff问题

查看详情

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

发现拉取gcr.io/google-containers/kube-addon-manager:v6.1失败,使用阿里云的镜像fix一下

minikube sshdocker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kube-addon-manager-amd64:v6.1docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kube-addon-manager-amd64:v6.1 gcr.io/google-containers/kube-addon-manager:v6.1

使用

kubectl get pods --all-namespaces

正常了

NAMESPACE     NAME                             READY     STATUS    RESTARTS   AGEdefault       hello-minikube-957602326-gf17s   1/1       Running   1          44mkube-system   kube-addon-manager-minikube      1/1       Running   0          55m

minikube dashboard

kubectl get pod --all-namespacesNAMESPACE     NAME                             READY     STATUS              RESTARTS   AGEdefault       hello-minikube-957602326-gf17s   1/1       Running             1          47mkube-system   kube-addon-manager-minikube      1/1       Running             0          58mkube-system   kube-dns-v20-m9p7t               0/3       ContainerCreating   0          2mkube-system   kubernetes-dashboard-k6z7w       0/1       ImagePullBackOff    0          2m

查看下

kubectl describe --namespace=kube-system po kube-dns-v20-m9p7t

fix

minikube sshdocker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kubedns-amd64:1.9docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kubedns-amd64:1.9 gcr.io/google_containers/kubedns-amd64:1.9docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kube-dnsmasq-amd64:1.4docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kube-dnsmasq-amd64:1.4 gcr.io/google_containers/kube-dnsmasq-amd64:1.4docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/exechealthz-amd64:1.2docker 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-k6z7wdocker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.0docker 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

看到久违的界面了

图片描述

doc

转载地址:http://jwwzx.baihongyu.com/

你可能感兴趣的文章
SharePoint 读取 Site Columns 的数据并绑定到DropdownList
查看>>
Python中的对象行为与特殊方法(二)类型检查与抽象基类
查看>>
使用 axios 详解
查看>>
通信基站(dfs回溯,思维)
查看>>
nginx web加密访问
查看>>
iOS - Regex 正则表达式
查看>>
第 68 章 Logical Volume Manager (LVM)
查看>>
膝盖中了一箭之康复篇-第八个月暨2月份目标总结
查看>>
IPA提交APPStore问题记录(一)
查看>>
有利于seo优化的网站地图不能取巧
查看>>
快照产品体验优化
查看>>
ASCII
查看>>
ibatis SqlMap not found
查看>>
Android SD卡创建文件和文件夹失败
查看>>
Ubuntu 14.04 vsftp refusing to run with writable root inside chroot问题解决方法
查看>>
Intellij IDEA远程调试tomcat
查看>>
hadoop的学习论坛
查看>>
Struts2 学习小结
查看>>
烂泥:wordpress迁移到docker
查看>>
.扒渣机的性能及优势 
查看>>