Day1-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 node1 10.20.60.21
pg60-22.k8s.host.com k8s node2 10.20.60.22
pg60-23.k8s.host.com k8s node3 10.20.60.23
pg60-200.k8s.host.com docker harbor 10.20.60.200

1.2 硬件环境#

  • 准备6台虚机环境
  • dns/nginx proxy 虚机配置不低于2c/4g/50g
  • k8s node 虚机配置不低于4c/8g/50g(运行容器资源的节点,配置越高越好)
  • docker harbor 虚机配置不低于2c/4g/50g

1.3 软件环境#

1.4 关闭 swap 分区#

关闭 swap 分区,否则kubelet 会启动失败(可以设置 kubelet 启动参数 --fail-swap-on 为 false 关闭 swap 检查):

Copy
shell> swapoff -a shell> sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

1.5 优化内核参数#

Copy
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:原因详见《Day1-1. kubernetes环境准备》中的 1.2 升级内核 说明
https://www.cnblogs.com/91donkey/p/13366373.html

Copy
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 变量#

Copy
shell> echo 'PATH=/opt/etcd/bin:/opt/kubernetes/server/bin/:$PATH' >> /root/.bashrc shell> source /root/.bashrc
posted @   龍龍小宝  阅读(107)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示
CONTENTS