What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pipe Kubernetes JSON into jq whenever you need more than a simple field lookup: kubectl get <resource> -o json | jq '<filter>'. The -o json option emits a JSON-formatted API object, while jq can select, test, reshape and reformat that data without changing anything in the cluster.

Use the basic kubectl-to-jq pipeline

Start by asking kubectl for JSON and pass that stream to jq:

kubectl get pods -n production -o json | jq '.'

Replace pods and production with the resource and namespace you need. For namespaced resources, kubectl otherwise uses your current namespace, so include -n (or --namespace) in scripts and examples when the namespace matters. Cluster-scoped resources, such as nodes, do not use a namespace.

The pipeline is read-only: jq processes kubectl’s output locally. It does not create, update or delete Kubernetes objects.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Extract common fields with jq

List resource names

kubectl get pods -n production -o json 
  | jq -r '.items[].metadata.name'

The -r option writes strings without JSON quotes, which is convenient for shell loops or other command-line tools.

Print several values as tab-separated columns

kubectl get pods -n production -o json 
  | jq -r '.items[] | [.metadata.namespace, .metadata.name, .status.phase] | @tsv'

Select objects by a field value

kubectl get pods -n production -o json 
  | jq -c '.items[] | select(.status.phase == "Running")'

Use -c for compact one-object-per-line JSON, useful when the result is fed to another JSON-aware command.

Use regular expressions, which kubectl JSONPath cannot do

kubectl supports a JSONPath output format, but Kubernetes documents that regular expressions are not supported in its JSONPath implementation. The official alternative uses jq’s test() function:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
kubectl get pods -o json 
  | jq -r '.items[] | select(.metadata.name | test("test-")).metadata.name'

This prints pod names containing the regular expression test-. Anchor or expand the expression when necessary—for example, test("^api-[0-9]+$") matches names beginning with api- and ending in digits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See Kubernetes JSONPath Support for the documented limitation and example.

Transform Kubernetes data with jq

Convert a selector map into selector text

Kubernetes’ quick reference demonstrates turning a label-selector map into comma-separated selector text. The same pattern is:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
kubectl get rc my-rc -o json 
  | jq -r '.spec.selector | to_entries | map("(.key)=(.value)") | join(",")'

to_entries converts an object into key/value records; the interpolation creates strings such as app=web, and join combines them. This is useful when a later command expects selector syntax rather than a JSON object.

Find secret references in container environments

kubectl get pods -n production -o json 
  | jq -r '.items[] as $pod
    | $pod.spec.containers[]?.env[]?.valueFrom.secretKeyRef.name?
    | select(. != null)
    | [$pod.metadata.name, .] | @tsv'

The optional operators tolerate containers without an env array or entries without a secret reference. The output contains the pod name and referenced secret name. The kubectl Quick Reference includes jq patterns for inspecting nested secret references.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep only the fields another program needs

kubectl get deployments -n production -o json 
  | jq '[.items[] | {name: .metadata.name, desired: .spec.replicas, ready: (.status.readyReplicas // 0)}]'

The // 0 fallback makes an absent readyReplicas value explicit as zero in this report; it does not alter the Deployment.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Choose jq or kubectl JSONPath

Need Prefer Why
Select a straightforward field or format a small result kubectl JSONPath It is built into kubectl and supports documented field access, list iteration and filters.
Match names or values with regular expressions jq Kubernetes JSONPath does not support regular expressions; its documentation uses jq test() instead.
Reshape nested objects or build text for another command jq Functions such as select, map, to_entries, interpolation and join handle transformations directly.
Keep structured JSON for a later processing step kubectl ... -o json followed by jq -o json preserves the API object while jq performs the next transformation.

For a simple built-in extraction, JSONPath may be shorter:

kubectl get pods -n production -o=jsonpath='{range .items[*]}{.metadata.name}{"n"}{end}'

kubectl’s JSONPath syntax includes field access, filters and range/end. Its documented reference is JSONPath Support.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Quote filters for your shell

The examples above use POSIX-style shells such as Bash, where single quotes prevent the shell from interpreting jq’s punctuation. Keep the entire jq filter inside one quoted argument:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
kubectl get pods -o json | jq -r '.items[] | .metadata.name'

Windows command shells have different quoting rules, especially for templates containing spaces. Follow the shell-specific quoting guidance in the Kubernetes JSONPath documentation rather than copying Bash quoting unchanged.

Make namespace and resource scope explicit

  • Namespaced resources: specify -n <namespace> when the command must not depend on the user’s current namespace.
  • All namespaces: use --all-namespaces (or -A) where the resource supports it, then include .metadata.namespace in jq output to distinguish objects.
  • Cluster-scoped resources: omit the namespace flag; examples include nodes and persistent volumes.
  • Single objects: kubectl get pod api-0 -n production -o json returns one object, so address it directly (for example, .metadata.labels) instead of iterating over .items.

Version and failure considerations

kubectl’s command and output behavior should be checked against the versions you actually run. Kubernetes states that kubectl supports a version skew of plus or minus one minor version relative to the cluster control plane; consult the kubectl overview and the release-specific documentation when versions fall outside that range.

  • “Cannot iterate over null”: the field may be absent for some objects. Use optional access such as .env[]? or a fallback with //.
  • No output: verify the resource type, namespace, context and selector before debugging the jq filter.
  • Malformed JSON: run kubectl get ... -o json | jq empty to validate the stream, then inspect authentication or kubectl errors.
  • Unexpected shell errors: re-check quoting for the shell in use; jq filters and JSONPath templates are not quoted identically in every command environment.

For the output-format definition, see kubectl’s reference entry for -o json, documented as “Output a JSON formatted API object.”

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.