Skip to content

Instantly share code, notes, and snippets.

@fulvi0
Forked from bu3ny/ocp4_all_resources.md
Created March 8, 2022 13:05
Show Gist options
  • Select an option

  • Save fulvi0/2f4fe112e638d0351d3b6dfa9cca3c50 to your computer and use it in GitHub Desktop.

Select an option

Save fulvi0/2f4fe112e638d0351d3b6dfa9cca3c50 to your computer and use it in GitHub Desktop.

Revisions

  1. @luckylittle luckylittle revised this gist Mar 12, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ocp4_all_resources.md
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,4 @@
    ## List every single namespaced resource in a namespace
    `oc get $(oc api-resources --namespaced=true --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found -n ${NAMESPACE} -o=custom-columns=KIND:.kind,NAME:.metadata.name --sort-by='kind'`

    _Note: `oc get all` inside namespace does not really show "all" and the above commands will fill those gaps.
    _Note: `oc get all` inside namespace does not really show "all" and the above commands will fill those gaps._
  2. @luckylittle luckylittle revised this gist Mar 12, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ocp4_all_resources.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@
    `oc get $(oc api-resources --namespaced=false --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found --all-namespaces -o=custom-columns=KIND:.kind,NAME:.metadata.name --sort-by='kind'`

    ## List every single namespaced resource in a namespace
    oc get $(oc api-resources --namespaced=true --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found -n ${NAMESPACE} -o=custom-columns=KIND:.kind,NAME:.metadata.name --sort-by='kind'
    `oc get $(oc api-resources --namespaced=true --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found -n ${NAMESPACE} -o=custom-columns=KIND:.kind,NAME:.metadata.name --sort-by='kind'`

    _Note: `oc get all` inside namespace does not really show "all" and the above commands will fill those gaps.
  3. @luckylittle luckylittle created this gist Mar 12, 2021.
    17 changes: 17 additions & 0 deletions ocp4_all_resources.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # How can I list all resources and custom resources in OpenShift
    ## List all CRDs with CR name and Scope
    `oc get crd -o=custom-columns=NAME:.metadata.name,CR_NAME:.spec.names.singular,SCOPE:.spec.scope`

    ## List every single custom resources in the cluster
    `oc get $(oc get crd -o=custom-columns=CR_NAME:.spec.names.singular --no-headers | awk '{printf "%s%s",sep,$0; sep=","}') --ignore-not-found --all-namespaces -o=custom-columns=KIND:.kind,NAME:.metadata.name,NAMESPACE:.metadata.namespace`

    ## List every single resource in the cluster (custom and non-custom)
    `oc get $(oc api-resources --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found --all-namespaces -o=custom-columns=KIND:.kind,NAME:.metadata.name,NAMESPACE:.metadata.namespace --sort-by='metadata.namespace'`

    ## List every single non-namespaced resource in the cluster
    `oc get $(oc api-resources --namespaced=false --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found --all-namespaces -o=custom-columns=KIND:.kind,NAME:.metadata.name --sort-by='kind'`

    ## List every single namespaced resource in a namespace
    oc get $(oc api-resources --namespaced=true --verbs=list -o name | awk '{printf "%s%s",sep,$0;sep=","}') --ignore-not-found -n ${NAMESPACE} -o=custom-columns=KIND:.kind,NAME:.metadata.name --sort-by='kind'

    _Note: `oc get all` inside namespace does not really show "all" and the above commands will fill those gaps.