字段选择器

    • metadata.namespace!=default
    • status.phase=Pending

    下面这个 kubectl 命令将筛选出 字段值为 Running 的所有 Pod:

    1. Error from server (BadRequest): Unable to find "ingresses" that match label selector "", field selector "foo.bar=baz": "foo.bar" is not a known field selector: only "metadata.name", "metadata.namespace"

    你可在字段选择器中使用 ===!==== 的意义是相同的)操作符。 例如,下面这个 kubectl 命令将筛选所有不属于 命名空间的 Kubernetes 服务:

    1. kubectl get pods --field-selector=status.phase!=Running,spec.restartPolicy=Always

    你能够跨多种资源类型来使用字段选择器。 下面这个 kubectl 命令将筛选出所有不在 default 命名空间中的 StatefulSet 和 Service: