The kubernetes documentation includes an example command for listing container images by pod:
List Container images by Pod
The formatting can be controlled further by using the range operation to iterate over elements individually.
kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |\ sort
When I run this command in my Debian WSL2 instance, it correctly lists the containers for each pod I have running across all namespaces.
When I run the same command in the Windows commandline, I get an error: error: a resource cannot be retrieved by name across all namespaces
:
C:\workspace>kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' | sort
error: a resource cannot be retrieved by name across all namespaces
Is this a bug with kubectl, or is this command *nix only? Is there an OS-independent command for getting container images by pod across all namespaces?
(I'm running Debian on WSL2, Windows 10 Enterprise. Docker Desktop using WSL2 integration, K8S with minikube.)
kubectl get pods --all-namespaces
it works? – Sahadat Hossainjsonpath
; if I specify a namespace with-n <namespace>
, it gives an error:error parsing jsonpath '{range, unclosed action
. – Roddy of the Frozen Peas