前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kubernetes 二进制安装(v1.20.16)(三)容器运行时

kubernetes 二进制安装(v1.20.16)(三)容器运行时

作者头像
看、未来
发布2022-06-09 10:37:04
3210
发布2022-06-09 10:37:04
举报
文章被收录于专栏:CSDN搜“看,未来”

本集群选择 docker 作为容器运行时。

文章目录

创建docker管理文件

代码语言:javascript
复制
#在k8s-master上进行操作,为了方便操作,将可执行文件和配置文件进行了分离
#可执行文件放在/opt/TLS/download/docker/bin下
#配置文件放在/opt/TLS/download/docker/cfg下
​
cd /opt/TLS/download
mkdir -p bin
mv docker/* bin
mv bin docker
mkdir -p docker/cfg
cd /opt/TLS/download/docker/cfg
​
#创建配置文件
cd /opt/TLS/download/docker/cfg
cat > docker.service << EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/local/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
​
tee daemon.json << 'EOF'
{
  "registry-mirrors": ["https://ung2thfc.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "50m"
  },
  "storage-driver": "overlay2"
}
EOF
​
#查看文件目录结构
[root@k8s-master docker]# cd /opt/TLS/download/docker/
[root@k8s-master docker]# tree ./
./
├── bin
│   ├── containerd
│   ├── containerd-shim
│   ├── containerd-shim-runc-v2
│   ├── ctr
│   ├── docker
│   ├── dockerd
│   ├── docker-init
│   ├── docker-proxy
│   └── runc
└── cfg
    ├── daemon.json
    └── docker.service

分发文件

代码语言:javascript
复制
#创建docker目录
mkdir -p /etc/docker
ssh k8s-node1 "mkdir -p /etc/docker"
​
#分发docker管理文件
scp /opt/TLS/download/docker/cfg/docker.service /usr/lib/systemd/system/docker.service
scp /opt/TLS/download/docker/cfg/docker.service k8s-node1:/usr/lib/systemd/system/docker.service
​
#分发docker配置文件
scp /opt/TLS/download/docker/cfg/daemon.json /etc/docker/daemon.json
scp /opt/TLS/download/docker/cfg/daemon.json k8s-node1:/etc/docker/daemon.json
​
#分发docker可执行文件
scp /opt/TLS/download/docker/bin/* /usr/local/bin
scp /opt/TLS/download/docker/bin/* k8s-node1:/usr/local/bin

核对文件

代码语言:javascript
复制
#核对docker管理文件
[root@k8s-master docker]# ls -l /usr/lib/systemd/system/docker.service
-rw-r--r-- 1 root root 456 Apr  3 13:17 /usr/lib/systemd/system/docker.service
[root@k8s-master docker]# ssh k8s-node1 "ls -l /usr/lib/systemd/system/docker.service"
-rw-r--r-- 1 root root 456 Apr  3 13:17 /usr/lib/systemd/system/docker.service
​
#核对docker配置文件
[root@k8s-master docker]# ls -l /etc/docker/daemon.json
-rw-r--r-- 1 root root 219 Apr  3 13:17 /etc/docker/daemon.json
[root@k8s-master docker]# ssh k8s-node1 "ls -l /etc/docker/daemon.json"
-rw-r--r-- 1 root root 219 Apr  3 13:18 /etc/docker/daemon.json
​
#核对docker可执行文件
[root@k8s-master docker]# ls -l /usr/local/bin/
total 241072
-rwxr-xr-x 1 root root 16659824 Apr  3 12:34 cfssl
-rwxr-xr-x 1 root root 13502544 Apr  3 12:34 cfssl-certinfo
-rwxr-xr-x 1 root root 11029744 Apr  3 12:34 cfssljson
-rwxr-xr-x 1 root root 33908392 Apr  3 13:19 containerd
-rwxr-xr-x 1 root root  6508544 Apr  3 13:19 containerd-shim
-rwxr-xr-x 1 root root  8609792 Apr  3 13:19 containerd-shim-runc-v2
-rwxr-xr-x 1 root root 21131264 Apr  3 13:19 ctr
-rwxr-xr-x 1 root root 52883616 Apr  3 13:19 docker
-rwxr-xr-x 1 root root 64758736 Apr  3 13:19 dockerd
-rwxr-xr-x 1 root root   708616 Apr  3 13:19 docker-init
-rwxr-xr-x 1 root root  2784145 Apr  3 13:19 docker-proxy
-rwxr-xr-x 1 root root 14352296 Apr  3 13:19 runc
[root@k8s-master docker]# ssh k8s-node1 "ls -l /usr/local/bin/"
total 200840
-rwxr-xr-x 1 root root 33908392 Apr  3 13:19 containerd
-rwxr-xr-x 1 root root  6508544 Apr  3 13:19 containerd-shim
-rwxr-xr-x 1 root root  8609792 Apr  3 13:19 containerd-shim-runc-v2
-rwxr-xr-x 1 root root 21131264 Apr  3 13:19 ctr
-rwxr-xr-x 1 root root 52883616 Apr  3 13:19 docker
-rwxr-xr-x 1 root root 64758736 Apr  3 13:19 dockerd
-rwxr-xr-x 1 root root   708616 Apr  3 13:19 docker-init
-rwxr-xr-x 1 root root  2784145 Apr  3 13:19 docker-proxy
-rwxr-xr-x 1 root root 14352296 Apr  3 13:19 runc

启动docker

代码语言:javascript
复制
#在k8s-master上执行启动命令,设置开启启动,并查看状态
[root@k8s-master docker]# systemctl daemon-reload && systemctl start docker && systemctl enable docker && systemctl status docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-04-03 13:26:46 CST; 72ms ago
     Docs: https://docs.docker.com
 Main PID: 1466 (dockerd)
   CGroup: /system.slice/docker.service
           ├─1466 /usr/local/bin/dockerd
           └─1471 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
​
Apr 03 13:26:46 k8s-master dockerd[1466]: time="2022-04-03T13:26:46.552291845+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
....
Hint: Some lines were ellipsized, use -l to show in full.
​
​
#在k8s-node1上执行启动命令,设置开启启动,并查看状态
[root@k8s-node1 ~]# systemctl daemon-reload && systemctl start docker && systemctl enable docker && systemctl status docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-04-03 13:26:53 CST; 84ms ago
     Docs: https://docs.docker.com
 Main PID: 1301 (dockerd)
   CGroup: /system.slice/docker.service
           ├─1301 /usr/local/bin/dockerd
           └─1307 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
​
Apr 03 13:26:53 k8s-node1 dockerd[1301]: time="2022-04-03T13:26:53.245105288+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
....
Hint: Some lines were ellipsized, use -l to show in full.
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-06-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 创建docker管理文件
  • 分发文件
  • 核对文件
  • 启动docker
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档