kubernetes是google公司基于docker所做的一个分布式集群,有以下主件组成
etcd: 高可用存储共享配置和服务发现
flannel: 网络结构支持
kube-apiserver: 不论通过kubectl还是使用remote api 直接控制,都要经过apiserver
kube-controller-manager: 对replication controller, endpoints controller, namespace controller, and serviceaccounts controller的循环控制,与kube-apiserver交互,保证这些controller工作
kube-scheduler: Kubernetes scheduler的作用就是根据特定的调度算法将pod调度到指定的工作节点(minion)上,这一过程也叫绑定(bind)
kubelet: Kubelet运行在Kubernetes Minion Node上. 它是container agent的逻辑继任者
kube-proxy: kube-proxy是kubernetes 里运行在minion节点上的一个组件, 它起的作用是一个服务代理的角色
kubernetes架构图 如下:
环境:Centos7 X86_64
下载地址:http://mirrors.cug.edu.cn/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1511.iso
master:192.168.50.130
monion01:192.168.50.131
monion02:192.168.50.132
monion03:192.168.50.133
master部署:
1.关闭防火墙
#systemctl stop firewalld
#systemctl disable firewalld
2.禁用selinux
setenforce 0
3.安装ntp
yum -y install ntp
systemctl start ntpd
systemctl enable ntpd
4.安装etcd与kubernete
yum -y install etcd kubernetes
5.修改etcd配置文件
vi /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"
6.修改kubernetes apiserver
vi /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=""
7.启动kube-apiserver kube-controller-manager kube-scheduler
forSERVICESinetcd kube-apiserver kube-controller-manager kube-scheduler;do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
8.创建网络
etcdctl mk /atomic.io/network/config'{"Network":"172.17.0.0/16"}'
9.查看节点
kubectlgetnodes
到此master端配置完成
客户端配置
1.在monion01、monion02、monion03上部署
yum -y install flannel kubernetes
2.配置flanneld
1
vi /etc/sysconfig/flanneld
FLANNEL_ETCD="http://192.168.50.130:2379"
3.配置kubernetes
vi /etc/kubernetes/config
KUBE_MASTER="--master=http://192.168.50.130:8080"
4.配置kubelet
monion01
vi /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
# change the hostname to this host’s IP address
KUBELET_HOSTNAME="--hostname_override=192.168.50.131"
KUBELET_API_SERVER="--api_servers=http://192.168.50.130:8080"
KUBELET_ARGS=""
monion02
vi /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
# change the hostname to this host’s IP address
KUBELET_HOSTNAME="--hostname_override=192.168.50.132"
KUBELET_API_SERVER="--api_servers=http://192.168.50.130:8080"
KUBELET_ARGS=""
monion03
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
# change the hostname to this host’s IP address
KUBELET_HOSTNAME="--hostname_override=192.168.50.133"
KUBELET_API_SERVER="--api_servers=http://192.168.50.130:8080"
KUBELET_ARGS=""
5.启动服务
forSERVICESinkube-proxy kubelet docker flanneld;do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
6.验证
monion01
ip a | grep flannel | grep inet
在monion02和monion3上执行查看
master
kubect lget nodes
NAME LABELS STATUS
192.168.50.131 kubernetes.io/hostname=192.168.50.131 Ready
192.168.50.132 kubernetes.io/hostname=192.168.50.132 Ready
192.168.50.133 kubernetes.io/hostname=192.168.50.133 Ready
测试完成!