How to access API from Postman with containerized app deployed in Azure Kubernetes Service

9/17/2020

I have created a sample API application with Node and Express to be containerized and deployed into Azure Kubernetes Services (AKS). However, I was unable to access the API endpoint through the external API generated from the service.yml that was deployed.

I have made use of deployment center within AKS to deploy my application to AKS and generate the relevant deployment.yml and service.yml. The following is the services running containing the external IP.

enter image description here

The following is the response from postman. I have tried with or without port number and ip address from kubectl get endpoints but to no avail. The request will timeout eventually and unable to access the api.

enter image description here

The following is the dockerfile config

enter image description here

I have tried searching around for solutions, how it was not possible to resolve. I would greatly appreciate if you have encountered similar issues and able to share your experience, thank you.

-- Richard Rodjues
azure
azure-aks
azure-container-registry
kubernetes

2 Answers

9/18/2020

As I see it you need to bring ingress in front of your service. Folks use NgInx etc. for that.

If you want to stay "pure" Azure you could use AGIC - Application Gateway Ingress Controller and annotate your service to have it exposed over AppGw. You could also spin up your own custom AppGw and hook it up with the AKS Service/LoadBalancer IP.

-- Kai Walter
Source: StackOverflow

9/18/2020

From client machine where kubectl is installed do

kubectl get pods -o wide -n restapicluster5ca2

this will give you all the pods with the ip of the Pods

kubectl describe svc restapicluster-bb91 -n restapicluster5ca2

this will give details about the service and then check LoadBalancer Ingress: for the external IP address, Port: for the port to access, TargetPort: the port on the containers to access i.e 5000 in your case, Endpoints: to verify if all IP of the pod with correct port i.e 5000 is displaying or not.

Log into any of the machines in the AKS cluster do the following

curl [CLUSTER-IP]:[PORT]/api/posts i.e curl 10.-.-.67:5000

check if you get the response.

For reference to use kubectl locally with AKS cluster check the links below 1. https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough 2. https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest

-- Himadri Ganguly
Source: StackOverflow