一,前置准备,这里不做解释
安装:docker kubectl kubelet kubeadm
修改:docker仓库修改为国内
二、关闭swap和防火墙
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
systemctl disable firewalld && systemctl stop firewalld
三、如果需要用ipvs就开启模块
以下模块需要开启
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
检查有没有开启
cut -f1 -d " " /proc/modules | grep -e ip_vs -e nf_conntrack_ipv4
没有的话,使用以下命令加载
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
四、禁用selinux
setenforce 0
#修改/etc/sysconfig/selinux
SELINUX=disabled
五、ssh免密自行修改,添加全部主机到hosts
六、内核修改
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward=1
EOF
sysctl --system
七、这里做测试不再安装haproxy和keepalived
八、修改init-defaults
kubeadm config print init-defaults > init-k8s-m001.yaml
#k8s-m001 init-k8s-m001.yaml
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 0.0.0.0
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: k8s-m001
taints