I know I can get the pods using:
kubectl get pods -n "namespace", and also to retrieve a json output
I'm trying to expand to get the pods name, the associated images, and a label attribute called 'base'. Also the date when I retrieve this information.
probably you can write shell script and achieve this. first try to get all running pods across all namespaces using:
kubectl get pods -all-namespaces
and then iterate over each pod and execute following command:
kubectl describe pods <name of pod>
In the describe command you can get all information that you are looking for.
You can try this using yaml output.
kubectl get pods --all--namespaces -o yaml| egrep "name:|image:"
This will give you name of pod and image which is there for running the pod.
OR
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}"
This command will give you all images which are there in all pods.
If you found this is difficult then use,
kubectl get pod --all-namespaces
Check which pods image you need to find then use,
kubectl describe pod <pod_name> -n <namespace>
For reference use Link
You can try jsonpath to retrieve the values for json output.
kubectl get po --all-namespaces -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\t"}{.metadata.labels.k8s-app}{"\n"}{end}'
Here you can find the description of kubectl get
command. What are you looking for is this:
output o Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...
See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
For example:
List a pod identified by type and name specified in "pod.yaml" in JSON output format:
kubectl get -f pod.yaml -o json
Adjust by using the flags that you need from there.
Please let me know if that helped.