在mac使用minikube和kubectl测试,没想到也能踩这么多坑。逐一记录如下:
踩坑一:toomanyrequests
- 过程
执行如下命令
1
minikube kubectl -- run ngx --image=nginx:alpine --force
查看pod status
1
minikube kubectl get pod ngx
其状态显示为:ErrImagePull 或 ImagePullBackoff
查看详情
1
minikube kubectl describe pod ngx
报错信息
1
Failed to pull image "nginx:alpine": rpc error: code = Unknown desc = Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
- 修复
docker login 方法:参考
尝试注册docker账号,并通过docker login,无效。
更换镜像方法: 参考
由于未找到:/etc/docker/daemon.json 而无果。后参考 在GUI上配置了如下内容得以解决。但是又引入了第二个问题:
1
2
3
4
5
6
7
8
9
10
11
12
13
14{
"features": {
"buildkit": true
},
"experimental": false,
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
]
}
踩坑二:重启
- 过程:
在更新docker配置后,尝试接着运行minikube以测试
1
minikube kubectl describe pod ngx
报错:
1
The connection to the server 127.0.0.1:52554 was refused - did you specify the right host or port?
尝试执行其他命令:
1
2
3minikube kubectl delete pod ngx
minikube kubectl get pod ngx报错依旧
- 修复
参考 无效
系统无systemctl命令
想起查看minikube的状态吧
1
minikube status
通过状态发现未启动
1
2
3
4
5
6minikube
type: Control Plane
host: Stopped
kubelet: Stopped
apiserver: Stopped
kubeconfig: Stoppedstart 一下?
1
minikube start --image-mirror-country='cn'
😄 Darwin 12.5 (arm64) 上的 minikube v1.22.0
✨ 根据现有的配置文件使用 docker 驱动程序
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image …
🔄 Restarting existing docker container for “minikube” …
❗ The image ‘registry.cn-hangzhou.aliyuncs.com/>google_containers/coredns/coredns:v1.8.0’ was not found; >unable to add it to cache.
🐳 正在 Docker 20.10.7 中准备 Kubernetes v1.21.2…
❌ Unable to load cached images: loading cached images: stat />Users/xxxxxxx/.minikube/cache/images/registry.cn-hangzhou.>aliyuncs.com/google_containers/coredns/coredns_v1.8.0: no >such file or directory
🔎 Verifying Kubernetes components…
▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-minikube/storage-provisioner:v5 (global image repository)
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use “minikube” cluster >and “default” namespace by defaul
再来一次,成功了。看来在重启docker后,minikube需要重新启动。
1
2
3minikube kubectl -- run ngx --image=nginx:alpine --force
minikube kubectl get pod ngx1
2NAME READY STATUS RESTARTS AGE
ngx 1/1 Running 0 33s
祝福
祝大家好运!
- 本文作者: xiaoxiaozi
- 本文链接: http://www.xiaoxiaozi.com/2022/08/11/minikube_kubectl_fix1/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!