SIDEBAR – JSONPATH

We might look up the specific Pod using a command like the following:

kubectl get pods -l app=flask

This will find just the pods matching the app=flask selector and print out human-readable output akin to the following:

NAME                     READY     STATUS    RESTARTS   AGEflask-2376258259-p1cwb   1/1       Running   0          8m

This same data is available in a structured form (JSON, YAML, and so on) that we can parse with tools such as jq. Kubectl includes two additional options to make it a more convenient tool—you can use JSONPATH or GO_TEMPLATE to dig out specific values. With JSONPATH built into the kubectl client instead of doing the preceding two-step process to get the Pod name, you can directly get the specific details we want to use, which is the name: ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.