Bootstrap FreeKB - OpenShift - List Service Accounts
OpenShift - List Service Accounts

Updated:   |  OpenShift articles

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

Typically, Service Accounts are associated with a Security Context Constraint (SCC) and then one or more deployments are configured have the Service Account to control certain things that the deployment is and is not allowed to do. Check out my article Run a deployment with a Service Account and Security Context Constraint.

The oc get serviceaccounts (or just oc get sa) command can be used to list the Service Accounts that have been created in the current project / namespace. By default, each namespace should contain the builder, default, and deployer Service Accounts.

~]$ oc get serviceaccounts
NAME                 SECRETS   AGE
builder              2         224d
default              2         224d
deployer             2         224d
my-servie-account    2         55d


The oc describe serviceaccount command can be used to show more details of a specific Service Account.

~]$ oc describe serviceaccount default
Name:                default
Namespace:           default
Labels:              <none>
Annotations:         <none>
Image pull secrets:  default-dockercfg-t9sz2
Mountable secrets:   default-token-tczbb
Tokens:              default-token-cnkj6
Events:              <none>


Or, the oc get serviceaccounts command with the --output json‚Äč or --output yaml option can be used.

~]$ oc get serviceaccount default --output yaml
apiVersion: v1
- name: default-dockercfg-t9sz2
kind: ServiceAccount
  creationTimestamp: "2021-07-16T17:10:00Z"
  name: default
  namespace: default
  resourceVersion: "10939"
  uid: ea72affa-09a5-41c7-bf8b-6407fb27eebe
- name: default-token-tczbb
- name: default-dockercfg-t9sz2


Did you find this article helpful?

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


Add a Comment

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