前置说明: 1.192.168.214.50 是k8s master的ip 地址 2.192.168.214.123为新增节点机的ip 地址 3.节点机需要安装的组件有:docker,flannel,kubelet,kube-proxy
一、在节点机上安装docker-ce 1、先关闭防火墙systemctl stop firewalld.service&&systemctl disable firewalld.service
2、安装yum install -y docker-ce
3、拷贝master 50机上的/opt/test/service/* 到新节点机的/usr/lib/systemd/system/下
4、systemctl restart docker.service&&systemctl enable docker.service
二、在节点机上安装flannelyum install flannel -yyum install -y socat fuse fuse-libs nfs-utils nfs-utils-lib pciutils ebtables ethtoolsed -i '/net.bridge.bridge-nf-call-iptables/d' /usr/lib/sysctl.d/00-system.confsed -i '/net.bridge.bridge-nf-call-ip6tables/d' /usr/lib/sysctl.d/00-system.confsed -i 'a net.bridge.bridge-nf-call-iptables = 1' /usr/lib/sysctl.d/00-system.confsed -i 'a net.bridge.bridge-nf-call-ip6tables = 1' /usr/lib/sysctl.d/00-system.confsysctl --system[ -f /proc/sys/fs/may_detach_mounts ] && sed -i "/fs.may_detach_mounts/ d" /etc/sysctl.conf[ -f /proc/sys/fs/may_detach_mounts ] && echo "fs.may_detach_mounts=1" >> /etc/sysctl.confsysctl -p vim /etc/sysconfig/flanneld //做如下配置的修改【FLANNEL_ETCD_ENDPOINTS="http://192.168.214.50:2379" #配置etcd 的ip:port FLANNEL_ETCD_PREFIX="/kube-centos/network"】touch /run/flannel/docker #不存在时,创建此文件后会自动写入内容[root@localhost ~]# more /run/flannel/dockerDOCKER_OPT_BIP="--bip=172.50.80.1/24"DOCKER_OPT_IPMASQ="--ip-masq=true"DOCKER_OPT_MTU="--mtu=1450"DOCKER_NETWORK_OPTIONS=" --bip=172.50.80.1/24 --ip-masq=true --mtu=1450"启动Flannelsystemctl start flanneld.servicesystemctl enable flanneld.service三、在节点机上安装kubelet及kube-proxy1、拷贝master 50机上的/opt/test/bin/* 到新节点机的/opt/kubernetes/bin/下,没有可以新建目录
2、拷贝master 50机上的/opt/test/bin/kubernetes-ssl.tar.gz 到新节点机的/etc/下 tar -xzvf kubernetes-ssl.tar.gz解压
3、修改vi /usr/lib/systemd/system/kubelet.service文件--address=192.168.214.123和--hostname-override=192.168.214.123地址为新节点机ip地址
4、修改vi /usr/lib/systemd/system/kube-proxy.service文件--bind-address=192.168.214.123和--hostname-override=192.168.214.123地址为新节点机ip地址
5、mkdir -p /var/lib/kubelet&&mkdir -p /var/lib/kube-proxy新建目录
6、systemctl restart kubelet.service&&systemctl enable kubelet.service启动kubelet
7、systemctl restart kube-proxy.service&&systemctl enable kube-proxy.service启动kube-proxy 四、在master管理机上检查node状态 1、master 50上kubectl get nodes查看新节点机是否加入集群且Ready状态 五、注意事项: 1.如果node加到集群是notready状态时,看下node上的kubelet服务是否有如下报错,如果有就reboot重启node就好了 kubelet_node_status.go:682] Node became not ready: {Type:Ready Status:False LastHeartbeatTime:2018-12-13 12:44:06.85329074 +0800 CST LastTransitionTime:2018-12-13 12:44:06.85329074 +0800 CST Reason:KubeletNotReady Message:Failed to start ContainerManager failed to initialise top level QOS containers: failed to create top level Burstable QOS cgroup : Unit kubepods-burstable.slice already exists.,container runtime is down}
2.节点机如果一直是notReady 状态,报错内容是: Failed to start ContainerManager failed to initialise top level QOS containers: root container /kubepods doesn't exist 需要重启节点,即可状态正常,如下截图所示: