k8s基础环境配置:基于CentOS7.9
0.虚拟机准备
wmware15安装centos7.9:https://www.cnblogs.com/uncleyong/p/15261742.html
1.配置静态ip
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.关闭防火墙
systemctl disable --now firewalld systemctl disable --now dnsmasq systemctl disable --now NetworkManager
3.关闭selinux
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源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
6.修改内核参数
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
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.同步时间
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
安装: yum localinstall -y kernel-ml*
更改内核启动顺序
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
{ "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
欢迎分享:如果您觉得文章对您有帮助,欢迎转载、分享,也可以点击文章右下角【推荐】一下!