Accessing a port on a pod

With kubectl, you can just forward a specific port of some pod to your local machine. So you can test the pod. A simple example:

# Start a grafana pod
kubectl run grafana --image=grafana/grafana
POD=$(kubectl get pod -l run= grafana \ 
    -o jsonpath="{.items[0].metadata.name}")

# Forward port 3000
kubectl port-forward $POD 3000:3000 &

# Access port
curl -s http://localhost:3000/login | grep title


Leave a comment

Your email address will not be published. Required fields are marked *