修改主机名
vim /etc/hostname
-> k8s-master
reboot
uname -n
添加主机名与IP对应关系(记得设置主机名)
vim /etc/hosts
123.57.31.168 ? ?k8s-master
关闭 swap
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
swapoff -a
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
firewall-cmd --state
将桥接的IPv4流量传递到 iptables 的链:
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
设置仓库
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
设置淘宝镜像
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装 Docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
sudo systemctl start docker
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker
添加 kubernetes 阿里云YUM软件源
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
将 SELinux 设置为 permissive 模式(相当于将其禁用)
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
yum update -y
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable --now kubelet
查看版本
kubectl version --client
|