k8s的安装

史玉全 2022-8-18 229 8/18

需要先安装containerd

1.系统配置

cat > /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF

modprobe overlay
modprobe br_netfilter

cat <<EOF > /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 -p /etc/sysctl.d/k8s.conf

2.配置修改

cat > /etc/containerd/certs.d/docker.io/hosts.toml <<EOF
# server = "https://docker.io"
[host."https://frz7i079.mirror.aliyuncs.com"]
capabilities = ["pull","resolve"]
override_path = true
EOF

3.安装

yum install -y kubelet-1.24.2-0 kubeadm-1.24.2-0 kubectl-1.24.2-0 --disableexcludes=kubernetes

systemctl restart kubelet ; systemctl enable kubelet

4.master执行

kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=v1.24.2 --pod-network-cidr=10.244.0.0/16


 mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config


#修改calico.yaml
# 修改 CALICO_IPV4POOL_CIDR 的value为网段的值 网段为--pod-network-cidr的值
#如果需要修改网卡名称
  - name: IP_AUTODETECTION_METHOD
              value: "interface=ens32"



5.安装网络

#三台均需执行              
#导入镜像
nerdctl load -i calico-3.19-img.tar

#master执行

#创建pod
kubectl apply -f calico.yaml

其他命令

1.重新获取加入集群命令

kubeadm token create --print-join-command

2.重置节点

#有一个节点在主节点被删除后,需重置节点,重新加入集群
kubeadmin reset

3.集群中删除某个节点

 #将节点上的pod驱逐到其他节点
 kubectl drain  vms30.rhce.cc
 
 #删除节点
 kubectl delete nodes vms30.rhce.cc 

配置文件

calico.yaml

wget https://docs.projectcalico.org/manifests/calico.yaml

其他配置

#开启tab补全
source <(kubectl completion bash)
- THE END -
最后修改:2022年8月18日
0

非特殊说明,本博所有文章均为博主原创。