AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Unable to assign public static IP

Open PlasmaPower opened this issue 8 years ago • 26 comments

I have created a (static) Public IP Address in the same resource as my AKS cluster. I was hoping to assign it to a Kubernetes service of type LoadBalancer. As specified here, I set the spec loadBalancerIP property to the IP address. However, I get this error:

Error creating load balancer (will retry): Failed to ensure load balancer for service kube-system/traefik: user supplied IP Address XX.XX.XX.XX was not found

Am I missing something, or is this not currently supported?

PlasmaPower avatar Dec 09 '17 20:12 PlasmaPower

May be fixed with kubernetes/kubernetes#53557 but I'm not sure.

PlasmaPower avatar Dec 10 '17 18:12 PlasmaPower

I'm getting this same issue, just created a new cluster and tried to follow the simple azure-vote.yml and got this error and saying pending forever and never get's a external IP

AceHack avatar Dec 17 '17 04:12 AceHack

Any suggestion on when this may be fixed? I would really like to get some workloads moved over and test them out but it's not going to work without an external IP.

AceHack avatar Dec 17 '17 04:12 AceHack

As mentioned, the Azure cloud provider integration doesn't support attaching to an existing ip address. Instead, let the Kubernetes service provision a new ip for the service. The most basic service + app that should work looks like:

# basic service + deployment
apiVersion: v1
kind: Service
metadata:
  name: basic-service-lb
  labels:
    app: basic-service-lb-app
spec:
  type: LoadBalancer
  ports:
  - port: 80
    protocol: TCP
  selector:
    app: basic-service-lb-app
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: basic-service-lb-app
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: basic-service-lb-app
    spec:
      containers:
      - name: nginx
        image: nginx:1.10.1
        ports:
        - containerPort: 80

slack avatar Dec 19 '17 22:12 slack

For me the pending issue was solved by removing the optional ACI plugin

AceHack avatar Dec 19 '17 23:12 AceHack

@slack However, that IP is dynamic, correct? When I recreate the service, the IP changes. That does not seem suitable for running a service such as a website.

I recently changed added Traefik to my Kubernetes setup. Doing so required modifying the frontend service. In that situation, I'd prefer not to have the website go down for hours while DNS updates to the new IP.

@AceHack you're using a dynamic IP, right? My issue is with static IPs. I'm also not sure I have an optional ACI plugin.

PlasmaPower avatar Dec 19 '17 23:12 PlasmaPower

@PlasmaPower it does look like https://github.com/kubernetes/kubernetes/pull/53557 was created to support static IPs that are in different resource groups. I'm guessing if you put the static IP in the MC_* resource group then you should be able to manually assign that IP address in a K8s yaml file and use it or reference a different resource group as defined by the issue you reference.

The Azure Container Instances (ACI) plugin is something you can install into the cluster with the Azure CLI. If you never installed it then you won't have it. Whenever I tried to give anything a dynamic public IP address with that plugin installed it would fail and never get the public IP address.

Also, dynamic IP addresses can work fine with DNS CNAME records. When you go to the azure provided public IP you can change it's DNS prefix to your desired alias. Like {yourprefix}.{region}.cloudapp.azure.com. Then create a CNAME that points to it. I've created two, a *.{mydomain}.com and a {mydomain}.com.

This lets me use nginx to expose any subdomain from my primary domain without touching any Azure infrastructure, all K8s native deployments.

AceHack avatar Dec 19 '17 23:12 AceHack

Oh, I had no idea it was assigned a cloudapp domain name! I'll do some more in depth testing, but that probably fixes the problem in my scenario. Perhaps that should be documented in the example AKS guide. Thanks!

PlasmaPower avatar Dec 19 '17 23:12 PlasmaPower

@PlasmaPower it is not assigned to a cloudapp domain name by default. You have to go in the Azure portal and click on the public IP address and go to settings, there you can type in a DNS alias in the format I described above. Thanks.

AceHack avatar Dec 20 '17 00:12 AceHack

Where can I find the public IP in Azure?

PlasmaPower avatar Dec 20 '17 00:12 PlasmaPower

@PlasmaPower You should see an auto created MC_* resource group in your Azure subscription. It has all the resources in there like your VMs, Disks, Load Balancer, and any public IPs, etc...

AceHack avatar Dec 20 '17 00:12 AceHack

Oh, I had no idea that existed! Thanks!

PlasmaPower avatar Dec 20 '17 00:12 PlasmaPower

Creating a public IP in the MC_* resource group also works.

PlasmaPower avatar Dec 21 '17 22:12 PlasmaPower

@PlasmaPower that's great!!

AceHack avatar Dec 22 '17 03:12 AceHack

This worked for me as well - thanks!

outkaj avatar Jan 17 '18 15:01 outkaj

Hey @AceHack , Does aks automatically pick up the dns name for the public ip created in the MC_* resource group ? Or, Do I need to specify it in the yml file through some property like loadBalancerIP to get it to stick with the service ? I seem to be getting a new public ip address even after setting up a dynamic ip address in the resource group..

prashantchari avatar Jan 25 '18 06:01 prashantchari

hi @prashantchari According to k8s docs:

To use user-specified public type loadBalancerIP, a static type public IP address resource needs to be created first, and it should be in the same resource group of the cluster. Then you could specify the assigned IP address as loadBalancerIP.

I think aks doesn't create any dns records for new LB services. But you can take a look at https://github.com/kubernetes-incubator/external-dns if it would help you.

mwieczorek avatar Jan 25 '18 09:01 mwieczorek

Thanks for the info @mwieczorek . I'll check that out. It sounded @PlasmaPower and a couple of folks got the Load Balancer to stick to a cloudapp DNS name earlier in the discussion instead of the supported static ip, and I was curious how they set it up.

prashantchari avatar Jan 25 '18 23:01 prashantchari

You can configure the domain name by creating the Public IP Address resource, setting the domain name of that IP resource, and then setting the loadBalancerIp (in Kubernetes) to that IP.

PlasmaPower avatar Jan 25 '18 23:01 PlasmaPower

Aah gotcha. Thanks @PlasmaPower .

prashantchari avatar Jan 25 '18 23:01 prashantchari