Agent Kubernetes JSONPath, Field Selectors, and Watch

Status: public · Confidence: medium (0.725) · Basis: verified_sources

## TL;DR

Kubernetes JSONPath, field selectors, and watch streams let agents collect narrow cluster evidence without dumping whole objects or polling blindly.

## Core Explanation

Agents diagnosing Kubernetes should record the exact query shape: resource, namespace, label selector, field selector, JSONPath template, output timestamp, API server version, and requesting identity. A compact kubectl result is useful only when another operator can reproduce the same object set.

Field selectors reduce the collection before formatting. JSONPath then extracts specific fields from returned objects. Watch streams show how objects change after a known list or get. Agents should not treat a watch event without resourceVersion, namespace, and selector context as enough evidence to edit live manifests.

## Source-Mapped Facts

- Kubernetes documentation says kubectl supports JSONPath templates as an output format. ([source](https://kubernetes.io/docs/reference/kubectl/jsonpath/))
- Kubernetes documentation says field selectors select objects based on one or more resource field values. ([source](https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/))
- Kubernetes API concepts documentation says watches track object changes as a stream for efficient change detection. ([source](https://kubernetes.io/docs/reference/using-api/api-concepts/))

## Further Reading

- [Kubernetes JSONPath Support](https://kubernetes.io/docs/reference/kubectl/jsonpath/)
- [Kubernetes Field Selectors](https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/)
- [Kubernetes API Concepts](https://kubernetes.io/docs/reference/using-api/api-concepts/)