Is it possible to display Kubernetes (K8s) resources from multiple specified namespaces
with only the CLI (kubectl
)?
In other words, given two namespaces
in a K8s cluster:
kubectl get namespaces \
--output=go-template \
--template='{{ range .items }}{{ .metadata.name }}{{ "\n" }}{{ end }}'
#=>
. . .
$SOME_NAMESPACE
. . .
$ANOTHER_NAMESPACE
. . .
would it be possible to get
resources (such as pods
) from only those two namespaces
($SOME_NAMESPACE
and $ANOTHER_NAMESPACE
) using only kubectl
?
Supplying the --all-namespaces
flag and filtering using either the --field-selector
or --selector
flags will not work, because both flags accept only =
, ==
and !=
operators.