CentOS部署Kubernetes集群

2,081 views次阅读
没有评论

 

CentOS部署Kubernetes集群

前提条件

需要2台或以上安装有CentOS的机器

启动一个集群

Kubernetes包提供了一些服务:kube-apiserver, kube-scheduler, kube-controller-manager,kubelet, kube-proxy。这些服务通过systemd进行管理,配置信息都集中存放在一个地方:/etc/kubernetes。我们将会把这些服务运行到不同的主机上。

第一台主机,k8s-master,将是Kubernetes 集群的master主机。这台机器上将运行kube-apiserver, kubecontroller-manager和kube-scheduler这几个服务,此外,master主机上还将运行etcd。其余的主机,k8s-node,将是从节点,将会运行kubelet, proxy和docker。

系统信息

IP地址 主机名 备注
172.20.2.30 k8s-master Master
172.20.2.31 k8s-node1 node1
172.20.2.32 k8s-node2 node2

开始安装

etcd集群部署

master节点

1、安装kubernetes etcd

[root@k8s-master ~]# yum -y install kubernetes-master etcd

2、配置etcd

vim /etc/etcd/etcd.conf

CentOS部署Kubernetes集群

node节点

1、安装部署kubernetes-node/etcd/flannel/docker

[root@k8s-node1 ~]# yum -y install kubernetes-node etcd flannel docker

2、配置etcd,node2和node1节点相同,以node1节点为例

[root@k8s-node1 ~]# vim /etc/etcd/etcd.conf

CentOS部署Kubernetes集群

启动etcd集群

分别在3台服务器启动etcd

[root@k8s-master ~]# systemctl start etcd
[root@k8s-node1 ~]# systemctl start etcd
[root@k8s-node2 ~]# systemctl start etcd

查看集群状态

CentOS部署Kubernetes集群

至此,etcd集群部署完毕。

Kubernetes集群配置

master节点

1、apiserver配置文件修改,注意KUBE_ADMISSION_CONTROL选项的参数配置

[root@k8s-master ~]# vim /etc/kubernetes/apiserver

CentOS部署Kubernetes集群

2、启动master服务

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

nodes节点配置

1、配置config配置,node1&node2配置相同,以node1为例说明

[root@k8s-node1 ~]# vim /etc/kubernetes/config
###
# kubernetes system config
#
# The following values are used to configure various aspects of all
# kubernetes services, including
#
#   kube-apiserver.service
#   kube-controller-manager.service
#   kube-scheduler.service
#   kubelet.service
#   kube-proxy.service
# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR="--logtostderr=true"

# journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0"

# Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false"

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://172.20.2.30:8080"

2、配置kubelet

[root@k8s-node1 ~]# vim /etc/kubernetes/kubelet
###
# kubernetes kubelet (minion) config

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=127.0.0.1"

# The port for the info server to serve on
KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=172.20.2.31"

# location of the api-server
KUBELET_API_SERVER="--api-servers=http://172.20.2.30:8080"

# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

# Add your own!
KUBELET_ARGS=""

网络配置

这里使用flannel进行网络配置,已经在2个节点上安装,下面进行配置。

在节点上进行配置flannel

[root@k8s-node1 ~]# vim /etc/sysconfig/flanneld
# Flanneld configuration options  

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://172.20.2.30:2379"

# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/atomic.io/network"

# Any additional options that you want to pass
#FLANNEL_OPTIONS=""

启动节点上的服务

for SERVICES in kube-proxy kubelet docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done

查看集群状态

CentOS部署Kubernetes集群

 

Honest1y
版权声明:本站原创文章,由Honest1y于2018年08月03日发表,共计6539字。
转载提示:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)