记录一下我在ubuntu下安装 minikube的过程
机器配置
腾讯云主机2核4G,已经安装docker 19.03.12
安装kubectl:
参考https://kubernetes.io/docs/tasks/tools/install-kubectl/
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl
下载minikube
可以参考 https://minikube.sigs.k8s.io/docs/start/ 安装配置,下面提供了阿里云团队构建的版本
curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.13.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
启动minkube
我是用的本机的docker运行的,所以有以下几点需要注意:
1.不能用root用户来启动minikube,否则错误提示如下
The "docker" driver should not be used with root privileges.
2.新增一个用户,然后把这个用户加到docker用户组,然后才能运行
sudo usermod -aG docker $USER && newgrp docker
3.启用minikube
ubuntu@******:~/download$ minikube start --driver=docker --image-mirror-country=cn --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --iso-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.7.3.iso --registry-mirror=https://hub-mirror.c.163.com
* minikube v1.13.0 on Ubuntu 18.04
* Using the docker driver based on user configuration
* Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Stopping node "minikube" ...
* Powering off "minikube" via SSH ...
* Deleting "minikube" in docker ...
! StartHost failed, but will try again: creating host: create: provisioning: Temporary Error: error getting ip during provisioning: IPs output should only be one line, got 2 lines
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Failed to start docker container. Running "minikube delete" may fix it: creating host: create: provisioning: Temporary Error: error getting ip during provisioning: IPs output should only be one line, got 2 lines
X Exiting due to GUEST_PROVISION: Failed to start host: creating host: create: provisioning: Temporary Error: error getting ip during provisioning: IPs output should only be one line, got 2 lines
*
* If the above advice does not help, please let us know:
- https://github.com/kubernetes/minikube/issues/new/choose
4.出错了,继续网上搜,找到以下解决文案试了下
https://askubuntu.com/questions/747778/docker-warning-config-json-permission-denied
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R sudo chmod g+rwx "/home/$USER/.docker" -R
5.删除掉文件,
ubuntu@******:~/download$ minikube delete --all
* Deleting "minikube" in docker ...
* Removing /home/ubuntu/.minikube/machines/minikube ...
* Removed all traces of the "minikube" cluster.
* Successfully deleted all profiles
5.然后重新启动,最终成功
ubuntu@******:~/download$ minikube start --driver=docker --image-mirror-country=cn --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --iso-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.7.3.iso --registry-mirror=https://hub-mirror.c.163.com * minikube v1.13.0 on Ubuntu 18.04 * Using the docker driver based on user configuration * Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers * Starting control plane node minikube in cluster minikube * Creating docker container (CPUs=2, Memory=2200MB) ... * Preparing Kubernetes v1.19.0 on Docker 19.03.8 ... > kubectl.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s > kubeadm.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s > kubelet.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s > kubectl: 41.01 MiB / 41.01 MiB [---------------] 100.00% 4.14 MiB p/s 10s > kubeadm: 37.30 MiB / 37.30 MiB [---------------] 100.00% 3.30 MiB p/s 12s > kubelet: 104.88 MiB / 104.88 MiB [-------------] 100.00% 5.77 MiB p/s 18s * Verifying Kubernetes components... * Enabled addons: default-storageclass, storage-provisioner * Done! kubectl is now configured to use "minikube" by default
6. 运行kubectl 查看版本
ubuntu@******:~/.docker$ kubectl version Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1", GitCommit:"206bcadf021e76c27513500ca24182692aabd17e", GitTreeState:"clean", BuildDate:"2020-09-09T11:26:42Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:23:04Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}
7.通过kubectl cluster-info
去连一下k8s api server
ubuntu@******:~/.docker$ kubectl cluster-info Kubernetes master is running at https://172.18.0.3:8443 KubeDNS is running at https://172.18.0.3:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
参考以下文章:
https://developer.aliyun.com/article/221687
https://developer.aliyun.com/article/691500?spm=a2c6h.14164896.0.0.3e3d7bd5wiBiC7