docker desktop for windows/mac中启动kubernetes
背景
在windows 10 / MAC中,搭建一个kubernetes的环境。
选择了docker desktop。
环境准备
mac下安装docker desktop
brew install --cask docker
问题
但是在启用kubernetes时,出现了卡住的情况。
原因
Docker日志在 C:\ProgramData\DockerDesktop
下的service.txt,
Kubernetes日志在 C:\Users\yourUserName\AppData\Local\Docker
下的log.txt。
经过多方查找,原因为下载不下来镜像所致。
解决
下载镜像
按照[1]中所述方法,我本地的kubernetes版本为1.22.5,于是用脚本手动下载镜像。但我本地由于权限原因,不支持ps脚本,只好自己全手动下载了。
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.5 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.5 k8s.gcr.io/pause:3.5 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.5 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.22.5 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.22.5 k8s.gcr.io/kube-controller-manager:v1.22.5 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.22.5 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.22.5 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.22.5 k8s.gcr.io/kube-scheduler:v1.22.5 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.22.5 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.22.5 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.22.5 k8s.gcr.io/kube-proxy:v1.22.5 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.22.5 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.22.5 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.22.5 k8s.gcr.io/kube-apiserver:v1.22.5 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.22.5 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.0-0 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.0-0 k8s.gcr.io/etcd:3.5.0-0 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.0-0 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.8.4 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.8.4 k8s.gcr.io/coredns/coredns:v1.8.4 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.8.4 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.1.1 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.1.1 k8s.gcr.io/ingress-nginx/controller:v1.1.1 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.1.1 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1 k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.1.1 docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1
删除pki目录
- 在Windows上面删除 'C:\ProgramData\DockerDesktop\pki' 目录 和 'C:\Users\yourUserName\AppData\Local\Docker\pki' 目录
最终,问题解决了。