用kubeadm安装k8s(使用containerd作为runc)

1、从github下载下来containerd

https://github.com/containerd/containerd/releases/tag/v1.6.8

 

2、解压并将文件直接复制进去/usr/local/bin/

tar xvf containerd-1.6.8-linux-amd64.tar.gz
cp bin/* /usr/local/bin/

 

3、添加containerd.service放进去/lib/systemd/system

 

复制代码
[root@localhost ~]# cat /lib/systemd/system/containerd.service
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd


Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target
复制代码

 

 

4、创建并且修改配置文件

[root@localhost ~]# mkdir /etc/containerd
[root@localhost ~]# containerd config default >/etc/containerd/config.toml
配置镜像加速及修改sandbox:
vim /etc/containerd/config.toml
 61     sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.7”
153       [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
154         [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
155            endpoint = ["https://9916w1ow.mirror.aliyuncs.com"]

 

5、启动并设置为开机自启动

[root@localhost ~]# systemctl restart containerd
[root@localhost ~]# systemctl enable containerd
[root@localhost ~]# systemctl status containerd

 

6、部署runc

https://github.com/opencontainers/runc找到下面的包下载

wget https://github.com/opencontainers/runc/releases/download/v1.1.4/runc.amd64

 

 

7、使用kubeadm安装k8s

 

从阿里镜像库https://developer.aliyun.com/mirror/进去这里找到kubernetesyum

复制代码
[root@localhost ~]yum install -y kubelet kubeadm kubectl

调整内核参数:
[root@localhost ~]echo “net.bridge.bridge-nf-call-iptables = 1“ >>/etc/sysctl.conf
[root@localhost ~]echo “net.ipv4.ip_forward = 1 >>/etc/sysctl.conf


执行kubeadm
kubeadm init --apiserver-advertise-address=10.0.0.80 --apiserver-bind-port=6443 --kubernetes-version=v1.25.2 --pod-network-cidr=172.31.0.0/16 --service-cidr=172.32.0.0/16 --service-dns-domain=cluster.local --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --ignore-preflight-errors=swap


当出现成功安装后根据相应的指令执行即可
 [root@localhost ~]mkdir -p $HOME/.kube
[root@localhost ~]sudo cp -i /etc/kubernetes/admin.conf [root@localhost ~]$HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config
复制代码

 

8、安装CNI后即可完成

https://github.com/containernetworking/plugins/releases/tag/v1.1.1

[root@localhost src]wget https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz
[root@localhost src]# mkdir /opt/cni/bin/ -p
[root@localhost src]# tar xvf cni-plugins-linux-amd64-v1.1.1.tgz -C /opt/cni/bin/

 

posted @   stephen-leung  阅读(268)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示