国内centos离线安装kubectl和minikube

k8s笔记:国内使用minikube安装单机版的k8s

Posted by Xiaolei.liang on November 28, 2019 本文总阅读量

安装docker-ce

参看之前文档

离线安装kubectl

curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x kubectl
mv kubectl /usr/local/bin
ln -sf /usr/local/bin/kubectl /usr/bin/kubectl

离线安装minikube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64&& chmod +x minikube
chmod +x minikube
mv minikube /usr/local/bin/
ln -sf /usr/local/bin/minikube /usr/bin/minikube

使用minikube安装k8s

# 安装k8s
minikube start --vm-driver=none --image-repository gcr.azk8s.cn/google-containers
# 安装指定版本的k8s
minikube start --vm-driver=none --image-repository gcr.azk8s.cn/google-containers --kubernetes-version='v1.14.3'

问题

  1. 使用azks.cn的镜像仓库,没有gcr.azk8s.cn/google-containers/storage-provisioner:v1.8.1

解决方法:

docker pull k8sminikube/storage-provisioner:v1.8.1
docker tag k8sminikube/storage-provisioner:v1.8.1 gcr.azk8s.cn/google-containers/storage-provisioner:v1.8.1
  1. 可用的镜像registry
minikube delete
minikube start --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --kubernetes-version v1.16.2 --vm-driver=none
  1. 删除并使用新版本k8s
# docker 19.03-ce
minikube delete --all
/bin/rm -rf /etc/kubernetes
minikube start --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --kubernetes-version v1.12.10 --vm-driver=none
  1. 报错’Sorry that minikube crashed’.
这个应该是有多种原因的,方法就是删除一切k8s相关东西。
minikube delete
/bin/rm -rf /root/.kube /root/.minikube /etc/kubernetes
/bin/rm -rf /usr/lib/systemd/system/kubelet.service /etc/systemd/system/kubelet.service  /etc/systemd/system/kubelet.service.d /var/lib/kubelet/  /etc/systemd/system/multi-user.target.wants/kubelet.service /usr/libexec/kubernetes/kubelet-plugins

kubelet是安装在本机上的service,而不是以镜像启动的,所以需要删除kubelet相关文件,否则网络、认证有问题,安装出错