In all Kubernetes resource list buffers, you can use /
(kubed-list-set-filter
) to filter the list of resources.
This command sets the filter of the current buffer, which specifies
conditions on resources (lines). Resources that don’t satisfy the
conditions are hidden, so you can focus on those that do.
Filters can be simple (atomic filters) or complex (composed filters). In the simple case, you enter a filter in the minibuffer in the format ‘op col val’, where op is a comparison operator, one of ‘=’, ‘~’, ‘<’ and ‘>’; col is a column name; and val is a value to compare to values of col with op.
If op is ‘=’, it says to keep only lines whose col equals val. If op is ‘~’, it says to keep lines whose col matches the val as a regular expression. ‘<’ and ‘>’ compare column values to numeric values. For example, the filter ‘= Name foobar’ keeps only resources whose name is ‘foobar’. To include whitespace in val, wrap val in double quotes: ‘= Name "foo bar"’.
The possible values of op and their meanings are defined in
kubed-list-filter-operator-alist
, which is a user option you
can use to add or change the meaning of filter operators:
Association list of filter operators and corresponding Emacs Lisp functions. See the documentation string of this option for specifics.
You can use more refined filters by composing simple filters. To add another filter that resources must satisfy, wrap your two filters in parentheses and put them next to each other:
(= Name foobar) (~ Namespace kube)
This filter keeps only resources whose name is ‘foobar’ in namespaces that include ‘kube’ as a substring, it expresses the conjunction of the two simple filters.
To negate a simple filter, put a single quote ahead of it, like so:
(= Name foobar) '(~ Namespace kube)
This matches resources named ‘foobar’ in namespaces that do not contain ‘kube’.
To specify a disjunction of simple filters (and negated simple filters), add another level of nesting:
((= Name spam) (= Name foobar)) '(~ Namespace kube)
This filter matches resources named either ‘spam’ or ‘foobar’, in namespaces that do not contain ‘kube’.
While entering a filter in the minibuffer, TAB completion is available for column names and values. To clear the filter, just exit the minibuffer with an empty input.