master节点加入kubernetes单节点集群
master节点加入kubernetes单节点集群
一、k8s单节点集群加入master节点
1.关闭防火墙和selinux服务
[ ~]# setenforce 0 [ ~]# hostnamectl set-hostname master2 [ ~]# su [ ~]# systemctl stop NetworkManager [ ~]# systemctl disable NetworkManager Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service. Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service. [ ~]# sed -i ‘s/^SELINUX=.*/SELINUX=disabled/‘ /etc/selinux/config [ ~]# iptables -F [ ~]#
2.将master1上的工作目录复制到master2
[ ~]# scp -r /k8s :/k8s [ k8s]# ls bin cfg etcd ssl
3.复制启动脚本到master2
[ ~]# scp /usr/lib/systemd/system/{kube-apiserver,kube-controller-manager,kube-scheduler}.service :/usr/lib/systemd/system/ ‘s password: kube-apiserver.service 100% 260 102.1KB/s 00:00 kube-controller-manager.service 100% 295 46.0KB/s 00:00 kube-scheduler.service 100% 259 88.8KB/s 00:00
4.修改apiserver的ip地址,指向master2
[ cfg]# ls kube-apiserver kube-controller-manager kube-scheduler token.csv [ cfg]# vim kube-apiserver --bind-address=192.168.191.133 --advertise-address=192.168.191.133 [ cfg]# vim kube-controller-manager [ cfg]# vim kube-scheduler
5.开启apiserver服务
[ cfg]# systemctl start kube-apiserver.service [ cfg]# systemctl status kube-apiserver.service ● kube-apiserver.service - Kubernetes API Server Loaded: loaded (/usr/lib/systemd/system/kube-apiserver.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2020-05-03 11:25:45 CST; 4s ago Docs: https://github.com/kubernetes/kubernetes Main PID: 21187 (kube-apiserver) [ cfg]# systemctl enable kube-apiserver.service Created symlink from /etc/systemd/system/multi-user.target.wants/kube-apiserver.service to /usr/lib/systemd/system/kube-apiserver.service
6.开启scheduler服务
[ cfg]# systemctl start kube-scheduler.service [ cfg]# systemctl enable kube-scheduler.service Created symlink from /etc/systemd/system/multi-user.target.wants/kube-scheduler.service to /usr/lib/systemd/system/kube-scheduler.service. [ cfg]# systemctl status kube-scheduler.service ● kube-scheduler.service - Kubernetes Scheduler Loaded: loaded (/usr/lib/systemd/system/kube-scheduler.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2020-05-03 11:27:36 CST; 12s ago
7.开启controllet-manager服务
[ cfg]# systemctl start kube-controller-manager.service [ cfg]# systemctl enable kube-controller-manager.service Created symlink from /etc/systemd/system/multi-user.target.wants/kube-controller-manager.service to /usr/lib/systemd/system/kube-controller-manager.service. [ cfg]# systemctl status kube-controller-manager.service ● kube-controller-manager.service - Kubernetes Controller Manager Loaded: loaded (/usr/lib/systemd/system/kube-controller-manager.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2020-05-03 11:30:32 CST; 12s ago
8.添加环境变量
[ cfg]# echo "PATH=$PATH:/k8s/bin/" >> /etc/profile [ cfg]# source /etc/profile [ cfg]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/k8s/bin/
最后我们验证一下是否成功
[ cfg]# kubectl get nodes NAME STATUS ROLES AGE VERSION 192.168.191.131 Ready <none> 2d5h v1.12.3 192.168.191.132 Ready <none> 2d5h v1.12.3