2-1 准备kubernetes集群环境
作者:互联网
1.1 基础架构
主机名 | 角色 | IP地址 |
---|---|---|
pg60-11.k8s.host.com | dns/nginx proxy | 10.20.60.11 |
pg60-12.k8s.host.com | dns/nginx proxy | 10.20.60.12 |
pg60-21.k8s.host.com | k8s master node1 | 10.20.60.21 |
pg60-22.k8s.host.com | k8s master node2 | 10.20.60.22 |
pg60-23.k8s.host.com | k8s master node3 | 10.20.60.23 |
pg60-23.k8s.host.com | k8s worker node1 | 10.20.60.31 |
pg60-23.k8s.host.com | k8s worker node2 | 10.20.60.32 |
pg60-23.k8s.host.com | k8s worker node3 | 10.20.60.33 |
pg60-200.k8s.host.com | docker harbor | 10.20.60.200 |
1.2 硬件环境
- 准备9台虚机环境
- dns/nginx proxy 虚机配置不低于2c/4g/50g
- k8s master node 虚机配置不低于2c/4g/50g
- k8s worker node 虚机配置不低于4c/8g/50g(运行容器资源的节点,配置越高越好)
- docker harbor 虚机配置不低于2c/4g/50g
1.3 软件环境
- OS:CentOS Linux release 7.7.1908 (Core)
- BASE源:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- EPEL源:wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
1.4 关闭 swap 分区
关闭 swap 分区,否则kubelet 会启动失败(可以设置 kubelet 启动参数 --fail-swap-on 为 false 关闭 swap 检查):
shell> swapoff -a
shell> sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
1.5 优化内核参数
shell> cat > /etc/sysctl.d/kubernetes.conf << EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
# 关闭 tcp_tw_recycle,否则与 NAT 冲突,可能导致服务不通;
net.ipv4.tcp_tw_recycle=0
net.ipv4.neigh.default.gc_thresh1=1024
net.ipv4.neigh.default.gc_thresh1=2048
net.ipv4.neigh.default.gc_thresh1=4096
vm.swappiness=0
vm.overcommit_memory=1
vm.panic_on_oom=0
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
EOF
shell> modprobe br_netfilter
shell> modprobe nf_conntrack
shell> sysctl -p /etc/sysctl.d/kubernetes.conf
1.6 升级内核
PS:原因详见《Docker容器入门基础》篇第一章节《1. Docker环境准备》中的 1.2 升级内核
说明
https://www.cnblogs.com/91donkey/p/13129574.html
shell> rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
shell> yum --enablerepo=elrepo-kernel install -y kernel-lt
# 设置开机从新内核启动
shell> grub2-set-default 0
shell> reboot
1.7 更新 PATH 变量
shell> echo 'PATH=/opt/etcd/bin:/opt/kubernetes/server/bin/:$PATH' >> /root/.bashrc
shell> source /root/.bashrc
标签:10.20,shell,kubernetes,环境,pg60,host,集群,k8s,com 来源: https://www.cnblogs.com/91donkey/p/12838617.html