-
设置域名映射
cat /etc/hosts
{IP} {HOSTNAMW} -
关闭防火墙
sudo systemctl disable firewalld --now
- 关闭selinux
#临时生效
sudo setenforce 0
# 永久生效
sed -ri 's/(SELINUX=).*/\1disabled/g' /etc/selinux/config
- 设置内核模块
cat > /etc/sysconfig/modules/ipvs.modules <<-EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
modprobe -- br_netfilter
modprobe -- ipip
EOF
# 生效ipvs模块
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules
# 验证
lsmod | grep -e ip_vs -e nf_conntrack -e br_netfilter
- 设置内核参数
cat > /etc/sysctl.d/kubernetes.conf << EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/kubernetes.conf
- 时间同步
yum install -y chrony
sed -ri 's/(server .* iburst)/# \1/g' /etc/chrony.conf
echo "server ntp.aliyun.com iburst" >> /etc/chrony.conf
systemctl restart chronyd
chronyc sources
- 关闭swap分区
#临时生效
swapoff -a
#永久生效,需要重启
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
- 安装docker
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce-18.09.9 -y
- 设置docker cgroupdriver
mkdir -p /etc/docker
vi /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors" : [
"https://ot2k4d59.mirror.aliyuncs.com/"
]
}
- 启动docker
systemctl enable docker --now
- 安装初始化kuebrnets集群相关命令
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
# master节点
yum install kubelet-1.18.18 kubeadm-1.18.18 kubectl-1.18.18
# node节点
yum install kubelet-1.18.18
- 初始化集群
kubeadm init --kubernetes-version=v1.18.18 --image-repository gcr.azk8s.cn/google_containers
标签:kubernetes,--,etc,yum,docker,k8s,com
From: https://www.cnblogs.com/xiaodunan/p/17503572.html