欢迎访问我的GitHub
这里分类和汇总了欣宸的全部原创(含配套源码):
https://github.com/zq2599/blog_demos
- 在linux安装minikube时遇到两个问题,在此记录整个安装过程,希望能够给遇见同样问题的读者一些参考;
前提
- 本次部署实战需要先解决谷歌镜像的下载问题,请确保您的网络可以正常访问和下载这些资源;
环境信息
- 操作系统:CentOS Linux release 7.6.1810
- Docker:1.13.1
准备工作
设置Docker
- 部署的第一步是对修改docker的cgroup driver设置,使其和即将安装的kubelet服务保持一致,否则会导致kubelet启动失败:
- 打开文件/usr/lib/systemd/system/docker.service,如下图,将红框中的systemd改为cgroupfs:
systemctl daemon-reload && systemctl restart docker
安装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
[root@minikubeblog ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
- 从上述信息可见kubect已经可用,但是还连接不上server端,接下来我们就来安装和启动minikube;
安装minikube
- 运行在虚拟机,这要求当前电脑上要先安装VirtualBox或者KVM;
- 运行在宿主机,这种方式不需要在当前电脑安装ViirtualBox或者KVM;
- 为了快速安装,今天实战用到的是上面的第二种方式;
- 下载最新版minikube,并赋予可执行权限:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
- 移动到系统目录,以便在任意位置可以执行minikube命令:
sudo cp minikube /usr/local/bin && rm minikube
- 启动minikube,参数--vm-driver=none表示minikube运行在宿主机,不需要提前安装VirtualBox或者KVM:
minikube start --vm-driver=none
- 等待一段时间后(和下载镜像的速度有关),minikube启动成功,执行kubectl get services查看服务正常:
[root@minikubeblog ~]# minikube start --vm-driver=none
* minikube v1.1.1 on linux (amd64)
* Creating none VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
* Configuring environment for Kubernetes v1.14.3 on Docker 1.13.1
* Unable to load cached images: loading cached images: loading image /root/.minikube/cache/images/gcr.io/k8s-minikube/storage-provisioner_v1.8.1: stat /root/.minikube/cache/images/gcr.io/k8s-minikube/storage-provisioner_v1.8.1: no such file or directory
* Downloading kubeadm v1.14.3
* Downloading kubelet v1.14.3
* Pulling images ...
* Launching Kubernetes ...
* Configuring local host environment ...
! The 'none' driver provides limited isolation and may reduce system security and reliability.
! For more information, see:
- https://github.com/kubernetes/minikube/blob/master/docs/vmdriver-none.md
! kubectl and minikube configuration will be stored in /root
! To use kubectl or minikube commands as your own user, you may
! need to relocate them. For example, to overwrite your own settings:
- sudo mv /root/.kube /root/.minikube $HOME
- sudo chown -R $USER $HOME/.kube $HOME/.minikube
* This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
* Verifying: apiserver proxy etcd scheduler controller dns
* Done! kubectl is now configured to use "minikube"
[root@minikubeblog ~]# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7m10s
- 至此,Linux环境部署和启动minikube成功,希望本文能给你在部署minikube时提供一些参考。
欢迎关注阿里云开发者社区博客:程序员欣宸
学习路上,你不孤单,欣宸原创一路相伴...