centos7集群部署k8s
1、机器情况机器ip角色部署内容172.18.1.22matseretcd、kube-apiserver、kube-controller-manager、kube-scheduler172.18.1.23minionkube-proxy,kubelet,docker,flanneld172.18.1.24minionkube-pr
·
1、机器情况
机器ip | 角色 | 部署内容 |
---|---|---|
172.18.1.22 | matser | etcd、kube-apiserver、kube-controller-manager、kube-scheduler |
172.18.1.23 | minion | kube-proxy,kubelet,docker,flanneld |
172.18.1.24 | minion | kube-proxy,kubelet,docker,flanneld |
172.18.1.25 | minion | kube-proxy,kubelet,docker,flanneld |
172.18.1.26 | minion | kube-proxy,kubelet,docker,flanneld |
2、部署依赖
确保系统已经安装epel-release源,关闭防火墙服务,避免与docker容器的防火墙规则冲突。
[root@bgsbtsp0006-dqf opt]# yum -y install epel-release
[root@bgsbtsp0006-dqf opt]# systemctl stop firewalld
3、安装并配置Kubernetes Master
[root@bgsbtsp0006-dqf opt]# yum -y install etcd kubernetes-master
3.1、编辑并修改/etc/etcd/etcd.conf文件
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
3.2、编辑/etc/kubernetes/apiserver文件
3.3、启动etcd、kube-apiserver、kube-controller-manager、kube-scheduler等服务,并设置开机启动。
[root@bgsbtsp0006-dqf opt]# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES ; done
3.4、在etcd中定义flannel网络
[root@bgsbtsp0006-dqf opt]# etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'
4、安装配置Kubernetes Node,如下操作在23、24、25、26机器上执行。
4.1、使用yum安装flannel和kubernetes-node
[root@bgsbtsp0006-dqf opt]# yum -y install flannel kubernetes-node
4.2、为flannel网络指定etcd服务,修改/etc/sysconfig/flanneld文件
# 修改ETCD服务即matser的ip地址
FLANNEL_ETCD="http://192.168.30.20:2379"
FLANNEL_ETCD_KEY="/atomic.io/network"
4.3、修改/etc/kubernetes/config文件
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.30.20:8080"
4.4、修改对应minion机器上的配置文件/etc/kubernetes/kubelet
172.18.1.23机器:
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
#修改成对应minion机器的IP
KUBELET_HOSTNAME="--hostname-override=172.18.1.23"
#指定Master节点的API Server
KUBELET_API_SERVER="--api-servers=http://172.18.1.22:8080"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""
172.18.1.24机器:
其余配置不变
KUBELET_HOSTNAME="--hostname-override=172.18.1.24"
172.18.1.25机器:
其余配置不变
KUBELET_HOSTNAME="--hostname-override=172.18.1.25"
172.18.1.26机器:
其余配置不变
KUBELET_HOSTNAME="--hostname-override=172.18.1.26"
5.在所有minion节点上启动kube-proxy,kubelet,docker,flanneld等服务,并设置开机启动。
for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done
6、验证集群是否安装成功,在master上执行如下命令:
[root@bgsbtsp0006-dqf opt]# kubectl get node
更多推荐
已为社区贡献7条内容
所有评论(0)