# Service accounts from Kubernetes

The Kubernetes connector can also add your cluster's **service accounts** to
your non-human identity inventory, and show which workloads run as each one.

This option is off by default. The connector itself is described in
[Kubernetes](./index.md).

## What you see in Mesh

- Each service account appears as a non-human identity of kind **Service
  account**, named `namespace/name`.
- The default service account of each namespace is labelled **default service
  account**.
- Each Deployment, StatefulSet, DaemonSet, Job and bare Pod is linked to the
  service account it runs as, in the **Permission flow** tab. A Job started by
  a CronJob appears as the Job.
- Kubernetes does not record owners, so these identities have no stated owner and
  show **No owner** unless Mesh suggests one. See
  [Suggested owners](../../../concepts/non-human-identity-data.md#suggested-owners).
- A deleted service account is marked deleted after the next complete
  collection, and restored if you recreate it.

![The Service accounts list under Non-human identities, showing each service account's type, connector, risk severity and when it was last updated](/img/connectors/crypto-kubernetes/k8s-sa-01-list.png)

![The Permission flow tab of a service account, showing the Deployment that runs as it](/img/connectors/crypto-kubernetes/k8s-sa-02-permission-flow.png)

## Permission to add

Add read access to service accounts to the read-only role you created for the
connector:

```yaml
- apiGroups: [""]
  resources: ["serviceaccounts"]
  verbs: ["list"]
```

Mesh does not read Kubernetes Secrets. Without this permission, a collection
reports incomplete.

## Turn it on in Mesh

1. On the **Connectors** page, open your Kubernetes connector for editing.
2. On the **Collection** tab, under **What Mesh reads**, in **Identities**, turn on
   **Service accounts**.
3. Save the connector.

Turning **Service accounts** off stops new links, but service accounts Mesh
already collected stay in Mesh.

## Troubleshooting

| Symptom | Likely cause | What to do |
| --- | --- | --- |
| No service accounts appear | **Service accounts** is off | Turn it on |
| The collection reports incomplete | The role cannot list `serviceaccounts` | Add the rule above |
| A workload has no **Permission flow** link | Its type is not listed above, or it has no Pods running, for example a Deployment scaled to zero | Expected; only the listed types are linked, and only while they have Pods |
