master节点加入kubernetes单节点集群
2021-03-11 16:31
标签:0kb bin name pat vendor source password loaded 火墙 一、k8s单节点集群加入master节点 2.将master1上的工作目录复制到master2 3.复制启动脚本到master2 4.修改apiserver的ip地址,指向master2 5.开启apiserver服务 6.开启scheduler服务 7.开启controllet-manager服务 8.添加环境变量 最后我们验证一下是否成功 master节点加入kubernetes单节点集群 标签:0kb bin name pat vendor source password loaded 火墙 原文地址:https://blog.51cto.com/14557905/2492452
1.关闭防火墙和selinux服务[root@localhost ~]# setenforce 0
[root@localhost ~]# hostnamectl set-hostname master2
[root@localhost ~]# su
[root@master2 ~]# systemctl stop NetworkManager
[root@master2 ~]# 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.
[root@master2 ~]# sed -i ‘s/^SELINUX=.*/SELINUX=disabled/‘ /etc/selinux/config
[root@master2 ~]# iptables -F
[root@master2 ~]#
[root@master1 ~]# scp -r /k8s root@192.168.191.133:/k8s
[root@master2 k8s]# ls
bin cfg etcd ssl
[root@master1 ~]# scp /usr/lib/systemd/system/{kube-apiserver,kube-controller-manager,kube-scheduler}.service root@192.168.191.133:/usr/lib/systemd/system/
root@192.168.191.133‘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
[root@master1 cfg]# ls
kube-apiserver kube-controller-manager kube-scheduler token.csv
[root@master2 cfg]# vim kube-apiserver
--bind-address=192.168.191.133 --advertise-address=192.168.191.133 [root@master2 cfg]# vim kube-controller-manager
[root@master2 cfg]# vim kube-scheduler
[root@master2 cfg]# systemctl start kube-apiserver.service
[root@master2 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)
[root@master2 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
[root@master2 cfg]# systemctl start kube-scheduler.service
[root@master2 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.
[root@master2 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
[root@master2 cfg]# systemctl start kube-controller-manager.service
[root@master2 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.
[root@master2 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
[root@master2 cfg]# echo "PATH=$PATH:/k8s/bin/" >> /etc/profile
[root@master2 cfg]# source /etc/profile
[root@master2 cfg]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/k8s/bin/
[root@master2 cfg]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
192.168.191.131 Ready
文章标题:master节点加入kubernetes单节点集群
文章链接:http://soscw.com/index.php/essay/63284.html