K8S installation process four: Docker installation and deployment

All Kubernetes worker nodes need to execute the following operation instructions. If the Kubernetes master node also needs to start the kubelet service, the Kubernetes master node also needs to execute the following operation instructions.

1. Preparations

su - root
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

2. docker service installation

  • View the list of docker versions
yum list docker-ce --showduplicates | sort -r

The output information is as follows:

docker-ce.x86_64            3:20.10.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.7-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
......
  • Select the required docker version to execute the installation command
yum install -y docker-ce-18.06.3.ce
  • Start the docker service
systemctl start docker

3. Verify that the docker service is started

Execute the following command on the command line

docker info

If there is information output as shown below, it means that the docker service is installed and started successfully

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.03.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-1160.53.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

4. Modify the image source

Set the domestic mirror source, open the /etc/docker/daemon.json file, and write the following content:

{
    "registry-mirrors": [
        "http://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com"
    ],
    "exec-opts": ["native.cgroupdriver=systemd"]
}
  • Restart the docker service. After modifying the image source, you need to restart the docker service to make the modified configuration take effect. The command to restart the docker service is as follows:
 systemctl restart docker

5. Install cri-dockerd service

If the kubernetes 1.24 version uses docker as the container engine, the cri-dockerd service needs to be installed separately.

  • Download the cri-dockerd installation package
su - root
cd  /opt
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.2.6/cri-dockerd-0.2.6-3.el7.x86_64.rpm
  • Install and start the service
yum install -y cri-dockerd-0.2.6-3.el7.x86_64.rpm
systemctl start cri-docker
  • View service startup status
systemctl status cri-docker

insert image description here

6. Download the initialization image

Since registry.k8s.io/pause:3.6 cannot be downloaded normally in the domestic network environment, it needs to be transferred with the help of domestic mirror warehouses. pause is a very important image. Without the pause image, other pods will not be able to start.

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6 registry.k8s.io/pause:3.6

Guess you like

Origin blog.csdn.net/hzwy23/article/details/128084555