Prerequisites
To configure Kubernetes with CentOS, you’ll need a machine to act as a master, and one or more CentOS 7 hosts to act as cluster nodes.
Starting a cluster
This is a getting started guide for CentOS. It is a manual configuration so you understand all the underlying packages / services / ports, etc…
The Kubernetes package provides a few services: kube-apiserver, kube-scheduler, kube-controller-manager, kubelet, kube-proxy. These services are managed by systemd and the configuration resides in a central location: /etc/kubernetes. We will break the services up between the hosts. The first host, centos-master, will be the Kubernetes master. This host will run the kube-apiserver, kube-controller-manager and kube-scheduler. In addition, the master will also run etcd. The remaining hosts, centos-minion-n will be the nodes and run kubelet, proxy, cadvisor and docker.
All of them run flanneld as networking overlay.
System Information:
Hosts:
Please replace host IP with your environment.
|
|
Prepare the hosts:
- Create a /etc/yum.repos.d/virt7-docker-common-release.repo on all hosts - centos-{master,minion-n} with following information.
|
|
- Install Kubernetes, etcd and flannel on all hosts - centos-{master,minion-n}. This will also pull in docker and cadvisor.
|
|
- Add master and node to /etc/hosts on all machines (not needed if hostnames already in DNS)
|
|
- Edit /etc/kubernetes/config which will be the same on all hosts to contain:
|
|
- Disable the firewall on the master and all the nodes, as docker does not play well with other firewall rule managers. CentOS won’t let you disable the firewall as long as SELinux is enforcing, so that needs to be disabled first.
|
|
Configure the Kubernetes services on the master.
- Edit /etc/etcd/etcd.conf to appear as such:
|
|
- Edit /etc/kubernetes/apiserver to appear as such:
|
|
- Start ETCD and configure it to hold the network overlay configuration on master:
Warning This network must be unused in your network infrastructure!172.30.0.0/16is free in our network.
|
|
- Configure flannel to overlay Docker network in /etc/sysconfig/flanneld on the master (also in the nodes as we’ll see):
|
|
- Start the appropriate services on master:
|
|
Configure the Kubernetes services on the nodes.
We need to configure the kubelet and start the kubelet and proxy
- Edit /etc/kubernetes/kubelet to appear as such:
|
|
- Configure flannel to overlay Docker network in /etc/sysconfig/flanneld (in all the nodes)
|
|
- Start the appropriate services on node (centos-minion-n).
|
|
- Configure kubectl
|
|
You should be finished!
- Check to make sure the cluster can see the node (on centos-master)
|
|
The cluster should be running! Launch a test pod.
You should have a functional cluster, check out.