Change kubernetes master node's IP after running `kubeadm init`

8/14/2019

I am attempting to build a machine image (AMI, via packer) which contains a single-node Kubernetes cluster (everything in just one machine). To do this, an EC2 instance is spun up, and kubeadm init is executed on it. When this happens, the current instance's internal IP is used to configure the Kubernetes cluster. This is exported as an AMI.

Now, when this AMI is used to spin up a new instance which receives a new IP address, the single-node Kubernetes is configured for the previous IP (the one given to the builder machine described before). This causes all components, including kubectl on the host machine to not reach the correct (new) IP.

Is there any way to create the cluster in such a way that is agnostic to its IP (perhaps a /etc/hosts entry with some extra magic)? Alternatively, how can I change the required IP's on this machine's configuration so that all components work (as if we ran kubeadm init on the target instance directly).

-- scooz
amazon-web-services
kubeadm
kubectl
kubernetes
packer

0 Answers