前言
一:k8s二进制方式多节点部署
- 要先部署单节点集群,可查阅博客https://blog.csdn.net/CN_TangZheng/article/details/105853689
1.1:环境介绍
-
下面拓扑图还有一个harbor仓库没有说明,到时候部署在单独的一台服务器上即可
-
-
主机分配
-
主机名 IP地址 资源分配 部署的服务 nginx01 192.168.233.128 2G+4CPU nginx、keepalived nginx02 192.168.233.129 2G+4CPU nginx、keepalived VIP 192.168.233.100 master 192.168.233.131 1G+2CPU apiserver、scheduler、controller-manager、etcd master02 192.168.233.130 1G+2CPU apiserver、scheduler、controller-manager node01 192.168.233.132 2G+4CPU kubelet、kube-proxy、docker、flannel、etcd node02 192.168.233.133 2G+4CPU kubelet、kube-proxy、docker、flannel、etcd
1.2:master02节点操作
-
开局优化
关闭防火墙,关闭核心防护,关闭网络管理功能(生成环境中一定要关闭它)
[root@localhost ~]# hostnamectl set-hostname master02 '//修改主机名' [root@localhost ~]# su [root@master02 ~]# [root@master02 ~]# systemctl stop firewalld && systemctl disable firewalld '//关闭防火墙' Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@master02 ~]# setenforce 0 && sed -i "s/SELINUX=enforcing/SELNIUX=disabled/g" /etc/selinux/config '//关闭核心防护' [root@master02 ~]# 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.
-
master节点操作,将master节点的kubernetes配置文件和启动脚本复制到master02节点
[root@master ~]# scp -r /opt/kubernetes/ root@192.168.233.130:/opt/ [root@master ~]# scp /usr/lib/systemd/system/{ kube-apiserver,kube-controller-manager,kube-scheduler}.service root@192.168.233.130:/usr/lib/systemd/system/
-
master02上修改apiserver配置文件中的IP地址
[root@master02 ~]# cd /opt/kubernetes/cfg/ [root@master02 cfg]# ls kube-apiserver kube-controller-manager kube-scheduler token.csv [root@master02 cfg]# vim kube-apiserver KUBE_APISERVER_OPTS="--logtostderr=true \ --v=4 \ --etcd-servers=https://192.