Unable to assign public static IP
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?
May be fixed with kubernetes/kubernetes#53557 but I'm not sure.
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
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.
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
For me the pending issue was solved by removing the optional ACI plugin
@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 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.
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 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.
Where can I find the public IP in Azure?
@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...
Oh, I had no idea that existed! Thanks!
Creating a public IP in the MC_* resource group also works.
@PlasmaPower that's great!!
This worked for me as well - thanks!
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..
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.
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.
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.
Aah gotcha. Thanks @PlasmaPower .