Kubernetes: Output Format

allowed formats are:

  • custom-columns
  • custom-columns-file
  • go-template
  • go-template-file
  • json
  • jsonpath
  • jsonpath-as-json
  • jsonpath-file
  • name
  • template
  • templatefile
  • wide
  • yaml
kubectl get deployments
kubectl get deployments test -o yaml > deploy-test.yaml
kubectl delete deployments test
kubectl apply -f deploy-test.yaml
kubectl get deployments -o json | jq ".items[].metadata.name, .items[].metadata.namespace"
kubectl get deployments -o jsonpath='{"NAME\n"}{range .items[*]}{.metadata.name}'
kubectl get deployments -o jsonpath='{"NAME\tNAMESPACE\n"}{range .items[*]}{.metadata.name}{"\t"}{.metadata.namespace}'
kubectl get secrets -o jsonpath='{.items[*].data.tls\.crt}' # Use \. to query key "tls.crt" 

References:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *