<p>How do I get a pod's name from its IP address?  What's the magic incantation of <code>kubectl</code> + <code>sed</code>/<code>awk</code>/<code>grep</code>/etc regardless of where <code>kubectl</code> is invoked?</p>

<h3>Example:</h3>

<pre><code>kubectl get pods -o wide
NAME                               READY     STATUS    RESTARTS   AGE       IP            NODE
alpine-3835730047-ggn2v            1/1       Running   0          5d        10.22.19.69   ip-10-35-80-221.ec2.internal 
</code></pre>

<h3>get pod name by IP</h3>

<pre><code>kubectl get --all-namespaces  --output json  pods | jq '.items[] | select(.status.podIP=="10.22.19.69")' | jq .metadata.name
"alpine-3835730047-ggn2v"
</code></pre>

<h3>get container name by IP</h3>

<pre><code>kubectl get --all-namespaces  --output json  pods | jq '.items[] | select(.status.podIP=="10.22.19.69")' | jq .spec.containers[].name
"alpine"
</code></pre>
