Cannot Use a static IP address outside of the node resource group

2/22/2019

I am trying to use a static ip address for the dashboard that is created outside of the node resource group following the guide located here, but it is not working. (This is for a firewalled dev-only cluster and won't go to production.)

What I have done so far:

  1. Created a public ip address in resourcegroup1
  2. Create an AKS cluster in resourcegroup1 tied to a azure ad application.
  3. Added the azure ad application's service principal as a "Network Contributer" in resourcegroup1.
  4. Added service.beta.kubernetes.io/azure-load-balancer-resource-group: resourcegroup1 to my service.yaml file.
  5. Added loadBalancerIP with the ip address from step 1.

Whenever I apply service.yaml, the service says it's in a pending state. When I run kubectl describe service, it shows the following output:

Name:                        kubernetes-dashboard
Namespace:                   kube-system
Labels:                      <none>
Annotations:                 externalTrafficPolicy=Local
                             service.beta.kubernetes.io/azure-load-balancer-resource-group=resourcegroup1
Selector:                    k8s-app=kubernetes-dashboard
Type:                        LoadBalancer
IP:                          10.0.42.112
IP:                          <IP FROM STEP 1>
Port:                        <unset>  80/TCP
TargetPort:                  9090/TCP
NodePort:                    <unset>  31836/TCP
Endpoints:                   10.244.0.6:9090
Session Affinity:            None
External Traffic Policy:     Cluster
LoadBalancer Source Ranges:  <SNIPPED>
Events:
  Type     Reason                      Age               From                Message
  ----     ------                      ----              ----                -------
  Normal   EnsuringLoadBalancer        38s (x6 over 3m)  service-controller  Ensuring load balancer
  Warning  CreatingLoadBalancerFailed  38s (x6 over 3m)  service-controller  Error creating load balancer (will retry): failed to ensure load balancer for service kube-system/kubernetes-dashboard: user supplied IP Address <IP FROM STEP 1> was not found

Here is my service.yaml

apiVersion: v1
kind: Service
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-resource-group: resourcegroup1
spec:
  type: LoadBalancer
  loadBalancerIP:  <IP FROM STEP 1>
  ports:
  - port: 80
    protocol: TCP
    targetPort: 9090
  selector:
    k8s-app: kubernetes-dashboard
  loadBalancerSourceRanges:
  - <SNIP>
  - <SNIP>
-- randomsolutions
azure-kubernetes

2 Answers

2/26/2019

My AKS cluster was 1.9.x which was older than the required 1.10.x. I was using Terraform to create the cluster and there appears to be a bug with how a missing kubernetes_version is handled. I submitted an issue on their repo.

-- randomsolutions
Source: StackOverflow

2/25/2019

For the error you got, it means the public IP cannot be found in the resourcegroup1 with the same region as the AKS. Different region causes the error like this as yours:

enter image description here

So you should create public IP in the same region with your AKS. Then it will work for you.

-- Charles Xu
Source: StackOverflow