Assign static public IP to LB in Azure

3/23/2017

My workflow is something on the lines of:

  1. Create a static Public IP on Azure and map it to a DNS name.
  2. Then start a service in Kubernetes which spins up a an LB to which we attached the pre-reserved public IP.

Approach 1:

externalName: <FQDN>

Approach 2:

type: LoadBalancer
externalIPs:
- 52.232.30.160

Approach 3:

type: LoadBalancer
loadBalancerIP: 52.232.30.160

Approach 4:

type: LoadBalancer
clusterIP: 52.166.121.161

But none of them seems to work. The LB always gets 2 public IPs - one statically assigned and the other dynamically assigned.

I was wondering what is the right way to do this and if Azure supports assignment of public IPs to the LB.

-- krish7919
azure
azure-container-service
kubernetes

1 Answer

7/20/2017

try this:

apiVersion: v1
kind: Service
metadata:
  labels:
    run: my-nginx
  name: my-nginx
  namespace: default
spec:
  clusterIP: $clusterip
  loadBalancerIP: $externalip
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: my-nginx
  sessionAffinity: None
  type: LoadBalancer

available external addresses check in fronted ip configuration of azure load balancer (but not masters)

-- Giorgi Mukhigulashvili
Source: StackOverflow