0
votes

I have a kubernetes pod that consists on 1 nginx container and 1 alpine container. I want to test with hello world to be sure I can curl alpine from nginx. Can someone tell me how I could best test that?

Would I need to copy a file from the host to the pod, and how would I best do that if so?

1

1 Answers

1
votes

When you set up the nginx, set it up with a service in front of it and then you should be able to use curl from an interactive session on that alpine container, either as a dynamic pod that you run and kill, or using exec to open a session and do what you want.

There's a walk-through on how to run nginx as a stateless application using a deployment that you can follow for the first part of this, and then the docs on kubernetes services should give you a good idea on how to form up that service. You could also take a shortcut to make this service and simply use the command:

kubectl expose deployment nginx-deployment --port=80

which will match to that example deployment in the docs.

Once that service is created, it'll have a DNS entry that will be visible to other pods in that cluster. You can vet that pretty easily by using nslookup from the same Alpine container. You can run a quick'n'dirty interactive alpine container with:

kubectl run -it alpine-interactive --image=alpine -- sh

And then:

nslookup nginx-deployment.default

and

curl nginx-deployment.default should get you where you want.

(I wrote this up without an environment to double check, but hopefully it's reasonably close to accurate)