Anil Kumar P
Anil Kumar P

Reputation: 571

AKS public ip not accessible

I have below config in my ingress service:

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  namespace: nginx-ingress
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  loadBalancerIP: **.***.**.***
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    targetPort: 443
    protocol: TCP
    name: https
  selector:
    app: nginx-ingress

we have purchased this public ip from azure. If we remove this loadBalancerIP from service yaml and deploy and then use the ip listed by kubectl get services -n nginx-ingress, It works fine when we access the service end points. But with this public ip nothing seems to be working.

Please find below service description (kubectl describe service nginx-ingress -n nginx-ingress-os):

[openapianil@LHGOPENAPIDEV001 github]$ kubectl describe service nginx-ingress -n nginx-ingress-os
Name:                     nginx-ingress
Namespace:                nginx-ingress-os
Labels:                   <none>
Annotations:              kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"nginx-ingress","namespace":"nginx-ingress-os"},"spec":{"externalTrafficPolicy"...
Selector:                 app=nginx-ingress
Type:                     LoadBalancer
IP:                       10.0.0.44
IP:                       **.**.**.***
LoadBalancer Ingress:     **.**.**.***
Port:                     http  80/TCP
TargetPort:               80/TCP
NodePort:                 http  31247/TCP
Endpoints:                **.**.**.***:80
Port:                     https  443/TCP
TargetPort:               443/TCP
NodePort:                 https  32241/TCP
Endpoints:                **.**.**.***:443
Session Affinity:         None
External Traffic Policy:  Local
HealthCheck NodePort:     30880
Events:
  Type    Reason                Age   From                Message
  ----    ------                ----  ----                -------
  Normal  EnsuringLoadBalancer  1m    service-controller  Ensuring load balancer
  Normal  EnsuredLoadBalancer   43s   service-controller  Ensured load balancer

Please help!!

Upvotes: 4

Views: 9917

Answers (2)

David Jennings
David Jennings

Reputation: 1

I ran into this when working through the QuickStart The EXTERNAL-IP was listed as localhost if I didn't enable RBAC when created the AKS. Worked as expected when RBAC was enabled for me.

Upvotes: 0

Jason Ye
Jason Ye

Reputation: 13954

As we know, after AKS created complete, Azure will create two resource groups.

If you want to create service with IP address, you should create static IP address in another resource group, name like MC_myResourceGRoup_myAKSCluster_eastus.

You can use Azure CLI command to create public IP address:

az network public-ip create --resource-group MC_myResourceGRoup_myAKSCluster_eastus --name myAKSPublicIP --allocation-method static

Also you can use Azure portal to create it, but you can't add DNS to it.

Then you can use static IP address like this:

apiVersion: v1
kind: Service
metadata:
  name: azure-vote-front1
spec:
  type: LoadBalancer
  loadBalancerIP: 52.224.235.119
  ports:
  - port: 80
  selector:
    app: azure-vote-front1

Here is the result:

enter image description here

Note:

1.Create Azure public IP address without DNS name.
2.Create Azure public IP address in this resource group MC_myResourceGRoup_myAKSCluster_eastus.
3.You can use kubectl describe service to check the status, like this:

[root@jasoncli@jasonye jason]# kubectl describe service azure-vote-front1
Name:                     azure-vote-front1
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=azure-vote-front1
Type:                     LoadBalancer
IP:                       10.0.76.241
IP:                       52.224.235.119
LoadBalancer Ingress:     52.224.235.119
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  30416/TCP
Endpoints:                10.244.0.11:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason                Age   From                Message
  ----    ------                ----  ----                -------
  Normal  CreatingLoadBalancer  45m   service-controller  Creating load balancer
  Normal  CreatedLoadBalancer   44m   service-controller  Created load balancer

Update:

Here is my yaml file:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: azure-vote-back
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: azure-vote-back
    spec:
      containers:
      - name: azure-vote-back
        image: redis
        ports:
        - containerPort: 6379
          name: redis
---
apiVersion: v1
kind: Service
metadata:
  name: azure-vote-back
spec:
  ports:
  - port: 6379
  selector:
    app: azure-vote-back
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: azure-vote-front
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: azure-vote-front
    spec:
      containers:
      - name: azure-vote-front
image: microsoft/azure-vote-front:v1
        ports:
        - containerPort: 80
        env:
        - name: REDIS
          value: "azure-vote-back"
---
apiVersion: v1
kind: Service
metadata:
  name: azure-vote-front
spec:
  loadBalancerIP: 40.71.3.119
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: azure-vote-front

Upvotes: 2

Related Questions