192.168.3.31 k8s-node-01
192.168.3.32 k8s-node-02
192.168.3.33 k8s-node-03
# systemctl stop firewalld && systemctl disable firewalld
# setenforce 0
# vim /etc/selinux/config
SELINUX=disabled
swapoff -a && sysctl -w vm.swappiness=0
sed '/swap/d' -i /etc/fstab
# cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
# setenforce 0
# yum install -y kubelet kubeadm kubectl docker
# systemctl enable kubelet && systemctl start kubelet
# systemctl enable docker && systemctl start docker
# cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
net.ipv4.tcp_tw_recycle=0
net.ipv4.tcp_tw_reuse=0
net.ipv4.ip_forward = 1
EOF
# sysctl --system
# docker info | grep -i cgroup
Cgroup Driver: systemd
# cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | grep "cgroup-driver"
Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=systemd"
systemd要一致
如果是cgroupfs
就要更改
# sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# kubeadm token create --print-join-command
kubeadm join --token d1fec5.68b3d6f59789a35c 192.168.3.11:6443 --discovery-token-ca-cert-hash sha256:f05dd2ea290eec10db6beab7f6d84116c9746bb58efb06f330b62
COPY後
# swapoff -a
# kubeadm join --token d1fec5.68b3d6f59789a35c 192.168.3.11:6443 --discovery-token-ca-cert-hash sha256:f05dd2ea290eec10db6beab7f6d84116c9746bb58efb06f330b62
# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master-01 Ready master 2h v1.11.1
k8s-master-02 Ready master 1h v1.11.1
k8s-master-03 Ready master 1h v1.11.1
k8s-node-01 Ready <none> 33s v1.11.1
ps. node加入master,大約要等30秒,請耐心等待
# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master-01 Ready master 2h v1.11.1
k8s-master-02 Ready master 1h v1.11.1
k8s-master-03 Ready master 1h v1.11.1
k8s-node-01 Ready <none> 2m v1.11.1
k8s-node-02 Ready <none> 1m v1.11.1
k8s-node-03 Ready <none> 40s v1.11.1