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

Posted 正在迷途

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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`

K8S二进制部署---双master和仪表盘_配置文件

K8S二进制部署---双master和仪表盘_配置文件_02

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

K8S二进制部署---双master和仪表盘_配置文件_04

修改配置文件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 \\ #修改
......

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

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

K8S二进制部署---双master和仪表盘_配置文件_07

 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

K8S二进制部署---双master和仪表盘_配置文件_08

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

K8S二进制部署---双master和仪表盘_配置文件_10

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

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

此时在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和仪表盘_nginx_12

2.修改nginx配置文件,配置四层反向代理负载均衡,指定k8s群集2台master的节点ip和6443端口

vim /etc/nginx/nginx.conf
events
worker_connections 1024;

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

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

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

server
listen 6443;
proxy_pass K8S——单master节点和基于单master节点的双master节点二进制部署

K8S——单master节点和基于单master节点的双master节点二进制部署(本机实验,防止卡顿,所以多master就不做3台了)

K8S——单master节点和基于单master节点的双master节点二进制部署(本机实验,防止卡顿,所以多master就不做3台了)

K8S二进制部署---单节点master

k8s多Master集群二进制部署

k8s多Master集群二进制部署