Kenny_I
Kenny_I

Reputation: 2503

Why external IP of AKS is not working? Something wrong with yaml?

I try to deploy simple API to AKS. API works fine in local docker. I get no errors. I see from AKS that status is running. However browser does not respond. Could someone check yaml or give tip what could be wrong?

C:\Azure\ACIPythonAPI\conda-flask-api> kubectl get service demo-flask-api --watch
NAME             TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)        AGE
demo-flask-api   LoadBalancer   10.0.105.135   11.22.33.44   80:31551/TCP   5m53s

aks.yaml file:

apiVersion: v1
kind: Service
metadata:
  name: demo-flask-api
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: demo-flask-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-flask-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo-flask-api
  template:
    metadata:
      labels:
        app: demo-flask-api
    spec:
      containers:
      - name: demo-flask-api
        image: mycontainerregistry.azurecr.io/demo/flask-api:v1
        ports:
        - containerPort: 8080

Upvotes: 0

Views: 1126

Answers (1)

Philip Welz
Philip Welz

Reputation: 2807

Seems you did not defined a Ingress resource nether an Ingress Controller.

Here is a Workflow from MS to install ingress-nginx as Ingress Controller on your Cluster.

You then expose the IC service like this:

apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-resource-group: myResourceGroup # only needed if the LB is in another RG
  name: ingress-nginx-controller
spec:
  loadBalancerIP: <YOUR_STATIC_IP>
  type: LoadBalancer

The Ingress Controller then will route incoming traffic to your demo flask API with an Ingress resource:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
spec:
  ingressClassName: nginx # ingress-nginx specifix
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

Upvotes: 2

Related Questions