I deployed a service on kubernetes and then I wanted to test it out inside the cluster itself, before I put an ingress rule to access it outside.
So, after I verified from the log that the service is running.
I tried to create a pod and get to the shell in it via
kubectl run -i --tty ubuntu --image=ubuntu --restart=Never -- sh
This seems to work fine. I am shown an ubuntu shell, and it seems to work fine.
But then if I do a curl: example
curl --location --request GET 'http://127.0.0.1:9000/hello'
I get a response
sh: 4: curl: not found
So then I tried,
apt-get install curl
which gives me:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package curl
Thought this was because of sudo. so I did sudo apt-get install curl
, but that tells me
sh: 6: sudo: not found
Tried installing sudo with apt-get install sudo
but that just gives
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package sudo
What am I missing here?
It seems I just needed to update apt-get.
It seems when you do get into such a pod, you are working in as root user. Just do apt-get update
and then later you can do apt-get install curl
. And that works.
And if yours is an alpine one, instead of apt, it would be
apk add curl