赞
踩
AnolisOS-8.6-x86_64-minimal.iso
Virtual Box,4 vCPU, 8G RAM, 40 vDisk
关闭selinux,默认已关闭
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g’ /etc/selinux/config
关闭防火墙
systemctl disable --now firewalld
允许iptables检查桥接流量
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
配置主机名解析
cat >> /etc/hosts << EOF
192.168.1.155 master
EOF
关闭swap
vi /etc/fstab,注释掉
#/dev/mapper/ao-swap
重启系统
cat > /etc/yum.repos.d/docker-ce.repo << EOF
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
EOF
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
清除,更新缓存
yum clean all && yum makecache
yum -y install ipvsadm iproute-tc socat conntrack-tools
yum -y install containerd.io
containerd config default > /etc/containerd/config.toml
修改/etc/containerd/config.toml
SystemdCgroup = true
sandbox_image = “registry.aliyuncs.com/google_containers/pause:3.9”
cat /etc/containerd/config.toml | grep System
cat /etc/containerd/config.toml | grep sandbox_image
systemctl enable --now containerd
systemctl restart containerd
systemctl status containerd
yum list kubectl kubeadm kubelet --showduplicates|sort -r | grep 1.26
yum -y install kubectl-1.26.9-0 kubelet-1.26.9-0 kubeadm-1.26.9-0 --disableexcludes=kubernetes
systemctl enable --now kubelet
设置 crictl 连接 containerd
crictl config --set runtime-endpoint=unix:///run/containerd/containerd.sock
使用kubeadm config生成配置
kubeadm config print init-defaults > init.default.yaml
编辑init.default.yaml
advertiseAddress: 192.168.50.109
name: node
imageRepository: registry.aliyuncs.com/google_containers
kubernetesVersion: 1.26.9
podSubnet: 172.16.0.0/16
#列出kubeadm 所需的镜像
kubeadm config images list --config=init.default.yaml
下载镜像
kubeadm config images pull --config=init.default.yaml
初始化集群
kubeadm init --config=init.default.yaml
设置root用户加载k8s环境变量
export KUBECONFIG=/etc/kubernetes/admin.conf
删除控制平面上的污点,以便您可以在其上调度 Pod
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
获取 k8s 节点信息
kubectl get node
**注意:**此时STATUS is NotReady
kubectl get pod -A
Containerd导入离线镜像
获取命名空间
ctr namespace list
ctr -n k8s.io image import cni-v3.23.1.tar
ctr -n k8s.io image import kube-controllers-v3.23.1.tar
ctr -n k8s.io image import node-v3.23.1.tar
查看镜像
crictl image
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.25.2/manifests/calico.yaml
编辑calico.yaml
name: CALICO_IPV4POOL_CIDR
value: “172.16.0.0/16” #和 --pod-network=172.16.0.0/16 保持一致
同时,修改image,改为本地镜像
kubectl create -f calico.yaml
kubectl get node
**注意:**此时STATUS is Ready
kubectl get pod -A
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。