Reputation: 77
When I login to openshift URL, under the URL/console/projects I can see all proejcts and who created them and when.
e.g.
:
actually
created by assafav 22 days ago
aggrdep
created by INNATR 22 days ago
:
how can i get this information using the oc cli?
I've tried "oc status -v
" "oc describe all
"
I'm using versions:
oc v3.10.14
kubernetes v1.10.0+b81c8f8
openshift v3.11.51
kubernetes v1.11.0+d4cacc0
Thanks
Upvotes: 0
Views: 2436
Reputation: 3573
oc get projects
works the same as any other oc get
command. It's important to know the full flexibility of this command, specifically the --output
flag:
$ oc get -h
...
-o, --output='': Output format. One of:
json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...
See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template
[http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template
[http://kubernetes.io/docs/user-guide/jsonpath].
...
In this case, oc get projects -o custom-columns
will likely be the best approach, although others like jsonpath
or go-template
will provide even more flexibility in controlling the output in case you want to use another delimiter instead of tabs.
Selecting a single project and outputting it as yaml, oc get project <project-name> -o yaml
will show you the full array of values that you are able to display.
To answer your specific question, on OpenShift the project creator is stored in a metadata annotation, openshift.io/requester
, and the creation timestamp is also stored in the metadata. To display the project name, creator, and creation timestamp on the command line, you can do so with:
oc get projects -o custom-columns=NAME:.metadata.name,OWNER:.metadata.annotations.openshift\\.io/requester,CREATED:.metadata.creationTimestamp
(Note the \\
is necessary to escape the .
in openshift.io
)
Upvotes: 2
Reputation: 3571
$ oc status
will give you status of current project you are in.
To view list of projects current login has access to use
$ oc get projects
Note : you are restricted to listing only the projects with authorization.
To Change to project use
$ oc project <project_name>
Once switched with above command you can get overview of the current project using
$ oc status
Upvotes: -1