Docker 简明教程
Docker - Working of Kubernetes
本章中,我们将了解如何通过 kubeadm 安装 Kubenetes 。这是一个帮助安装 Kubernetes 的工具。让我们逐步了解如何安装 Kubernetes。
In this chapter, we will see how to install Kubenetes via kubeadm. This is a tool which helps in the installation of Kubernetes. Let’s go step by step and learn how to install Kubernetes.
Step 1 − 确保您所使用的 Ubuntu server version 为 16.04 。
Step 1 − Ensure that the Ubuntu server version you are working on is 16.04.
Step 2 − 确保您生成了用于 ssh 登录的 ssh 密钥。您可以使用以下命令执行此操作。
Step 2 − Ensure that you generate a ssh key which can be used for ssh login. You can do this using the following command.
ssh-keygen
这将在您的 home folder 中生成密钥,如下所示。
This will generate a key in your home folder as shown below.
Step 3 − 接下来的操作取决于您所使用的 Ubuntu 版本,您需要将相关网站添加到 docker.list 中以用于 apt package manager ,以便可以从 kubernetes 网站检测 Kubernetes packages 并相应下载。
Step 3 − Next, depending on the version of Ubuntu you have, you will need to add the relevant site to the docker.list for the apt package manager, so that it will be able to detect the Kubernetes packages from the kubernetes site and download them accordingly.
我们可以使用以下命令操作。
We can do it using the following commands.
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main” | sudo tee /etc/apt/sources.list.d/docker.list
Step 4 − 我们然后颁布 apt-get 更新以确保已下载 Ubuntu 服务器上的所有软件包。
Step 4 − We then issue an apt-get update to ensure all packages are downloaded on the Ubuntu server.
Step 5 − 根据前面章节中所述安装 Docker 软件包。
Step 5 − Install the Docker package as detailed in the earlier chapters.
Step 6 − 现在是时候通过安装以下软件包来安装 kubernetes 了 −
Step 6 − Now it’s time to install kubernetes by installing the following packages −
apt-get install –y kubelet kubeadm kubectl kubernetes-cni
Step 7 − 一旦下载了所有 kubernetes 软件包,则应该使用以下命令启动 kubernetes 控制器 −
Step 7 − Once all kubernetes packages are downloaded, it’s time to start the kubernetes controller using the following command −
kubeadm init
完成后,您会收到一条成功的消息,指出 master 已启动并正在运行,并且节点现在可以加入群集。
Once done, you will get a successful message that the master is up and running and nodes can now join the cluster.