一、准备环境(所有服务器)
1.各服务器设置hosts
192.168.137.100 k8s-master
192.168.137.101 k8s-node1
192.168.137.102 k8s-node2
hostname set-hostname k8s-master
hostname set-hostname k8s-node1
hostname set-hostname k8s-node1
2。时间同步
自己想办法
3.lvs环境(暂定)
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
4.vim /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness =0
5.清除iptables
iptable -F ; iptables -t nat -F
6.修改 vim /run/systemd/resolve/resolv.conf(非常重要)
nameserver 10.96.0.1
7.基础环境一定要配置齐全
8.安装驱动
modprobe br_netfilter
modprobe overlay
二、准备软件(所有服务器)
1.在离线的环境下准备好需要的服务依赖镜像,需要从docker打包下载。
calico/kube-controllers v3.27.3
calico/cni v3.27.3
calico/pod2daemon-flexvol v3.27.3
calico/node v3.27.3
registry.aliyuncs.com/google_containers/kube-apiserver v1.28.2
registry.aliyuncs.com/google_containers/kube-scheduler v1.28.2
registry.aliyuncs.com/google_containers/kube-proxy v1.28.2
registry.aliyuncs.com/google_containers/kube-controller-manager v1.28.2
registry.aliyuncs.com/google_containers/etcd 3.5.9-0
registry.aliyuncs.com/google_containers/coredns v1.10.1
registry.aliyuncs.com/google_containers/pause 3.9
2.导入镜像到ctr管理
ctr -n k8s.io images import kube-controllers.tar.gz
所有的服务全部导入
列出所有的镜像
ctr -n k8s.io images ls
三、部署docker-ce,docker-ce-cli、containerd.io (所有服务器)
1.在有网的环境下载好所有的软件
sudo apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances 修改这里为包名| grep "^\w" | sort -u)
随后执行dpkg -i *.deb安装软件
随后查看状态
systemctl status docker
systemctl status containerd
systemctl status docker.socket
配置contanerd
containerd config default > /etc/containerd/config.toml
sed -i '/SystemdCgroup/s/false/true/g' /etc/containerd/config.toml
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
systemctl enable containerd
systemctl start containerd
四、部署k8s
1.在离线环境下载好所有的离线软件(kubectl、kubeadmi、kubelet)更具上面的操作执行
kubeadm init --apiserver-advertise-address=192.168.137.100 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.28.2 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.0.0.0/16 --ignore-preflight-errors=all --cri-socket /run/containerd/containerd.sock
会出现报错,执行一下重新初始化
重新打一下etcd的tag
mkdir -p $HOME/.kube sudo
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf(这句话要写进环境变量)
客户端根据自己的输出执行已下操作;
kubeadm join 192.168.137.100:6443 --token 5zuk01.90lzu02xkdcyb3w2 --discovery-token-ca-cert-hash sha256:5cd777c253f3f99e0193e61e4b8c54f2910bc956435b13136e5e0f07f06a04c2
2.加入网络插件
修改calico.yaml
- name: CALICO_IPV4POOL_CIDR
value: "10.0.0.0/16"
- name: IP_AUTODETECTION_METHOD
value: "interface=ens33"
kubectl apply -f calico.yaml 生效配置
五、验证是否完成
标签:aliyuncs,google,k8s1.28,containerd,ubuntu22.04,离线,--,k8s,com From: https://www.cnblogs.com/jianxgin/p/18547450