Kubernetes教程-节点配置安装

  

第三章 k8s的node节点配置

 

复制代码
设置系统主机名以及Host文件的相互解析
192.168.66.10#hostnamectl set-hostname k8s-master01
192.168.66.20#hostnamectl set-hostname k8s-node01
192.168.66.21#hostnamectl set-hostname k8s-node02

查看命令:
#hostname
192.168.66.10#vim /etc/hosts 192.168.66.10 k8s-master01 192.168.66.20 k8s-node01 192.168.66.21 k8s-node02 192.168.66.10#scp /etc/hosts root@k8s-node01:/etc/hosts 192.168.66.10#scp /etc/hosts root@k8s-node02:/etc/hosts 安装依赖包 yum install -y conntrack ntpdate ntp ipvsadm ipset jq iptables curl sysystat libseccomp wget vim net-tools git 设置防火墙为iptables并设置空规则 systemctl stop firewalld && systemctl disable firewalld yum -y install iptables-services && systemctl start iptables && systemctl enable iptables && iptables -F && service iptables save 关闭swap分区和swap永久内存,防止容器运行在虚拟内存里 swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab 关闭SELINUX setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
复制代码

 

 

 

 

 

复制代码
调整内核参数,对于k8s,每个机器都执行
cat > kubernetes.conf << EOF
net.bridge.bridge-nf-call-iptables=1   #必备,开启网桥模式
net.bridge.bridge-nf-call-ip6tables=1   #必备,开启网桥模式
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
vm.swappiness=0  #禁止使用swap空间,只有当系统00M时才允许使用他
vm.overcommit_memory=1  #不检查无理内存是否足够
vm.panic_on_oom=0   #开启00M
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   #必备,关闭ipv6模式
net.netfilter.nf_conntrack_max=2310720
EOF

cp kubernetes.conf /etc/sysctl.d/kubernetes.conf   #复制后开机会自动调用
sysctl -p /etc/sysctl.d/kubernetes.conf   #刷新一下立刻生效
复制代码

 

 

 

不用管下面的错误内容

 

 

 

复制代码
调整系统时区
设置系统时区为 中国/上海
timedatectl set-timezone Asia/Shanghai
将当前的UTC时间写入硬件时钟
timedatectl set-local-rtc 0
重启依赖于系统时间的服务
systemctl restart rsyslog
systemctl restart crond


关闭系统不需要服务,例如:邮件服务
systemctl stop postfix && systemctl disable postfix
复制代码

 

 

 

 

 

设置日志的保存方式,contos7默认有两个日志方案,
设置rsyslogd和systemd journald,只保留systemd journald一个日志方案
复制代码
mkdir /var/log/journal  #持久化保存日志目录
mkdir /etc/systemd/journald.conf.d
cat > /etc/systemd/journald.conf.d/99-prophet.conf << EOF
[Journal] 
# 持久化保存到磁盘
Storage=persistent

# 压缩历史日志
Compress=yes

SyncIntervalSec=5m
RateLimitInterval=30s
RateLimitBurst=1000


# 最大占用空间 10G
SystemMaxUse=10G


# 单日志文件最大 200M
SystemMaxFileSize=200M


# 日志保存时间 2 周
MaxRetentionSec=2week


# 不将日志转发到 syslog
ForwardToSyslog=no
EOF


复制代码

 

#systemctl restart systemd-journald

 

 

 

复制代码
升级系统内核为4.44

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
#安装完成后检查 /boot/grub2/grub.cfg 中对应内核 menuentry 中是否包含 initrd16 配置,如果没有,再安装一次!
yum --enablerepo=elrepo-kernel install -y kernel-lt
#设置开机从新内核启动
grub2-set-default "CentOS Linux (4.4.182-1.el7.elrepo.x86_64) 7 (Core)"
# 重启
reboot
# 重启之后,看一下
uname -r
复制代码

 

 

 

 

 reboot 重启之后,执行 uname -r

 

posted @   —八戒—  阅读(563)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2015-06-04 linux配置java环境变量(详细) [转]
2015-06-04 为什么要设置Java环境变量(详解)[转]
2015-06-04 win7 下配置 java 环境变量[转]
2015-06-04 linux centos下 安装jdk
点击右上角即可分享
微信分享提示