k8s基础环境配置:基于CentOS7.9
0.虚拟机准备
wmware15安装centos7.9:https://www.cnblogs.com/uncleyong/p/15261742.html
1.配置静态ip
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | TYPE= "Ethernet" PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "none" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens33" UUID= "67760d22-eb54-4a07-9f48-c2306c51c5d3" DEVICE= "ens33" ONBOOT= "yes" IPADDR= "192.168.117.161" PREFIX= "24" GATEWAY= "192.168.117.2" DNS1= "192.168.117.2" IPV6_PRIVACY= "no" |
2.关闭防火墙
1 2 3 | systemctl disable --now firewalld systemctl disable --now dnsmasq systemctl disable --now NetworkManager |
3.关闭selinux
1 2 3 | setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config |
4.关闭交换分区
sed -ri '/^[^#]*swap/s@^@#@' /etc/fstab
5.修改yum源
1 | curl -o /etc/yum.repos.d/CentOS-Base.repo https: //mirrors.aliyun.com/repo/Centos-7.repo |
6.修改内核参数
1 2 3 4 5 6 7 8 9 | vim /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft nproc 65535 * hard nproc 655350 * soft memlock unlimited * hard memlock unlimited |
7.修改主机名
比如:hostnamectl set-hostname k8s-master01
8.配置hosts文件
vim /etc/hosts
1 2 3 4 5 6 7 | 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.117.161 k8s-master01 192.168.117.162 k8s-node01 192.168.117.163 k8s-node02 |
9.安装常用工具
yum -y install net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel python-devel epel-release openssh-server socat ipvsadm conntrack ntpdate yum-utils device-mapper-persistent-data lvm2
10.同步时间
1 2 3 4 5 6 7 8 9 10 11 12 13 | rpm -ivh http: //mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm yum install ntpdate -y ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo 'Asia/Shanghai' >/etc/timezone ntpdate time2.aliyun.com */5 * * * * /usr/sbin/ntpdate time2.aliyun.com systemctl restart crond |
11.升级系统及内核(4.x)
centos7.x默认内核是3.10
下载4.x的kernel-ml-deve和kernel-ml
1 2 | 安装: yum localinstall -y kernel-ml* |
更改内核启动顺序
1 2 | grub2- set - default 0&& grub2-mkconfig -o /etc/grub2.cfg grubby --args= "user_namespace.enable=1" --update-kernel= "$(grubby --default-kernel)" |
reboot重启后,查看内核是否为升级后的:uname -a
12.安装docker
添加docker需要的yum源:yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce-19.03.15* docker-ce-cli-19.03.15* -y
mkdir /etc/docker
cd /etc/docker
vim daemon.json
1 2 3 | { "exec-opts" : [ "native.cgroupdriver=systemd" ] } |
启动:systemctl daemon-reload && systemctl enable --now docker && systemctl status docker
虚拟机已经安装配置好(如需要vof虚拟机模板文件,请微信联系作者)
原文:https://www.cnblogs.com/uncleyong/p/15471002.html
__EOF__

关于博主:擅长性能、全链路、自动化、企业级自动化持续集成(DevTestOps)、测开等
面试必备:项目实战(性能、自动化)、简历笔试,https://www.cnblogs.com/uncleyong/p/15777706.html
测试提升:从测试小白到高级测试修炼之路,https://www.cnblogs.com/uncleyong/p/10530261.html
欢迎分享:如果您觉得文章对您有帮助,欢迎转载、分享,也可以点击文章右下角【推荐】一下!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
2019-10-27 【甩掉35岁焦虑症】2025了,你的竞争力在哪里?
2017-10-27 【转】Eclipse Memory Analyzer(MAT)使用