初始化安装k8s安装环境

1.修改主机名(分别操作)
hostnamectl set-hostname k8s-master01 && bash
hostnamectl set-hostname k8s-master02 && bash
hostnamectl set-hostname k8s-master03 && bash
hostnamectl set-hostname k8s-worker01 && bash
hostnamectl set-hostname k8s-worker02 && bash
hostnamectl set-hostname k8s-worker03 && bash

2.绑定hosts
cat >> /etc/hosts << EOF
172.31.24.96 k8s-master01
172.31.24.97 k8s-master02
172.31.24.98 k8s-master03
172.31.24.99 k8s-worker01
172.31.24.100 k8s-worker02
172.31.24.101 k8s-worker03
EOF

 

3.配置ssh免密钥
ssh-keygen

 

ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-master01
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-master01
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-master02
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-master02
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-worker01
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-worker02
ssh-copy-id -i /root/.ssh/id_rsa.pub root@k8s-worker03

 

4.修改机器内核参数
modprobe br_netfilter
echo "modprobe br_netfilter" >> /etc/profile

cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

sysctl -p /etc/sysctl.d/k8s.conf


5.关闭 firewalld 防火墙

systemctl stop firewalld
systemctl disable firewalld


6.关闭 selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
getenforce


7.配置阿里云的 repo 源

yum install -y wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


8.配置国内阿里云 docker 的 repo 源

yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

 

9.配置安装 k8s 组件需要的阿里云的 repo 源
cat > /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
EOF

10.配置时间同步
yum install ntpdate -y
ntpdate cn.pool.ntp.org

crontab -e
* */1 * * * /usr/sbin/ntpdate cn.pool.ntp.org

11.开启 ipvs
cat >/etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
ipvs_modules="ip_vs ip_vs_lc ip_vs_wlc ip_vs_rr ip_vs_wrr ip_vs_lblc ip_vs_lblcr ip_vs_dh ip_vs_sh ip_vs_nq ip_vs_sed ip_vs_ftp nf_conntrack"
for kernel_module in \${ipvs_modules}; do
/sbin/modinfo -F filename \${kernel_module} > /dev/null 2>&1
if [ 0 -eq 0 ]; then
/sbin/modprobe \${kernel_module}
fi
done
EOF

 

chmod 755 /etc/sysconfig/modules/ipvs.modules && bash


12.安装基础软件包

yum install -y yum-utils device-mapper-persistent-data lvm2 wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel python-devel epel-release openssh-server socat ipvsadm conntrack ntpdate telnet rsync

 

posted @   awks  阅读(84)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示