Difference between revisions of "Jsonpath"

From wikieduonline
Jump to navigation Jump to search
Line 11: Line 11:
 
  [[kubectl get pods]] YourPOD -o jsonpath='{.spec.containers[*].name}'
 
  [[kubectl get pods]] YourPOD -o jsonpath='{.spec.containers[*].name}'
  
  export POD_NAME=$(kubectl get pods --namespace default [[-l]] "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
+
  export POD_NAME=$([[kubectl get pods]] --namespace default [[-l]] "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
  
 
== See also ==
 
== See also ==

Revision as of 10:35, 25 July 2022

kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
Tjp67Ib3c2PxvGoD6SH1pjTtnlq6X4XvrXo4xxx
kubectl get pods --selector=app=your-app-name -o=jsonpath='{.items[0].metadata.name}'

List all containers in all pod:

kubectl get pods -o jsonpath='{range .items[*]}{"pod: "}{.metadata.name}{"\n"}{range .spec.containers[*]}{"\tname: "}{.name}{"\n\timage: "}{.image}{"\n"}{end}'

List all containers in a pod:

kubectl get pods YourPOD -o jsonpath='{.spec.containers[*].name}'
export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")

See also

Advertising: