Bootstrap FreeKB - OpenShift - List projects using the oc get namespaces command
OpenShift - List projects using the oc get namespaces command

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

There are a few similar commands that can be used to list each project / namespace in your OpenShift cluster.

The oc get namespaces command can be used to return each project / namespace in your OpenShift cluster. Something like this should be returned.

 ~]$ oc get namespaces
NAME                             STATUS   AGE
my-project                       Active   4y117d
foo-project                      Active   4y117d
bar-namespace                    Active   4y117d
default                          Active   4y122d

 

The oc describe namespace command can be used to display details for a specific namespace.

~]$ oc describe namespace my-project
Name:         my-project
Labels:       kubernetes.io/metadata.name=my-project
              pod-security.kubernetes.io/audit=baseline
              pod-security.kubernetes.io/audit-version=v1.24
              pod-security.kubernetes.io/warn=baseline
              pod-security.kubernetes.io/warn-version=v1.24
Annotations:  openshift.io/description:
              openshift.io/display-name:
              openshift.io/requester: john.doe
              openshift.io/sa.scc.mcs: s0:c33,c22
              openshift.io/sa.scc.supplemental-groups: 1001100000/10000
              openshift.io/sa.scc.uid-range: 1001100000/10000
Status:       Active

Resource Quotas
  Name:     thrivent-pod-quota
  Resource  Used  Hard
  --------  ---   ---
  pods      0     150

Resource Limits
 Type       Resource           Min  Max  Default Request  Default Limit  Max Limit/Request Ratio
 ----       --------           ---  ---  ---------------  -------------  -----------------------
 Container  cpu                1m   1    5m               300m           -
 Container  memory             4Mi  2Gi  16Mi             256Mi          -
 Container  ephemeral-storage  -    -    1Mi              1Gi            -
 Pod        ephemeral-storage  -    3Gi  -                -              -

 

Or the oc get namespace with the --output json or --output yaml option can be used.

~]$ oc get namespace my-project --output yaml
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    openshift.io/description: ""
    openshift.io/display-name: ""
    openshift.io/requester: john.doe
    openshift.io/sa.scc.mcs: s0:c33,c22
    openshift.io/sa.scc.supplemental-groups: 1001100000/10000
    openshift.io/sa.scc.uid-range: 1001100000/10000
  creationTimestamp: "2025-01-14T02:08:04Z"
  labels:

    kubernetes.io/metadata.name: my-project
    pod-security.kubernetes.io/audit: baseline
    pod-security.kubernetes.io/audit-version: v1.24
    pod-security.kubernetes.io/warn: baseline
    pod-security.kubernetes.io/warn-version: v1.24
  name: my-project
  resourceVersion: "1962094450"
  uid: 5a75ea4c-adc7-43e5-9960-eeaffc8affe4
spec:
  finalizers:
  - kubernetes
status:
  phase: Active

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter b6b4d1 in the box below so that we can be sure you are a human.