Arash Motamedi
Arash Motamedi

Reputation: 10672

Kubernetes bare-metal: Assign external IP to Node

I have setup a Kubernetes cluster with a few VMs. I know the external static IP of each node. Is there a way for me to manually register these external IPs to my cluster nodes?

I don't want to use Service, Ingress, MetalLB, or any cloud-specific load balancer solution.

Basically, I want to manually populate these fields for my nodes:

How do I add external IPs to my nodes


For context, here's what I'm trying to accomplish: I have some NodePort services which I want to expose to the internet without explicitly specifying the externalIps list in the service definition. I want a request from the browser to hit one of my nodes at its external IP, and inside the cluster behave as if the internal node IP was requested.

I'm assuming that if I can somehow tell my nodes what their external IP is, then this scenario will work automatically. Is this assumption correct? And if so, is there a way, kubectl or otherwise, for me to add external IP to my node definitions?

Else, can I achieve what I've described via a CNI plugin? Or by changing the content of /etc/cni/net.d/10-weave.conflist?

Upvotes: 0

Views: 1860

Answers (1)

coderanger
coderanger

Reputation: 54191

Okay, so to rewind, this is what the actual data structure looks like:

  addresses:
  - address: 10.45.0.53
    type: InternalIP
  - address: 34.127.42.172
    type: ExternalIP

So multiple address types are present in parallel (there's also usually hostname data set in there too). However the Kubelet only ever sets InternalIP itself, based on either --node-ip or the primary interface address of the system. The other values are populated by cloud controllers which you don't have. So either you need to write your own cloud controller or set up the primary IP of the node to be public (it will be noted as "internal" but IPs are IPs.

Upvotes: 2

Related Questions