Ubuntu22.04部署k8s集群常见问题

基本流程参考这个博客:
https://www.cnblogs.com/way2backend/p/16970506.html

踩坑

1.k8s新版默认用的是cri是containerd,镜像管理用crictl,所以下载完镜像不在docker里

通过这个命令查看

sudo crictl images

2.即便指定了–image-repository=registry.aliyuncs.com/google_containers pasue这个镜像还是会走k8s.gcr.io/pause:3.6

解决方法就是

# 拉取3.6版本,k8s不用3.9版本
crictl pull registry.aliyuncs.com/google_containers/pause:3.6
ctr -n k8s.io i tag registry.aliyuncs.com/google_containers/pause:3.6 k8s.gcr.io/pause:3.6

3.init时最好指定主机可以连接的地址且地址尽量不重复

kubeadm init \
--apiserver-advertise-address=10.243.1.1 \	# master主机地址
--control-plane-endpoint=10.243.1.1 \	# master主机地址
--image-repository registry.aliyuncs.com/google_containers \
--service-cidr=10.96.0.0/16 \	# 可以不指定
--pod-network-cidr=10.244.0.0/16	#pod集群地址,不要和本机地址冲突

4.我踩过的最大的坑就是网络插件只安装在master节点就可以了,以calico为例

# 获取calico配置
 curl https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/calico.yaml -O
#修改配置
在这个注释下边加上这个,value就是kubeadm init初始化时指定的--pod-network-cidr
# The default IPv4 pool to create on startup if none exists. Pod IPs will be
# chosen from this range. Changing this value after installation will have
# no effect. This should fall within `--cluster-cidr`.
- name: CALICO_IPV4POOL_CIDR
  value: "10.244.0.0/16"
 # Cluster type to identify the deployment type
 #- name: CLUSTER_TYPE
 #  value: "k8s,bgp"
 在这里加上下面这个,否则会发现节点处于running但是不ready的状态,查看日志会发现如下错误
 unable to connect to BIRDv4 socket: dial unix /var/run/bird/bird.ctl: connect: no such file or directory

 - name: IP_AUTODETECTION_METHOD
   value: "interface=ztr4n7kwlx"


kubectl delete -f calico.yaml
kubectl apply -f calico.yaml

你可能感兴趣的:(kubernetes,docker,容器,calico,ubuntu)