I have redis in a pod, and wanted to connect to it to see some usage stats this morning.
My initial, naive attempt was to hit
redis directly, thinking maybe the k8s master maps these internal hostnames out to the host; no bueno.
Next I tried connecting to the pod directly via
kubectl exec -it pod/redis-123812739 sh but once I get in there I cannot
telnet because that isn’t installed. I could’ve installed telnet, but I didn’t want to add custom stuff to a k8s-managed container.
Finally I recalled that I had used port forwarding in the past, so after a bit of searching, I issued the following command:
kubectl --namespace=khoisan port-forward pod/redis-12354-123123 8888:6379
I had to background it with ctrl-Z, but after that, I could do
telnet localhost 8888 and get to redis.