Search code examples
node.jsazureload-balancingazure-load-balancer

Allow Node.js app to talk to a pod on a Kubernetes Cluster


I have a Node.js app in Azure and I want it to be able to connect/talk to a pod on a kubernetes cluster (this pod has an external IP and is a load balancer). On click of a submit button on my Node.js app, I want to be able to send bash commands to the pod on the Kubernetes cluster.

Would you know how I could connect the app to the pod? I know there is server.listen function in the index.js file, however I am not too sure how to approach the situation.

Thanks for the help


Solution

  • Not sure, but you can connect the pod in a Kubernetes Cluster as you connect the Database or other services as usual in the Node.js app.

    All of all, you should get the credential of the AKS through the command az aks get-credentials to create a tunnel with the Kubernetes Cluster. Then you can use the command kubectl exec to execute the bash shell command in the pod.

    Also, you can take a look at Executing commands in Pods using K8s API, maybe it would be helpful.

    Here are the examples that manage the pod in the Kubernetes CLuster pod. See kubernetes-client.