Kubernetes is an open source system for automatic deployment, scaling and management of containerized applications. It groups the containers that make up the application into logical units to facilitate management and discovery.
In the process of installing kubernetes cluster, you need to install kubeadm
, kubectl
,
kubelet
and
other programs, and also need to pull the required kube-apiserver
, kube-controller-manager
,
kube-scheduler
and other container images. Because the default operating system source
and container image source
are located abroad, the download and pull speed is relatively slow. This paper specially collates
the use of sources in China to install kubernetes related programs and pull the required images.
Ⅰ. Install kubeadm , kubectl , kubelet
Debian / Ubuntu configuration
apt-get update && apt-get install -y apt-transport-https
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
The above command installs the default version of programs such askubeadm
. You can also use the commandapt install -y kubeadm=1.22.3-00 kubectl=1.22.3-00 kubelet=1.22.3-00
to install the specified version of the program.
Use the commandapt-cache madison kubeadm
to search the repository for available installed versions.
CentOS / RHEL / Fedora configuration
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
If the index gpg check fails, use the command yum install -y --nogpgcheck kubelet kubeadm
kubectl
to install.
Ⅱ. Pull the container image required by the installation process
Because the default image source k8s.cgr.io is generally inaccessible in China, so we need to use the image source in China to pull it down, and then change the image tag.
1. Execute kubeadm config images list
to view the container image required for
installation.
k8s.gcr.io/kube-apiserver:v1.22.3
k8s.gcr.io/kube-controller-manager:v1.22.3
k8s.gcr.io/kube-scheduler:v1.22.3
k8s.gcr.io/kube-proxy:v1.22.3
k8s.gcr.io/pause:3.5
k8s.gcr.io/etcd:3.5.0-0
k8s.gcr.io/coredns/coredns:v1.8.4
2. Pull the image from the Alibaba Cloud image mirror repository and modify the corresponding tag.
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.22.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.22.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.22.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.22.3
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.5
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.0-0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.4
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.22.3 k8s.gcr.io/kube-apiserver:v1.22.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.22.3 k8s.gcr.io/kube-controller-manager:v1.22.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.22.3 k8s.gcr.io/kube-scheduler:v1.22.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.22.3 k8s.gcr.io/kube-proxy:v1.22.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.5 k8s.gcr.io/pause:3.5
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.0-0 k8s.gcr.io/etcd:3.5.0-0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.4 k8s.gcr.io/coredns/coredns:v1.8.4
Alibaba Cloud image repository also has other versions of kubernetes
images. According
to the image listed in the previous command, select and install the image of the corresponding
tag.
Kubernetes (k8s) China image source list. Install kubeadm, kubectl and kubelet using the image source in china. Use the china image source list to download the images required for kubernetes installation.