ubuntu22.04 kubeadm安装k8s集群(从零到有)


前言

k8s 三master 三node所有节点hosts文件添加
192.168.220.110 master1
192.168.220.120 master2
192.168.220.130 master3
192.168.220.140 node1
192.168.220.150 node2
192.168.220.160 node3


一、初始化所有ubuntu服务器

# 切换用户
sudo su
echo "root:123456" | chpasswd

#修改root用户可登录
sed -i "s+#PermitRootLogin prohibit-password+PermitRootLogin yes+g" /etc/ssh/sshd_config  &&  systemctl restart sshd

#修改dns服务能访问外网
systemctl restart systemd-resolved.service 

sed -i  "/nameserver/i\nameserver 114.114.114.114" /etc/resolv.conf 
sed -i  "/nameserver 127.0.0.53/i\nameserver 114.114.114.114" /etc/resolv.conf 

##更新软件
apt update
apt upgrade


##安装docker.io docker-compose
apt install -y docker.io docker-compose

## docker daemon.json
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

systemctl  daemon-reload
#立即启用docker并开机自启
systemctl restart  docker 
systemctl enable docker 

#永久关闭swap
swapoff -a  
sed -ri 's/.*swap.*/#&/' /etc/fstab

#本地时区设置
timedatectl set-timezone Asia/Shanghai
timedatectl set-local-rtc 0

#取消进程数/连接数限制
-S :soft指定为给定的资源设置软极限。-H :hard
##临时
ulimit -SHn 65535

##永久
说明:* 代表针对所有用户,noproc 是代表最大进程数,nofile 是代表最大文件打开数
 cat << EOF >> /etc/security/limits.conf
* soft noproc 65535
* hard noproc 65535 
* soft nofile 65535 
* hard nofile 65535 
EOF

#允许 iptables 检查桥接流量
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF


cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
vm.swappiness = 0 # 禁止使用 swap 空间,只有当系统 0OM 时才允许使用它vm.overcommit memory=1 # 不检查物理内存是否够用
fs.inotify.max_user_instances = 8192
fs.inotify.max_user_watches = 1048576
fs.file-max = 52706963
fs.nr_open = 52706963
net.ipv6.conf.all.disable_ipv6 = 1
net.netfilter.nf_conntrack_max = 2310720
net.ipv4.ip_forward = 1
EOF

sysctl --system
sysctl -p /etc/sysctl
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@王先生1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值