centos上部署kubernetes集群

环境

centos7系统机器2台:

  • 172.16.5.17 用来做master节点
  • 172.16.5.20 用来做minion节点

关闭防火墙和selinux

在master和minion节点上进行如下配置:

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/sysconfig/selinux

master节点安装配置

安装etcd和kubernetes

yum -y install etcd kubernetes

配置etcd

#vim /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"

配置kubernetes

vim /etc/kubernetes/apiserver

KUBE_API_ADDRESS="--address=0.0.0.0" KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet_port=10250"
KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_ARGS=""

启动服务

systemctl restart etcd kube-apiserver kube-controller-manager kube-scheduler
systemctl enable etcd kube-apiserver kube-controller-manager kube-scheduler
systemctl status etcd kube-apiserver kube-controller-manager kube-scheduler

设置etcd网络

etcdctl --endpoint http://172.16.5.17:2379 set /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

验证安装

kubectl get nodes

minion节点安装配置

安装flannel和kubernetes

yum -y install flannel kubernetes

配置kubernetes连接的服务端IP

vim /etc/kubernetes/config

KUBE_MASTER="--master=http://172.16.5.17:8080"

配置kubernetes

vim /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=127.0.0.1"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=172.16.5.20"
KUBELET_API_SERVER="--api-servers=http://172.16.5.17:8080"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

配置flannel网络

vim /etc/sysconfig/flanneld

FLANNEL_ETCD_ENDPOINTS="http://172.16.5.17:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"

其中atomic.io与上面etcd中的Network对应

启动服务

systemctl restart flanneld kube-proxy kubelet docker
systemctl enable flanneld kube-proxy kubelet docker
systemctl status flanneld kube-proxy kubelet docker

验证

master节点上,执行命令kubectl get nodes,显示如下

NAME          STATUS    AGE
172.16.5.20   Ready     17m

你可能感兴趣的:(Linux,kubernetes)