Assign an External IP to a Node

10/15/2016

I'm running a bare metal Kubernetes cluster and trying to use a Load Balancer to expose my services. I know typically that the Load Balancer is a function of the underlying public cloud, but with recent support for Ingress Controllers it seems like it should now be possible to use nginx as a self-hosted load balancer.

So far, i've been following the example here to set up an nginx Ingress Controller and some test services behind it. However, I am unable to follow Step 6 which displays the external IP for the node that the load balancer is running on as my node does not have an ExternalIP in the addresses section, only a LegacyHostIP and InternalIP.

I've tried manually assigning an ExternalIP to my cluster by specifying it in the service's specification. However, this appears to be mapped as the externalID instead.

How can I manually set my node's ExternalIP address?

-- KingJ
kubernetes

2 Answers

10/16/2016

This is something that is tested and works for an nginx service created on a particular node.

apiVersion: v1
kind: Service
metadata:
    name: nginx
    namespace: default
spec:
    ports:
    -   port: 80
        protocol: TCP
        targetPort: 80
        name: http
    -   port: 443
        protocol: TCP
        targetPort: 443
        name: https
    externalIPs:
      - '{{external_ip}}'
    selector:
        app: nginx

Assumes an nginx deployment upstream listening on port 80, 443. The externalIP is the public IP of the node.

-- iamnat
Source: StackOverflow

11/16/2018

I would suggest checking out MetalLB: https://github.com/google/metallb

It allows for externalIP addresses in a baremetal cluster using either ARP or BGP. It has worked great for us and allows you to simply request a LoadBalancer service like you would in the cloud.

-- adam wilhelm
Source: StackOverflow