iT邦幫忙

0

四、K8S node加入master

DK 2018-08-22 15:40:427688 瀏覽

192.168.3.31 k8s-node-01
192.168.3.32 k8s-node-02
192.168.3.33 k8s-node-03

安裝(3台node都要裝 kubelet、kubeadm、kubectl docker)

開始佈署叢集前確保關閉firewall及selinux

# systemctl stop firewalld && systemctl disable firewalld
# setenforce 0
# vim /etc/selinux/config
SELINUX=disabled

k8s要求關閉swap

swapoff -a && sysctl -w vm.swappiness=0
sed '/swap/d' -i /etc/fstab

安裝 Kubernetes

# 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小問題(請確認清楚)

# 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

先到 192.168.3.11 k8s-master-01

# kubeadm token create --print-join-command
kubeadm join --token d1fec5.68b3d6f59789a35c 192.168.3.11:6443 --discovery-token-ca-cert-hash sha256:f05dd2ea290eec10db6beab7f6d84116c9746bb58efb06f330b62

COPY後

再到 192.168.3.31 k8s-node-01 貼上

# swapoff -a
# kubeadm join --token d1fec5.68b3d6f59789a35c 192.168.3.11:6443 --discovery-token-ca-cert-hash sha256:f05dd2ea290eec10db6beab7f6d84116c9746bb58efb06f330b62

回到 192.168.3.11 k8s-master-01

# 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秒,請耐心等待

k8s-node-02、k8s-node-03跟k8s-master-01的步驟一樣

# 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

END


尚未有邦友留言

立即登入留言