Kubernetes集群部署
阿新 • • 發佈:2018-07-20
container 網絡代理 文件 int 角色 集群部署 ddr don 4.0 一、kubernetes組件和角色分布
組件功能:
- etcd 一個高可用的K/V鍵值對存儲和服務發現系統
- flannel 實現誇主機的容器網絡的通信
- kube-apiserver 提供kubernetes集群的API調用
- kube-controller-manager 確保集群服務
- kube-scheduler 調度容器,分配到Node
- kubelet 在Node節點上按照配置文件中定義的容器規格啟動容器
- kube-proxy 提供網絡代理服務
角色分布:
主機 | 角色 |
---|---|
192.168.10.131 | etcd server、kubernetes master |
192.168.10.128 | kubernetes node |
192.168.10.135 | kubernetes node |
配置epel-release源
# yum -y install epel-release
二、 master節點配置
1.在master上安裝etcd和kubernetes-master
[root@dockertest ~]# yum -y install etcd kubernetes-master
2.修改etcd配置文件
[root@dockertest ~]# cat /etc/etcd/etcd.conf | grep -v "^#" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" ETCD_NAME="default" ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
3.修改kubernetes配置文件
[root@dockertest ~]# cat /etc/kubernetes/apiserver | grep -v "^#" | grep -v "^$" KUBE_API_ADDRESS="--insecure-bind-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,ServiceAccount,ResourceQuota" KUBE_API_ARGS=""
4.設置服務啟動
[root@dockertest ~]# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES ; done
5.在etcd中定義flannel網絡
[root@dockertest ~]# etcdctl mk /atomic.io/network/config ‘{"Network":"172.17.0.0/16"}‘
{"Network":"172.17.0.0/16"}
三、node節點配置
1..在所有node節點上安裝flannel和kubernetes-node
[root@machine1 ~]# yum -y install flannel kubernetes-node
2.修改flannel配置文件
[root@machine1 ~]# cat /etc/sysconfig/flanneld | grep -v "^#" | grep -v "^$"
FLANNEL_ETCD_ENDPOINTS="http://192.168.10.131:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
3.修改kubernetes配置文件
[root@machine2 ~]# cat /etc/kubernetes/config | grep -v "^#" | grep -v "^$"
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.10.131:8080"
[root@machine1 ~]# cat /etc/kubernetes/kubelet| grep -v "^#" | grep -v "^$"
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=192.168.10.128"
KUBELET_API_SERVER="--api-servers=http://192.168.10.131:8080" #修改成對應Node的IP
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""
4.啟動kube-proxy,kubelet,docker,flanneld等服務
[root@machine2 ~]# for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done
四、查看集群啟動情況
[root@dockertest ~]# kubectl get node
NAME STATUS AGE
192.168.10.128 Ready 1m
192.168.10.135 Ready 1m
Kubernetes集群部署