惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

M
MIT News - Artificial intelligence
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
博客园 - Franky
腾讯CDC
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
V
V2EX
N
Netflix TechBlog - Medium
量子位
Jina AI
Jina AI
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
爱范儿
爱范儿
博客园 - 叶小钗
D
Docker
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss

运维开发绿皮书

OBS虚拟摄像头重命名 Ubuntu备份为LiveOS 使用Powershell卸载windows默认程序 Cisco路由器OSPF配置 汽车的分类和特点 Windows11跳过TPM2.0 HTTPS 双向认证与 USB 加密锁配置实战 SSL 证书工具 字数统计 BMI 计算 颜色转换 Hash 生成器 JSON 格式化 JWT 解码 房贷计算 时间戳转换 URL 编码 UUID 生成 牛马时钟 二维码批量生成器 CKS Simulator Kubernetes 1.25 FRP TOTP验证码生成器 direct-ssh-passthrough-nat 脚本使用说明 Python软件授权 Linux命令行百度网盘 为 Containerd 配置 Harbor 无证书镜像站 Docker一键部署Meta和MetacubexD面板 必应搜索屏蔽垃圾网站 VMware的ubuntu完整安装vm-tools支持粘贴板
UOS(1070a)服务器版本部署Kubernetes1.28
Paper-Dragon · 2024-12-26 · via 运维开发绿皮书

UOS(1070a)服务器版本部署Kubernetes1.28

UOS 系统基于 CentOS 8 深度定制,虽可沿用 CentOS 8 的软件源,但 CentOS 8 已终止技术支持,可选的安全软件包极为有限,这无疑增加了 Kubernetes 1.28 部署过程的难度。

根据下面的步骤可以成功部署kuberntes集群

组件部署

普通组件

yum install wget jq psmisc vim net-tools telnet yum-utils device-mapper-persistent-data lvm2 git -y

基础组件

yum install conntrack iproute-tc -y

ipvs

yum install ipvsadm ipset sysstat libseccomp -y

基础优化

内核限制优化

ulimit -SHn 65535


cat <<EOF >> /etc/security/limits.conf
# Add custom limits for all users
* soft nofile 65536
* hard nofile 131072
* soft nproc 65535
* hard nproc 65535
* soft memlock unlimited
* hard memlock unlimited
EOF

使用如下命令查看生效情况

内核模块

开机自动加载

cat << EOF >> /etc/modules-load.d/ipvs.conf 
ip_vs
ip_vs_lc
ip_vs_wlc
ip_vs_rr
ip_vs_wrr
ip_vs_lblc
ip_vs_lblcr
ip_vs_dh
ip_vs_sh
ip_vs_fo
ip_vs_nq
ip_vs_sed
ip_vs_ftp
ip_vs_sh
nf_conntrack
ip_tables
ip_set
xt_set
ipt_set
ipt_rpfilter
ipt_REJECT
ipip
overlay
br_netfilter
EOF

重新加载模块

systemctl restart systemd-modules-load.service

内核参数优化

cri和网络专项优化

cat <<EOF > /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
fs.may_detach_mounts = 1
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_watches=89100
fs.file-max=52706963
fs.nr_open=52706963
net.netfilter.nf_conntrack_max=2310720

net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl =15
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 327680
net.ipv4.tcp_orphan_retries = 3
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.ip_conntrack_max = 65536
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_timestamps = 0
net.core.somaxconn = 16384
EOF
sysctl --system
# 如果不生效,需要检查sysctl.conf里面是否有冲突的内核配置

安装containerd

版本必须大于1.6否则会报错OCI有问题

因为默认使用了4.19版本内核找不到匹配的包,请使用命令直接安装3.1内核版本,已测试功能兼容,可以正常工作。

yum install https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/8Server/x86_64/stable/Packages/containerd.io-1.6.9-3.1.el8.x86_64.rpm

生成默认配置,并更改参数

containerd config default > /etc/containerd/config.toml

# 修改Cgroup为true
SystemdCgroup = true

# 修改pause为 registry.aliyuncs.com/google_containers/pause:3.9 ,请使用较新的3.9版本。
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"

systemctl daemon-reload && systemctl restart containerd

配置containerd管理工具(可选)

/etc/crictl.yaml

runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false

安装kubernetes

镜像源

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[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

安装组件

最新就是1.28 不用锁定版本

yum install kubeadm kubelet kubectl
systemctl enable kubelet

安装主要组件

kubeadm config print init-defaults > /root/kubeadm.yml

修改关键参数

...
镜像源: registry.aliyuncs.com/google_containers/
api地址: aa.bb.cc.dd
node名字: master?

拉取默认镜像减少出错概率

kubeadm config images pull --config /root/kubeadm.yml

初始化

kubeadm init --config /root/kubeadm.yml

复制集群凭证

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

其他节点加入集群

kubeadm join 192.168.122.10:6443 --token abcdef.0123456789abcdef \
        --discovery-token-ca-cert-hash sha256:1111c01dff5e4f70xxxxxxxx2b28117487ebe5

修改缺失的选项

这里是为了兼容flannel网络插件做的更改

controller 需要修改

--cluster-cidr=10.244.0.0/16 \
--allocate-node-cidrs=true

kube-proxy需要修改

clusterCIDR: 10.244.0.0/16

安装网络插件

这个版本的系统calico是不用想了,实测calico 1.30、1.29、1.28版本都不可能安装。选择flannel的vxlan模式安装

关联项目 https://github.com/flannel-io/flannel

wget https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

注意点

If you use custom podCIDR (not 10.244.0.0/16) you first need to download the above manifest and modify the network to match your one.

部署

kubectl apply -f flannel.yaml
reboot