欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

二进制安装k8s - 01. 服务器初始化

程序员文章站 2024-03-18 18:46:46
...

二进制安装k8s - 01. 服务器初始化

k8s 版本为 :v1.15.6

实验环境

这里最简单化。 一个master 一个node 一个etcd 无高可用
本次所有安装目录都在 /data 下面

192.168.100.59    master   etcd
192.168.100.60    node

最小化安装Centos7

直接安装最新的centos7 最小镜像即可

[[email protected] ~]# uname -a
Linux master 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

基本优化点

# 关闭 防火墙
systemctl stop firewalld
systemctl disable firewalld

# 关闭 SeLinux
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

# 关闭 swap
swapoff -a
yes | cp /etc/fstab /etc/fstab_bak
cat /etc/fstab_bak |grep -v swap > /etc/fstab

# yum epel源
yum install wget -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache

# 安装必备包
yum install -y vim wget lrzsz tree lsof rsync zip net-tools telnet 

# 时间同步 (我这装机时就默认开启了)
#yum -y install chrony
#systemctl start chronyd
#systemctl enable chronyd

# 配置 limits 
cat >> /etc/security/limits.conf << EOF
      *           soft   nofile       65535
      *           hard   nofile       65535
      *           soft   nproc        65535
      *           hard   nproc        65535
EOF

# 修改 /etc/sysctl.conf
cat << EOF >  /etc/sysctl.conf
vm.swappiness = 0
net.ipv4.neigh.default.gc_stale_time=120

net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce=2
net.ipv4.conf.all.arp_announce=2

net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

kernel.sysrq=1

net.ipv4.ip_forward = 1

EOF
sysctl -p
相关标签: k8s二进制