k8s 1.28.3 使用containerd

文章目录

环境说明

主机名称 操作系统(mac宿主机) ip地址 cpu 内存 k8s containerd runc cilium kubectl kubelet kubeadm
k8s-master01 Ubuntu 22.04.3 LTS 192.168.195.20/24 2 2 1.28 1.7.3 1.1.8 1.14.3 v1.28.2 1.28.2 1.28.2
k8s-worker01 Ubuntu 22.04.3 LTS 192.168.195.29/24 2 4 1.28 1.7.3 1.1.8 1.14.3 v1.28.2 1.28.2 1.28.2
k8s-worker02 Ubuntu 22.04.3 LTS 192.168.195.30/24 2 4 1.28 1.7.3 1.1.8 1.14.3 v1.28.2 1.28.2 1.28.2

最终结果

环境配置

时钟同步

Plain 复制代码
apt install chrony -y
systemctl enable --now chrony.service
Plain 复制代码
timedatectl set-timezone Asia/Shanghai
date

主机名称配置

Plain 复制代码
#master
hostnamectl set-hostname k8s-master01

#work1
hostnamectl set-hostname k8s-worker01

#work2
hostnamectl set-hostname k8s-worker02

主机名解析

Plain 复制代码
# vim /etc/hosts
192.168.195.20 k8s-master01
192.168.195.29 k8s-worker01
192.168.195.30 k8s-worker02

关闭swap

Plain 复制代码
swapoff -a
sed -i '/\sswap\s/s/^/#/' /etc/fstab

安装ipvs

Plain 复制代码
apt install ipset ipvsadm

cat > /etc/modules-load.d/ipvs.conf << EOF
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack
br_netfilter
EOF

modprobe --all ip_vs ip_vs_rr ip_vs_wrr  ip_vs_sh  nf_conntrack br_netfilter

lsmod|grep -e ip_vs -e nf_conntrack
Plain 复制代码
# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

sysctl -p

安装containerd

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

安装containerd

Plain 复制代码
wget https://github.com/containerd/containerd/releases/download/v1.7.3/cri-containerd-1.7.3-linux-arm64.tar.gz

tar xf cri-containerd-1.7.3-linux-arm64.tar.gz -C /

生成配置

Plain 复制代码
mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml

修改配置

Plain 复制代码
# vim /etc/containerd/config.toml 
            SystemdCgroup = true  #配置systemdcgroup驱动程序
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9" #因为k8s需要pause:3.9镜像,共用

开启containerd服务

Plain 复制代码
ctr image pull registry.aliyuncs.com/google_containers/pause:3.9

systemctl enable --now containerd
containerd --version

安装runc

(可忽略,因为containerd自带)

https://github.com/opencontainers/runc/releases/tag/v1.1.5

安装k8s

安装kubelet kubeadm kubectl

https://developer.aliyun.com/mirror/kubernetes?spm=a2c6h.13651102.0.0.73281b11ZWDJ2s

Plain 复制代码
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
获取kubernetes 1.28组件容器镜像
Plain 复制代码
root@k8s-master01:/etc# kubeadm config images list --image-repository=registry.aliyuncs.com/google_containers
ctr image pull registry.aliyuncs.com/google_containers/kube-apiserver:v1.28.3
ctr image pull registry.aliyuncs.com/google_containers/kube-controller-manager:v1.28.3
ctr image pull registry.aliyuncs.com/google_containers/kube-scheduler:v1.28.3
ctr image pull registry.aliyuncs.com/google_containers/kube-proxy:v1.28.3
ctr image pull registry.aliyuncs.com/google_containers/pause:3.9
ctr image pull registry.aliyuncs.com/google_containers/etcd:3.5.9-0
ctr image pull registry.aliyuncs.com/google_containers/coredns:v1.10.1

拉取镜像

Plain 复制代码
kubeadm config images pull --image-repository=registry.aliyuncs.com/google_containers

初始化集群

方法一(不太会 ipvs模式)

Plain 复制代码
#打印初始化配置
kubeadm config print init-defaults --component-configs KubeletConfiguration
Plain 复制代码
advertiseAddress: 192.168.195.20
criSocket: unix:///var/run/containerd/containerd.sock
imageRepository: registry.aliyuncs.com/google_containers
kubernetesVersion: 1.28.3
serviceSubnet: 192.168.10.0/24

方法二(iptables模式)

Plain 复制代码
kubeadm init \
--apiserver-advertise-address=192.168.195.20  \
--kubernetes-version=v1.28.3 \
--pod-network-cidr=192.168.20.0/24 \
--service-cidr=192.168.10.0/24 \
--token-ttl=0 \
--cri-socket unix:///var/run/containerd/containerd.sock \
--upload-certs \
--image-repository=registry.aliyuncs.com/google_containers

安装cilium

官网链接:https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/

Plain 复制代码
# 下载cilium-cli
CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)
CLI_ARCH=amd64
if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi
curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum
sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin
rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}

#安装,等待一会
cilium install --version 1.14.3

cilium install \
  --agent-image=registry.cn-hangzhou.aliyuncs.com/cilium/cilium:v1.14.3 \
  --operator-image=registry.cn-hangzhou.aliyuncs.com/cilium/operator-generic:v1.14.3

iptable改ipvs

https://www.yuque.com/yuqueyonghudwdyw7/vhna62/fh4rdicy5ilfnsu1#《Kubernetes理论知识》

相关推荐
@东辰2 小时前
【golang-技巧】-自定义k8s-operator-by kubebuilder
开发语言·golang·kubernetes
小安运维日记2 小时前
CKA认证 | Day3 K8s管理应用生命周期(上)
运维·云原生·容器·kubernetes·云计算·k8s
陈小肚2 小时前
k8s 1.28.2 集群部署 docker registry 接入 MinIO 存储
docker·容器·kubernetes
politeboy4 小时前
关于k8s中镜像的服务端口被拒绝的问题
云原生·容器·kubernetes
weixin_438197384 小时前
K8S创建云主机配置docker仓库
linux·云原生·容器·eureka·kubernetes
皮锤打乌龟10 小时前
(干货)Jenkins使用kubernetes插件连接k8s的认证方式
运维·kubernetes·jenkins
ggaofeng14 小时前
通过命令学习k8s
云原生·容器·kubernetes
qq_道可道17 小时前
K8S升级到1.24后,切换运行时导致 dind 构建镜像慢根因定位与解决
云原生·容器·kubernetes
SONGW201818 小时前
k8s拓扑域 :topologyKey
kubernetes
weixin_4381973819 小时前
K8S实现反向代理,负载均衡
linux·运维·服务器·nginx·kubernetes