16

How do I show all service accounts In Kubernetes?

I have tried kubectl get --all-namespaces all. It does not show service accounts.

How can I use kubectl to list all service accounts?

David West
  • 1,463
  • 3
  • 16
  • 25

2 Answers2

15

The command you listed will show you your resources.

Instead try: kubectl get serviceAccounts

Wesley Rolnick
  • 2,747
  • 11
  • 26
  • Is there a way to get everything? I actually want to see resources, service accounts, cluster role bindings, everything. I am trying to clean up my nodes and would appreciate a way to get a birds eye view. – David West Aug 27 '19 at 20:11
  • Are you trying to get all the information tied to that service account? If so check out the official docs here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/. Otherwise you may want to look into https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/ for a dashboard or chain commands together (e.g. kubectl get --all-namespaces && kubectl get serviceAccounts) – Wesley Rolnick Aug 27 '19 at 20:15
  • Popeye helps... https://github.com/derailed/popeye – David West Aug 27 '19 at 20:24
  • 4
    if your serviceAccount is not in your current namespace you should use -A for looking on all your namespaces or target an specific one with -n=foobar if you know in which namespace is your resource. – Juan-Kabbali Dec 17 '21 at 13:44
9

kubectl get sa --all-namespaces

This will only provide the service accounts.

In general, you can have a comma separated list of resources to display.

Example:

kubectl get pods,svc,sa,deployments [-FLAGS]

The FLAGS would apply to all the resources.

Tanish Islam
  • 106
  • 1