系统Ubuntu 22.04.2
| 主机名称 | IP |
| ----- | -------- |
| k8s-master | 192.168.198.141 |
| k8s-node01 | 192.168.198.142 |
| k8s-node02 | 192.168.198.143 |
设置k8s环境准备条件(所有机器)
swapoff -a
sudo vim /etc/fstab
apt-get install -y bridge-utils
modprobe br_netfilter
lsmod | grep br_netfilter
安装配置container
2.1 安装启动
--安装依赖工具
sudo apt-get install -y apt-transport-https ca-certificates curl
--安装containerd
sudo apt-get -y install containerd
sudo systemctl enable containerd
sudo systemctl start containerd
2.2 输出配置(需手动创建空文件)
--输出默认配置文件
sudo mkdir /etc/containerd
sudo touch /etc/containerd/config.toml
sudo containerd config default>/etc/containerd/config.toml
2.3 编辑配置文件
sudo vi/etc/containerd/config.toml
1.修改SystemdCgroup参数为true,默认为false
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup=true
2.修改sandbox_image参数,其值一定要和
kubeadm config images list 命令输出的pause版本和tag保持一致,否则Node节点的Pod一直CrashLoopBackOff而且查询 kubectl logs 时也没有任何错误,此处我的版本为阿里云3.6
sandbox_image="registry.aliyuncs.com/google_containers/pause:3.6"
2.4 配置容器ENDPOINT并生效
crictl config runtime-endpoint unix:///run/containerd/containerd.sock
crictl config image-endpoint unix:///run/containerd/containerd.sock
systemctl restart containerd
3.1 安装 kubelet kubeadm kubectl
# 安装基础环境
apt-get install -y ca-certificates curl software-properties-common apt-transport-https curl
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
# 执行配置k8s阿里云源
vim /etc/apt/sources.list.d/kubernetes.list
#加入以下内容
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
# 执行更新
apt-get update -y
# 安装kubeadm、kubectl、kubelet
apt-get install -y kubelet=1.27.2-00 kubeadm=1.27.2-00 kubectl=1.27.2-00
# 阻止自动更新(apt upgrade时忽略)。所以更新的时候先unhold,更新完再hold。
apt-mark hold kubelet kubeadm kubectl
# 集群初始化
kubeadm init --apiserver-advertise-address=192.168.198.141 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.27.2 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16 --v=5
安装网络插件
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
手机扫一扫
移动阅读更方便
你可能感兴趣的文章