I want to build my own Kubernetes cluster across two locations (300 km distance) and integrate it into GitLab.
Let me list my ideas. My question is if I have a mistake in my thinking somewhere and ask to solve it.
Since I can only set up VMs and have no rights directly on the hosts, I want to install an etcd-cluster on 5 VMs (3+2). I would install etcd with apt on Ubuntu 18.04. For this I don't need Kubernetes at first.
An odd number of instances only applies to etcd and not to control planes?
Does it make any sense to set up separate VMs for the control planes or can I reuse the 3+2 VMs of the etcd cluster? Otherwise I would already have 10 VMs.
Unless you have a big kubernetes cluster with thousand of services and many nodes, you can setup a separated etcd cluster and remember if you want to setup the etcd cluster in two locations, check the coreos documentation, because etcd is very sensitive to latency
If you choose to use an external etcd cluster, you don't need an odd number for the control planes, you only need an odd number with etcd, because etcd machines are in cluster.
Control planes doesn't communicate between them, only with etcd
I have learned a few things and would like to share them with you.
etcd is pronounced like "@ cee dee".
I have decided now to not use apt (etcd 3.2 on Ubuntu 18.04) for installation but to download the latest version (3.3.18) with wget. The first hit on Google worked.
Installation
Reset
Remove all data in the member folders:
Or change argument
--initial-cluster-token XYZ
(every five members the same) and startetcd
with parameter--force-new-cluster
.When you restart your existing cluster or add more members: change from
--initial-cluster-state new
to--initial-cluster-state existing
.Drop all data (keys with values) from etcd cluster:
Configuration
You can put this into service:
/etc/systemd/system/etcd.service
(create if not exist) (example for first member aaa)If someone can make an example with encryption, i.e. with client certificates, I would be grateful.
Chrony
It is also important that all five machines have the same time. Otherwise you will see a lot of errors in your logs. For this I used chrony.
/etc/chrony/chrony.conf
Please remember to supply the worker nodes with the same time as well.
Checks
sudo etcdctl cluster-health
sudo etcdctl member list