Skip to content

Instantly share code, notes, and snippets.

@saadlu
Last active December 1, 2021 15:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saadlu/0bd2b8874efe48c23a08a86b64bb5a01 to your computer and use it in GitHub Desktop.
Save saadlu/0bd2b8874efe48c23a08a86b64bb5a01 to your computer and use it in GitHub Desktop.
useful kubectl/oc jsonpaths
  1. Print containers of a pod

    oc get pod <pod_name> -o jsonpath='{.spec.containers[*].name}{"\n"}' | tr ' ' '\n'
  2. IBM Chart repo URI

     export ibm_entitled_charts=$(cloudctl catalog repos --json | jq '.[] | select(.name=="ibm-entitled-charts").URL')
  3. Export secret without --export

    With yq

    oc -n <from-ns> get secret <name-of-secret> -o yaml | yq d - metadata | yq w - metadata.name <name-of-secret> | oc -n <to-ns> create -f -

    with jq

    oc -n <from-ns> get secret <name-of-secret> -o json | jq 'del(.metadata) | .metadata.name="<name-of-secret>"' | oc -n <to-ns> create -f -
  4. Get names of resource by custom columns

    oc get tr -o=custom-columns=':metadata.name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment