我是靠谱客的博主 寂寞西牛,最近开发中收集的这篇文章主要介绍k8s 1.25.4部署,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一:安装前期准备。可在单独一台机器上设置好以后再克隆镜像。

yum
install -y vim
#配置
cat >> /etc/hosts <<EOF
172.16.13.100 k8s-master
172.16.13.101 k8s-node01
172.16.13.102 k8s-node02
172.16.13.103 k8s-node03
EOF
# 2 设置iptables规则
iptables -P FORWARD ACCEPT
swapoff -a
sed -i '/ swap / s/^(.*)$/#1/g' /etc/fstab
sed -ri 's#(SELINUX=).*#1disabled#' /etc/selinux/config
setenforce 0
systemctl disable firewalld && systemctl stop firewalld
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
vm.max_map_count=262144
EOF
modprobe br_netfilter
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf
curl -o /etc/yum.repos.d/Centos-7.repo
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kuberne
tes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yumkey.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpmpackage-key.gpg
EOF
yum clean all && yum makecache
yum clean all && yum makecache
vim /etc/yum.repos.d/docker-ce.repo
yum clean all && yum makecache
ls
cd /opt/
ls
curl -o repo.repo /etc/yum.repos.d/docker-ce.repo
ls
curl -o ./4repo.repo /etc/yum.repos.d/docker-ce.repo
curl -o ./4repo.repo http://mirrors.aliyun.com/docker-ce/linux/centos/dockerce.repo
vim /etc/yum.repos.d/docker-ce.repo
yum clean all && yum makecache
vim /etc/yum.repos.d/docker-ce.repo
rm -f /etc/yum.repos.d/docker-ce.repo
yum clean all && yum makecache
vim /etc/yum.repos.d/kubernetes.repo
yum clean all && yum makecache
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/dockerce.repo
yum clean all && yum makecache
#坑一:docker版本问题
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.0/cri-dockerd-0.3.0.amd64.tgz
tar xf cri-dockerd-0.3.0.amd64.tgz
cp cri-dockerd/cri-dockerd /usr/bin/
chmod +x /usr/bin/cri-dockerd
docker login --username=XXX registry.cn-shenzhen.aliyuncs.com
passwd======xxx
cat > /etc/sysconfig/modules/ipvs.modules << EOF
#! /bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF

k8s初始化master节点

yum install -y --setopt=obsoletes=0 kubeadm-1.25.4 kubelet-1.25.4 kubectl-1.25.4 #指定版本。最新版的1.26翻车了。failed to run Kubelet: validate service connection: CRI v1 runtime API is not implet: validate service connection: CRI v1 runtime API is not implemented for endpoint "unix:///var/run/cri-dockerd.sock": rpplemented for endpoint "unix:///var/run/cri-dockerd.sock": rpc error: code = Unimplemented desc = unknown service runtime.vpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService"捣鼓了一下午。没捣鼓成。能力有限。下次吧
kubeadm config images list

#4、修改cgroup方式
>/etc/docker/daemon.json
cat > /etc/docker/daemon.json << EOF
{
"exec-opts":["native.cgroupdriver=systemd"]
}
EOF
#3、启动docker服务
systemctl restart docker
docker version
######################################
#
3、cri-dockerddocker安装
#
######################################
#1、上传安装包并解压
#
#2、配置启动文件,执行如下命令
cat > /usr/lib/systemd/system/cri-docker.service << EOF
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket
[Service]
Type=notify
ExecStart=/usr/bin/cri-dockerd --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.7
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
#3、生成socket文件,执行如下命令
cat > /usr/lib/systemd/system/cri-docker.socket <<EOF
[Unit]
Description=CRI Docker Socket for the API
PartOf=cri-docker.service
[Socket]
ListenStream=%t/cri-dockerd.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
EOF
#4、启动cri-docker并设置开机启动
systemctl daemon-reload
systemctl enable cri-docker --now
systemctl is-active cri-docker
######################################
#
4、k8s三大组件安装
#
######################################
#1、添加阿里云 yum源
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=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
#2、安装三大件
yum install -y --setopt=obsoletes=0 kubeadm-1.25.4 kubelet-1.25.4
kubeadm version
systemctl enable kubelet
#3、修改初始化系统管理器
cat > /etc/sysconfig/kubelet << EOF
KUBELET_EXTRA_ARGS="--cgroup-driver=systemd"
EOF
cat > /etc/sysconfig/kubelet << EOF
KUBELET_EXTRA_ARGS="--cgroup-driver=systemd"
EOF

master节点初始化

kubeadm init 
--apiserver-advertise-address=172.16.13.100 
--image-repository registry.aliyuncs.com/google_containers 
--kubernetes-version v1.25.4 
--service-cidr=10.96.0.0/12 
--pod-network-cidr=10.244.0.0/16 
--cri-socket unix:///var/run/cri-dockerd.sock 
--ignore-preflight-errors=all
--exec-opt native.cgroupdriver=systemd
注意版本:目前1.25.4可以正常安装。1.26不行。failed to run Kubelet: validate service connection: CRI v1 runtime API is not implet: validate service connection: CRI v1 runtime API is not implemented for endpoint "unix:///var/run/cri-dockerd.sock": rpplemented for endpoint "unix:///var/run/cri-dockerd.sock": rpc error: code = Unimplemented desc = unknown service runtime.vpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService"

节点初始化加入集群。

kubeadm join 172.16.13.100:6443 --token o8bu0b.42xg3bine96o98fd --discovery-token-ca-cert-hash sha256:26745e1c88d14bbe6b0c3160e81447bb622a8eea191b02e7cd71d0948f4aedc6 --cri-socket=unix:///var/run/cri-dockerd.sock

最后

以上就是寂寞西牛为你收集整理的k8s 1.25.4部署的全部内容,希望文章能够帮你解决k8s 1.25.4部署所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(246)

评论列表共有 0 条评论

立即
投稿
返回
顶部