前言
Minikube可在本地快速启动一个Kubernetes环境,用来开发和测试
环境
系统:CentOS 7.2
准备
-
安装kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- 安装依赖包
yum install conntrack-tools
安装
- 安装
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
- 启动
minikube start --driver=none --image-repository=registry.aliyuncs.com/google_containers
--driver=none 在虚拟机上运行时需要使用此参数
--image-repository=registry.aliyuncs.com/google_containers 默认镜像库gcr.io在国内一般无法访问,替换为阿里云的(但部分功能拉取image失败,后面有解决方法)
- 管理
minikube status
minikube stop
minikube delete
修复
解决pod/storage-provisioner拉取image失败
- 查看所有pod
kubectl -n kube-system get pods
会看到storage-provisioner状态是magePullBackOff
- 查看pod/storage-provisioner详情
kubectl -n kube-system describe pods storage-provisioner
会看到image地址是registry.aliyuncs.com/google_containers/k8s-minikube/storage-provisioner
- 修改pod/storage-provisioner的image地址
kubectl -n kube-system edit pod/storage-provisioner
原来 registry.aliyuncs.com/google_containers/k8s-minikube/storage-provisioner
正确 registry.aliyuncs.com/google_containers/storage-provisioner
启用功能
启用Ingress
- 启用
minikube addons enable ingress
此时因为image地址错误,会卡住,新开窗口执行以下命令
- 查看ingress资源
kubectl -n ingress-nginx get all
- 修改pod/ngress-nginx-admission-create-xxxxx的image地址
kubectl -n ingress-nginx edit pod/ingress-nginx-admission-create-xxxxx
原来 registry.aliyuncs.com/google_containers/docker.io/jettech/kube-webhook-certgen
正确 docker.io/jettech/kube-webhook-certgen
- 修改pod/ingress-nginx-admission-patch-xxxxx的image地址
kubectl -n ingress-nginx edit pod/ingress-nginx-admission-patch-xxxxx
原来 registry.aliyuncs.com/google_containers/docker.io/jettech/kube-webhook-certgen
正确 docker.io/jettech/kube-webhook-certgen
- 修改deployment/ingress-nginx-controller的image地址
kubectl -n ingress-nginx edit deployment/ingress-nginx-controller
原来 registry.aliyuncs.com/google_containers/ingress-nginx/controller
正确 registry.aliyuncs.com/google_containers/nginx-ingress-controller
网友评论