Editing Setting up Kubernetes cluster

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
This article describes a way to deploy a Kubernetes cluster on a few CentOS 7 machines, using Docker with ploop graphdriver.
+
This article describes a way to deploy a Kubernetes cluster on a few CentOS 7 machines.
  
 
{{Stub}}
 
{{Stub}}
Line 8: Line 8:
 
* CentOS 7 minimal installed
 
* CentOS 7 minimal installed
 
* firewalld stopped
 
* firewalld stopped
* ntpd installed and running
+
: <code>systemctl stop firewalld; systemctl disable firewalld</code>
 
+
* ntpd installed and running:
For Docker to work with ploop (on the nodes), you also need:
+
: <code>yum -y install ntpd && systemctl start ntpd && systemctl enable ntpd</code>
* ext4 filesystem on /var/lib
 
* vzkernel installed and booted into
 
* ploop installed
 
* docker with ploop graphdriver installed
 
 
 
== CentOS 7 installation ==
 
 
 
1. Select "disk", "manual setup", "standard partitioning", "automatically create partitions", then change xfs to ext4 for / and /boot.
 
 
 
2. After reboot, login and edit <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code> file, making sure it has the following line:
 
ONBOOT=yes
 
 
 
3. Enable networking:
 
ifup eth0
 
 
 
4. Update the system:
 
yum update -y
 
 
 
5. Disable firewalld:
 
systemctl stop firewalld; systemctl disable firewalld
 
 
 
6. Install and enable ntpd:
 
yum -y install ntp && systemctl start ntpd && systemctl enable ntpd
 
 
 
  
 
== Master installation ==
 
== Master installation ==
Line 54: Line 30:
 
Make sure <code>/etc/kubernetes/apiserver</code> contains this:
 
Make sure <code>/etc/kubernetes/apiserver</code> contains this:
  
=== Start master node services ===
+
4. Start master node services:
  
 
  for S in etcd kube-apiserver kube-controller-manager kube-scheduler; do  
 
  for S in etcd kube-apiserver kube-controller-manager kube-scheduler; do  
Line 63: Line 39:
 
== Set nodes (minions) ==
 
== Set nodes (minions) ==
  
=== Set the node hostname ===
+
1. Install vzkernel:
 
 
For example:
 
echo kube-node2 > /etc/hostname
 
 
 
=== Install vzkernel ===
 
 
 
This is needed for ploop to work. If you don't need ploop, you can skip this step.
 
 
 
First, install vzkernel:
 
 
  rpm -ihv https://download.openvz.org/virtuozzo/factory/x86_64/os/Packages/v/vzkernel-3.10.0-229.7.2.vz7.6.9.x86_64.rpm
 
  rpm -ihv https://download.openvz.org/virtuozzo/factory/x86_64/os/Packages/v/vzkernel-3.10.0-229.7.2.vz7.6.9.x86_64.rpm
  
Or, use the latest vzkernel from https://download.openvz.org/virtuozzo/factory/x86_64/os/Packages/v/
+
2. Enable docker-ploop repo:
 
 
Then reboot into vzkernel:
 
reboot
 
 
 
Finally, make sure vzkernel is running:
 
uname -r
 
3.10.0-229.7.2.vz7.6.9
 
 
 
=== Install docker with ploop graphdriver ===
 
  
This is needed for ploop to work. If you don't need ploop, you can skip this step.
 
 
First, install docker and ploop:
 
yum install -y wget
 
 
  cd /etc/yum.repos.d/
 
  cd /etc/yum.repos.d/
 
  wget https://copr.fedoraproject.org/coprs/kir/docker-ploop/repo/epel-7/kir-docker-ploop-epel-7.repo
 
  wget https://copr.fedoraproject.org/coprs/kir/docker-ploop/repo/epel-7/kir-docker-ploop-epel-7.repo
Line 95: Line 49:
 
  yum install ploop docker
 
  yum install ploop docker
  
Then, set ploop driver to be default for docker. Make sure <code>/etc/sysconfig/docker-storage</code> contains:
+
3. Set ploop driver to be default for docker.
 +
 
 +
Make sure <code>/etc/sysconfig/docker-storage</code> contains:
  
 
  DOCKER_STORAGE_OPTIONS="-s ploop"
 
  DOCKER_STORAGE_OPTIONS="-s ploop"
  
=== Install flannel and kubernetes-node ===
+
4. Install flannel and kubernetes-node:
  
 
  yum -y install flannel kubernetes-node
 
  yum -y install flannel kubernetes-node
 
=== Configure flannel for master etcd ===
 
 
Update the following line in /etc/sysconfig/flanneld to make sure it contains master IP:
 
 
FLANNEL_ETCD="http://192.168.122.211:2379"
 
 
=== Configure Kubernetes for master node ===
 
 
Update the following line in /etc/kubernetes/config to make sure in contains master IP:
 
 
KUBE_MASTER="--master=http://192.168.122.211:8080"
 
 
=== Configure kubelet ===
 
 
In /etc/kubelet/config:
 
 
1. Enable it to listen on all interfaces:
 
KUBELET_ADDRESS="--address=0.0.0.0"
 
 
2. Comment out this line to use default hostname:
 
# KUBELET_HOSTNAME
 
 
3. Make sure this points to master node IP:
 
KUBELET_API_SERVER="--api_servers=http://192.168.122.211:8080"
 
 
=== Start needed services ===
 
 
Start needed services:
 
systemctl restart docker
 
systemctl restart flanneld
 
systemctl restart kubelet
 
systemctl restart kube-proxy
 
 
NOTE: if 'systemctl restart docker' fails, you might need to run:
 
systemctl stop docker
 
ip l del docker0
 
 
Enable needed services:
 
systemctl enable docker
 
systemctl enable flanneld
 
systemctl enable kubelet
 
systemctl enable kube-proxy
 
 
== Checking that the system is set up ==
 
 
On the master node, check that the needed services are running:
 
for S in etcd kube-apiserver kube-controller-manager kube-scheduler; do
 
  systemctl status $S
 
done
 
 
On the nodes, check that the needed services are running:
 
systemctl status docker
 
systemctl status flanneld
 
systemctl status kubelet
 
systemctl status kube-proxy
 
 
Finally, check that the nodes are visible and active:
 
# kubectl get nodes
 
NAME        LABELS                              STATUS
 
kube-node1  kubernetes.io/hostname=kube-node1  Ready
 
kube-node2  kubernetes.io/hostname=kube-node2  Ready
 
 
NOTE: if there are some stale nodes listed, you can remove those:
 
kubectl delete node localhost.localdomain
 
  
 
== See also ==
 
== See also ==
  
 
* [https://github.com/coreos/etcd/blob/master/Documentation/configuration.md etcd configuration]
 
* [https://github.com/coreos/etcd/blob/master/Documentation/configuration.md etcd configuration]

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: