1、
PS:前提条件,需要安装docker
2、K8s优化
1.env
#--1.hosts
shell> cat >> /etc/hosts << EOF
192.168.8.10 k8s-master
192.168.8.11 k8s-node1
192.168.8.12 k8s-node2
EOF
#--2.firewall
shell> systemctl disable firewalld.service
#--3.iptables
shell> cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
shell> cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
shell> sudo sysctl --system
#--4.swap
shell>systemctl disable swap
#--5.docker
shell> cat <<EOF | sudo tee /etc/docker/daemon.json
{
"registry-mirrors": ["https://w60mq0zz.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
#--6.aliyun
shell> cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF