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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。