如何在kubernetes中配置Master02

这篇文章为大家分享有关在kubernetes中配置Master02的方法。文章涵盖Master02的配置和使用方法,希望大家通过这篇文章能有所收获。

创新互联建站专注于成都做网站、网站制作、网页设计、网站制作、网站开发。公司秉持“客户至上,用心服务”的宗旨,从客户的利益和观点出发,让客户在网络营销中找到自己的驻足之地。尊重和关怀每一位客户,用严谨的态度对待客户,用专业的服务创造价值,成为客户值得信赖的朋友,为客户解除后顾之忧。

服务器角色分配

角色地址安装组件
master192.168.142.220kube-apiserver kube-controller-manager kube-scheduler etcd
master02192.168.142.120kube-apiserver kube-controller-manager kube-scheduler
node1192.168.142.136kubelet kube-proxy docker flannel etcd
node2192.168.142.132kubelet kube-proxy docker flannel etcd
nginx1192.168.142.130nginx keepalived
nginx2192.168.142.140nginx keepalived

一、Master02配置

分隔符前的操作均在master01上进行

复制目录到master02

复制kubernetes目录到master02

[root@master k8s]# scp -r /opt/kubernetes/ root@192.168.142.120:/opt

复制etcd目录到master02

master02一定要有etcd证书,否则apiserver服务无法启动

[root@master k8s]# scp -r /opt/etcd/ root@192.168.142.120:/opt

复制服务启动脚本

kube-apiserver.service kube-controller-manager.service kube-scheduler.service

[root@master k8s]# scp /usr/lib/systemd/system/{kube-apiserver,kube-controller-manager,kube-scheduler}.service root@192.168.142.120:/usr/lib/systemd/system/

修改服务脚本

实际上仅需要修改apiserver即可

[root@master02 k8s]# cd /opt/kubernetes/cfg/
[root@master02 cfg]# vim kube-apiserver
KUBE_APISERVER_OPTS="--logtostderr=true \
--v=4 \
--etcd-servers=https://192.168.142.220:2379,https://192.168.142.136:2379,https://192.168.142.132:2379 \
#注意地址更改
--bind-address=192.168.142.120 \
--secure-port=6443 \
#注意地址更改
--advertise-address=192.168.142.120 \
--allow-privileged=true \
--service-cluster-ip-range=10.0.0.0/24 \
--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,NodeRestriction \
--authorization-mode=RBAC,Node \
--kubelet-https=true \
--enable-bootstrap-token-auth \
--token-auth-file=/opt/kubernetes/cfg/token.csv \
--service-node-port-range=30000-50000 \
--tls-cert-file=/opt/kubernetes/ssl/server.pem  \
--tls-private-key-file=/opt/kubernetes/ssl/server-key.pem \
--client-ca-file=/opt/kubernetes/ssl/ca.pem \
--service-account-key-file=/opt/kubernetes/ssl/ca-key.pem \
--etcd-cafile=/opt/etcd/ssl/ca.pem \
--etcd-certfile=/opt/etcd/ssl/server.pem \
--etcd-keyfile=/opt/etcd/ssl/server-key.pem"

开启服务

[root@master02 cfg]# systemctl start kube-apiserver.service 
[root@master02 cfg]# systemctl start kube-controller-manager.service 
[root@master02 cfg]# systemctl start kube-scheduler.service

结果验证

//增加环境变量
[root@master02 cfg]# vim /etc/profile
//末尾添加
export PATH=$PATH:/opt/kubernetes/bin/
[root@master02 cfg]# source /etc/profile

//见到如下画面即为成功
[root@master02 cfg]# kubectl get node
NAME              STATUS   ROLES    AGE     VERSION
192.168.142.132   Ready       2d12h   v1.12.3
192.168.142.136   Ready       38h     v1.12.3

看完这篇文章,你们学会kubernetes中配置Master02的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


本文名称:如何在kubernetes中配置Master02
网站网址:http://ybzwz.com/article/pchjjs.html