Get the App
SLTechnology News&Howtos  ›  Development  › 

How to create a kubernetes cluster using the kubeadm command line tool

Shulou Source: shulou.com Published: 2022-06-01 02:11:55 09月21日 Update

This article mainly shows you "how to use kubeadm command-line tools to create kubernetes clusters", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use kubeadm command-line tools to create kubernetes clusters" this article.

Command line tool

There are three main tools, and command-line tools are named using the kube prefix.

Kubeadm: the instruction used to initialize the cluster.

Kubelet: used to launch Pod, containers, etc., on each node in the cluster.

Kubectl: a command-line tool for communicating with clusters.

Installed through a software repository

Method ①

This method is to download the installation kit from the source of Google.

Update the apt package index and install the packages required to use the Kubernetes apt repository:

Sudo apt-get updatesudo apt-get install-y apt-transport-https ca-certificates curl

Download the Google Cloud public signature key:

Sudo curl-fsSLo / usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

Add a Kubernetes apt repository:

Echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee / etc/apt/sources.list.d/kubernetes.list

Update the apt package index, install kubelet, kubeadm, and kubectl, and lock their versions:

Sudo apt-get updatesudo apt-get install-y kubelet kubeadm kubectlsudo apt-mark hold kubelet kubeadm kubectl

Method ②

Download the installation kit from Aliyun's source.

Add the source directly through the command.

Curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add

Then update the software source and install the three tools.

Apt-get update & & apt-get install-y apt-transport-https curlapt-get install-y kubelet kubeadm kubectl-allow-unauthenticated

Execute the command to check if it is normal:

Download and install kubeadm-help binaries

Check out the latest stable version of kubectl:

Curl-s https://storage.googleapis.com/kubernetes-release/release/stable.txt

The stable version currently queried by the author is v1.20.2.

Download the kubectl executable file to replace the version number in URL.

Curl-LO https://storage.googleapis.com/kubernetes-release/release/v1.20.2/bin/linux/amd64/kubectl

After downloading, the directory can see a kubectl file, 40MB size, the domestic download speed is slightly slower, may not be able to download, be prepared.

Then you need to give it executable file permissions.

Sudo chmod + x. / kubectl

In order to use kubectl directly, you can copy the files to the bin directory.

Sudo mv. / kubectl / usr/local/bin/kubectl

Execute the command to output the version number and check whether the installation is successful.

Kubectl version-client

Output:

Client Version: version.Info {Major: "1", Minor: "20", GitVersion: "v1.20.0", GitCommit: "af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState: "clean", BuildDate: "2020-12-08T17:59:43Z", GoVersion: "go1.15.5", Compiler: "gc", Platform: "linux/amd64"} ubutu & centos Quick installation

It's just that the different installation methods of ubuntu and centos are introduced here, which have been installed through the previous installation method, so you don't need to pay attention to this section.

Systems such as Ubuntu and Debain can be installed from the software repository using the following commands:

Sudo apt-get update & & sudo apt-get install-y apt-transport-https gnupg2 curlcurl-s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add-echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee-a / etc/apt/sources.list.d/kubernetes.listsudo apt-get updatesudo apt-get install-y kubelet kubeadm kubectl

Centos, RHEL and other systems can be installed through the software repository using the following commands:

Cat

Tags: Commands tools clusters versions repositories files nodes three methods software services content servers articles tips updates success can make address toolkit Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info NVidia Microsoft MariaDB