Instructions mostly at https://vitux.com/install-and-deploy-kubernetes-on-ubuntu/ but be sure to read the notes below before starting.
This document assumes all hosts are on the private network, and the hosts are configured to pass/allow all traffic on that network. You could tighten this up if you want, but k8 requires quite a range of ports be open.
Be sure the --apiserver-advertise-address=<private ip>
parameter is passed to kubeadm init
on any master host. By default, the api-server will attempt to advertise on the public interface.
Note that on digital ocean, and possibly anwhere you have more than one NIC, you will need to tell the nodes to use their private ip. On each host (including masters), edit/create /etc/default/kubelet
and put in the line:
KUBELET_EXTRA_ARGS= --node-ip=<private ip>
By default kublet binds to the instance public IP which is no bueno.
Then systemd restart kubelet.service
. Do this for all nodes
Do not blindly install flannel. You will need to make some changes to the config file. Specificlly, download the yaml file:
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Then edit the file. Look for the DaemonSet/containers/kube-flannes section. Add the following to the list of startup args:
- --iface=eth1 # or whatever the private interface is
Then apply the yaml file:
kubectl apply -f kube-flannel.yml
# or kubectl delete -f kube-flannel.yml && kubectl apply -f kube-flannel.yml if you already went with the default
You can get the logs for each deployed flanne container (there wil be one per node) by getting all the flannel pods:
kubectl get pods -o wide --all-namespaces | grep flannel
Then go grab the logs for each, and verify that it started with the correct -- private -- ip:
kubectl -n kube-system logs -c kube-flannel <pod name>