Choice of K8s Automatic Installation Method of Container Cloud

At present, kubernetes has developed to the era of 1.5, but before that, learning and using kubernetes still took a lot of detours. The first problem is installation, maybe you will say that the installation is very simple. Copy an article from the official website or online and you can install it...

And when we used kubernetes version 1.1 and 1.2, the most authoritative document at that time should be the official website document of kubernetes.io... However, it will appear when we search for problems on the official website (this picture comes from the network)

This picture has clearly explained the problem... Due to the problems in the installation process, a series of problems in the later use process are caused...

With the development of kubernetes (currently reaching the 1.5 beta version), the official documentation has become more complete than before. At the same time, there are many ways to install kuberntets. How should we choose among so many installation methods?

Today I will introduce 5 installation methods for you

minikube

minikube is provided by CoreOS to build a kubernetes cluster on a single machine. The minikube command can run on platforms such as windows/linux/macos. It is very convenient to use minikube to build a local cluster. At the same time, minikube provides a complete kubernetes cluster function. For beginners, minikube is a good way to install, and it's very quick to get started. But the problem is that minikube needs to be connected to the Internet when installed, and the network needs to be good enough... The reason is simple.

This is the official website using minikube to start the kubernetes cluster. If you are interested, you can check github's information on minikube.

beadm

kubeadm can run on physical machines, virtual machines, and cloud hosts, and can work with chef or puppet to automate deployment and installation. kubeadm is the same as minikube, your network is better and the reason is simple...

kubeadm 是 kubernetes 在1.4版推出安装 kubernetes 集群。目前还处于alpha,不建议在生产环境使用。本人在centos系统上安装测试时会出现无法连接到kubeadm所需要的yum源。即使按照官网配置了源也行出现无法下载源,最后是找到三方源才能顺利安装完成。在安装过程中可选的配置参数太少,所以基本都需要在使用过程中自行修改。

如图就是官方说明添加yum源,ubuntu没测试过。

hyperkube image

hyperkube images 由 Google 推出将 kubernetes 各组件以容器方式运行。容器可以有(docker/rkt等)。使用 hyperkube images 需要提前配置 kubelet 组件。最终通过kubelet将kubenetes部署各组件。这种安装方法的好处是:只要系统可运行容器,就可以通过hyperkube images 来运行kubernetes组件。

通过 hyperkube images 部署kubernetes组件,首先你的网络要好,原因很简单……或者你提前在本地准备好 hyperkube images 。

前面说过使用 hyperkube images 需要使用 kubelet 组件。运行kubelet组件可以有两种方法:docker和systemd。

通过设置kubelet 的–config目录。kubelet 会自动运行此目录中所添加的组件。在这里需要注意是,在kubernetes V1.3的版本,需要手动创建kube-system的namespace 而V1.4版本不需要配置。

docker

docker images 由 kubernetes 在发行版本中提供 docker images,并通过 docker images 运行 kubernetes 组件。所需要的镜像包在kubernetes-server-linux-amd64.tar.gz里。

SystemD

第五种方法通过SystemD来实现,这也是我们在生产和测试环境使用的方法。

Like it or not, systemd is here to stay.

看完上图也许我会明白systemd在系统中的重要做用。

在这之前,我们在Linux下使用容器你会发现,不能挑内核,不能加载内核模块,不能挂载文件系统,不能调整内核参数,不能改网络配置。如果你在运行容器时使用了 docker run –privileged 那我只能说祝你好运。

如果容器就是通过cgroups堆出来,那么容器本身的/sys /dev 和 /proc 存在隔离性的问题。

因此通systemd+selinux 来进行管理,而kubernetes只需要调用systemd就完成对于容器的管理。

因此我在基于systemdd在自的环境编写了安装kubernetes各组件的脚本。

安装脚本主要完成上图的安装和配置。

总结

个人推荐使用systemd的方式来远行kubenetes各组件。如果可以,可以使用rkt+systemd。

文中可能存在错误的地方欢迎大家指正。希望大家在安装kubernetes时少走弯路。谢谢!

普元云计算专区: http://primeton.csdn.net/m/zone/primeton/index#

 

http://www.tuicool.com/articles/ZzQJJzA

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326629861&siteId=291194637