I want to create a Kubernetes cluster on 4 machines.
One has a public IP address and is reachable from the internet (let's call this Master
). The Master also has a domain name assigned to it (let's say it's master.foo
).
Three machines are on the same private network (192.168.5.0), behind a router (let's call these Worker A/B/C
).
I have successfully set up a cluster between these machines:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
Master Ready master 5d20h v1.17.1
WorkerA Ready <none> 21h v1.17.1
WorkerB Ready <none> 21h v1.17.1
WorkerC Ready <none> 5d17h v1.17.1
I also have pods running on the different workers without errors.
I have initialized my cluster with:
sudo kubeadm init --control-plane-endpoint=master.foo --pod-network-cidr=10.244.0.0/16
(Using Flannel as the overlay network.)
The problem is that running kubectl exec
or kubectl port-forward
on the master results in an error:
paulb@galaxy:~$ kubectl -n pgo port-forward svc/postgres-operator 8443:8443
error: error upgrading connection: error dialing backend: dial tcp 192.168.5.192:10250: i/o timeout
Where 192.168.5.192
is the private IP of one of the workers, of course.
I think this is related to what is stated here: https://kubernetes.io/docs/concepts/cluster-administration/networking/#the-kubernetes-network-model
pods on a node can communicate with all pods on all nodes without NAT
So, should I set up an OpenVPN network between all these machines?
If yes, then how would I combine kubeadm init --control-plane-endpoint
with the fact that I neet kubernetes going out on the OpenVPN tun0
adapter?
Did I miss something? It seems strange that containers are running on the workers, but I cannot execute commands (kubectl exec
) on them from the master.