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?

2 Answers 2

15

The command you listed will show you your resources.

Instead try: kubectl get serviceAccounts

4
  • 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
    Commented Aug 27, 2019 at 20:11
  • Are you trying to get all the information tied to that service account? If so check out the official docs here: kubernetes.io/docs/tasks/configure-pod-container/…. Otherwise you may want to look into kubernetes.io/docs/tasks/access-application-cluster/… for a dashboard or chain commands together (e.g. kubectl get --all-namespaces && kubectl get serviceAccounts) Commented Aug 27, 2019 at 20:15
  • Popeye helps... github.com/derailed/popeye
    – David West
    Commented Aug 27, 2019 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. Commented Dec 17, 2021 at 13:44
10
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.

1
  • 1
    This is what I was looking for, and worked for me. Thanks!
    – mkumar118
    Commented Apr 21, 2022 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.