跳转到主要内容

安装k8s 1.28.0

k8s 从1.24之后移除了dokcer直接支持,安装方式与1.24.0以前有不一样的地方

  • 下载安装文件


# 三个主文件

wget qq829.cn/uploads/software/k8s/v1.28.0/kubectl wget qq829.cn/uploads/software/k8s/v1.28.0/kubelet wget qq829.cn/uploads/software/k8s/v1.28.0/kubeadm # docker-compose wget qq829.cn/uploads/software/k8s/docker-compose # 两个插件 wget qq829.cn/uploads/software/k8s/v1.28.0/cri-dockerd-0.3.4-3.el7.x86_64.rpm

wget qq829.cn/uploads/software/k8s/v1.28.0/crictl-v1.28.0-linux-amd64.tar.gz # 服务配置文件 wget qq829.cn/uploads/software/k8s/v1.28.0/10-kubeadm.conf wget qq829.cn/uploads/software/k8s/v1.28.0/kubelet.service # 插件 wget qq829.cn/uploads/software/k8s/v1.28.15/calico.yaml wget qq829.cn/uploads/software/k8s/v1.28.15/traefik-ingress.tar wget qq829.cn/uploads/software/k8s/v1.28.15/nfs-storage.tar # 安装 socat conntrack 依赖软件 yum install -y socat yum install -y conntrack # 复制三个主文件到目录 cp kubectl kubelet kubeadm /usr/local/bin/ # 安装插件 yum install cri-dockerd-0.3.4-3.el7.x86_64.rpm # 修改cri-docker服务配置 # vi /usr/lib/systemd/system/cri-docker.service # 修改cri-docker配置文件,在后面增加参数,告诉告诉docker使用 pause镜像与版本 # --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.9 systemctl enable cri-docker systemctl restart cri-docker # 复制circtl到目录 tar -xvzf crictl-v1.28.0-linux-amd64.tar.gz cp crictl /usr/local/bin # 安装kubelet服务,开启服务自启动 # 需要注意 服务文件里面的执行路径, cp kubelet.service /usr/lib/systemd/system/kubelet.service mkdir -p /etc/systemd/system/kubelet.service.d cp 10-kubeadm.conf /etc/systemd/system/kubelet.service.d # 设置kubelet 开机启动服务 # 此时会显示一堆错误,这是正常的 systemctl enable kubelet.service systemctl status kubelet
  • 安装



# 部署KUBE-VIP 便于后期扩展,如果不想部署KUBE-VIP,可以直接使用主机名

docker run --network host --rm swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/kube-vip:v0.6.0 manifest pod --interface=eth0 --vip 172.18.41.242  --controlplane --services  --arp  --leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml



# 初始化集群


kubeadm init --control-plane-endpoint "kube-api-server:6443" --image-repository registry.aliyuncs.com/google_containers --upload-certs --kubernetes-version v1.28.0   --pod-network-cidr 10.244.0.0/16 --cri-socket unix:///var/run/cri-dockerd.sock --v  5

# 重置集群


kubeadm reset --cri-socket unix:///var/run/cri-dockerd.sock
 


# 安装网络插件