How to call service on pod in k8s cluster?

5/14/2020

I've been reading a lot about this and I don't really see why this isn't working for me. I created a k8s cluster on AWS. I created a hello-world nodejs app, dockerized it and hosted it on docker hub account. I created a pod file that points at this image and ran the command kubectl create pod with this file. I then ran the command

kubectl expose pod <pod-name> —type=NodePort —name=<service-name>

The pod then became exposed. I expected to be able to run the terminal command

curl http://<public IP of EC2>:<port>

and then see the "hello world" output. This does not happen though, nothing is returned. How do I call my hello world service from outside of the cluster with curl or postman?

-- Dan
kubernetes

0 Answers