K8S二进制部署---双master和仪表盘

业无高卑志当坚,男儿有求安得闲?这篇文章主要讲述K8S二进制部署---双master和仪表盘相关的知识,希望能为你提供帮助。
??承接前文??
??https://blog.51cto.com/u_15382411/5143381?
一、master02 节点部署

//从 master01 节点上拷贝证书文件、各master组件的配置文件和服务管理文件到 master02 节点
scp -r /opt/etcd/ root@192.168.132.5:/opt/
scp -r /opt/kubernetes/ root@192.168.132.5:/opt
scp /usr/lib/systemd/system/kube-apiserver,kube-controller-manager,kube-scheduler.service root@192.168.132.5:/usr/lib/systemd/system/

cd
ls -A
scp -r .ssh/ 192.168.132.5:`pwd`
scp -r .kube/ 192.168.132.5:`pwd`





修改配置文件kube-apiserver中的IP
vim /opt/kubernetes/cfg/kube-apiserver
KUBE_APISERVER_OPTS="--logtostderr=true \\
--v=4 \\
--etcd-servers=https://192.168.80.10:2379,https://192.168.80.11:2379,https://192.168.80.12:2379 \\
--bind-address=192.168.132.5 \\#修改
--secure-port=6443 \\
--advertise-address=192.168.132.5 \\#修改
......
vim /opt/kubernetes/cfg/kube-apiserver
KUBE_APISERVER_OPTS="--logtostderr=true \\
--v=4 \\
--etcd-servers=https://192.168.80.10:2379,https://192.168.80.11:2379,https://192.168.80.12:2379 \\
--bind-address=192.168.132.5 \\#修改
--secure-port=6443 \\
--advertise-address=192.168.132.5 \\#修改
......




在 master02 节点上启动各服务并设置开机自启
systemctl start kube-apiserver.service
systemctl enable kube-apiserver.service
ps aux | grep apiserver

systemctl start kube-controller-manager.service
systemctl enable kube-controller-manager.service
ps aux | grep controller

systemctl start kube-scheduler.service
systemctl enable kube-scheduler.service
ps aux | grep scheduler




查看node节点状态
ln -s /opt/kubernetes/bin/* /usr/local/bin/
kubectl get nodes
kubectl get nodes -o wide#-o=wide:输出额外信息;对于Pod,将输出Pod所在的Node名


??此时在master02节点查到的node节点状态仅是从etcd查询到的信息,而此时node节点实际上并未与master02节点建立通信连接,因此需要使用一个VIP把node节点与master节点都关联起来???
?二、负载均衡部署  ???配置load balancer集群双机热备负载均衡(nginx实现负载均衡,keepalived实现双机热备)??
?1、在lb01、lb02节点上操作  ?
?1.配置nginx的官方在线yum源,配置本地nginx的yum源?
cat > /etc/yum.repos.d/nginx.repo < < EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
EOF

yum install nginx -y

【K8S二进制部署---双master和仪表盘】
2.修改nginx配置文件,配置四层反向代理负载均衡,指定k8s群集2台master的节点ip和6443端口
vim /etc/nginx/nginx.conf
events
worker_connections1024;

#添加
stream
log_formatmain$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent;

access_log/var/log/nginx/k8s-access.logmain;

upstream k8s-apiserver
server 192.168.132.50:6443;
server 192.168.132.5:6443;

server
listen 6443;
proxy_pass

    推荐阅读