Kubernetes集群安装部署

  • 时间:
  • 浏览:0
  • 来源:幸运飞艇APP下载_幸运飞艇APP官网

node2:

# yum -y install flannel kubernetes-node

node3:

KUBELET_HOSTNAME="--hostname-override=192.168.1000.24"

2.编辑/etc/etcd/etcd.conf文件

如下操作在master上执行

KUBELET_HOSTNAME="--hostname-override=192.168.1000.23"

3.修改/etc/kubernetes/config文件

# yum -y install etcd kubernetes-master

node1:

KUBELET_PORT="--kubelet-port=1021000"

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

•Kubernetes集群组件:

KUBELET_PORT="--port=1021000"

# yum -y install epel-release

在master上执行如下命令

  - flannel 实现夸主机的容器网络的通信

KUBELET_ARGS=""

  - etcd 另三个 多高可用的K/V键值对存储和服务发现系统

KUBELET_API_SERVER="--api-servers=http://192.168.1000.20:10001000"

KUBELET_PORT="--port=1021000"

192.168.1000.24   Ready     1m

如下操作在node1、node2、node3、node4上执行

本文转自super李导51CTO博客,原文链接:http://blog.51cto.com/superleedo/201000172 ,如需转载请自行联系原作者

如下操作在所有机器执行

# systemctl stop firewalld

KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"

# etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

1.使用yum安装etcd和kubernetes-master

KUBELET_ADDRESS="--address=0.0.0.0"

•安装配置Kubernetes Master

KUBELET_ADDRESS="--address=0.0.0.0"

  - kubelet 在Node节点上按照配置文件中定义的容器规格启动容器

KUBE_LOG_LEVEL="--v=0"

 示意图如下:

KUBELET_ARGS=""

192.168.1000.22   Ready     1m

ETCD_NAME=default

FLANNEL_ETCD_KEY="/atomic.io/network"

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

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

KUBELET_ADDRESS="--address=0.0.0.0"

  - kube-proxy 提供网络代理服务

5.在etcd中定义flannel网络

KUBE_MASTER="--master=http://192.168.1000.20:10001000"

KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379"

KUBELET_HOSTNAME="--hostname-override=192.168.1000.21" #修改成对应Node的IP

[root@master ~]# kubectl get node

KUBELET_HOSTNAME="--hostname-override=192.168.1000.22" 

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

KUBE_LOGTOSTDERR="--logtostderr=true"

KUBELET_PORT="--port=1021000"

4.启动etcd、kube-apiserver、kube-controller-manager、kube-scheduler等服务,并设置开机启动。

KUBELET_API_SERVER="--api-servers=http://192.168.1000.20:10001000"

KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"

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

KUBELET_API_SERVER="--api-servers=http://192.168.1000.20:10001000"

2.关闭防火墙服务和selinx,正确处理与docker容器的防火墙规则冲突。

FLANNEL_ETCD="http://192.168.1000.20:2379"

•集群示意图

# systemctl disable firewalld

•安装配置Kubernetes Node

# setenforce 0

5.在所有Node节点上启动kube-proxy,kubelet,docker,flanneld等服务,并设置开机启动。

1.使用yum安装flannel和kubernetes-node

NAME            STATUS    AGE

KUBELET_ARGS=""

KUBELET_ADDRESS="--address=0.0.0.0"

Kubernetes集群安装部署

  - kube-apiserver 提供kubernetes集群的API调用

4.按照如下内容修改对应node的配置文件/etc/kubernetes/kubelet

node4:

KUBE_API_ARGS=""

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

  - kube-controller-manager 确保集群服务

KUBE_API_PORT="--port=10001000"

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

ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"

KUBE_ALLOW_PRIV="--allow-privileged=false"

2.为flannel网络指定etcd服务,修改/etc/sysconfig/flanneld文件

1.确保系统不可能 安装epel-release源

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"

KUBELET_ARGS=""

KUBELET_API_SERVER="--api-servers=http://192.168.1000.20:10001000" #指定Master节点的API Server

3.编辑/etc/kubernetes/apiserver文件

192.168.1000.23   Ready     1m

•验证集群否有安装成功

192.168.1000.21   Ready     1m

  Kubernetes工作模式server-client,Kubenetes Master提供集中化管理Minions。部署1台Kubernetes Master节点和4台Minion节点,

KUBELET_PORT="--port=1021000"

  - kube-scheduler 调度容器,分配到Node