Service Account Controller

What

What is the Service Account Controller?

The Service Account Controller is a component within the Kubernetes controller manager. It ensures that each namespace has a default service account and manages the lifecycle of service accounts and their associated secrets within a Kubernetes cluster.

What are the main responsibilities of the Service Account Controller?

What is the purpose of a service account in Kubernetes?

A service account provides an identity for processes that run in a pod, allowing them to interact with the Kubernetes API. It is used to control access and permissions within the cluster, following the principle of least privilege.

Why

Why is the Service Account Controller important?

Why does each namespace need a default service account?

Each namespace needs a default service account to ensure that any pod created without an explicitly specified service account can still interact with the Kubernetes API. This default service account provides basic permissions, which can be further refined using Role-Based Access Control (RBAC).

How

How does the Service Account Controller work?

  1. Monitoring: Continuously monitors the namespaces in the cluster.
  2. Creation: Automatically creates a default service account for any new namespace.
  3. Secret Management: Generates and attaches a secret containing the service account token to the service account.
  4. Synchronization: Ensures that service accounts and their secrets are kept in sync, updating or recreating them as needed to ensure proper functionality.

How do service accounts and their tokens get used in pods?

When a pod is created, it is assigned a service account (default or specified). The Kubernetes API server automatically mounts the secret containing the service account token into the pod, typically at /var/run/secrets/kubernetes.io/serviceaccount/token. This token is used by the pod to authenticate to the Kubernetes API.

How can you configure service accounts?

When

When does the Service Account Controller create a new service account?

The Service Account Controller creates a new service account whenever a new namespace is created and does not already have a default service account.

When might you need to manually intervene with service accounts?

Manual intervention might be needed when:

When should you consider creating custom service accounts?

You should consider creating custom service accounts when different applications or components within your cluster require distinct sets of permissions. This allows you to follow the principle of least privilege, granting only the necessary permissions to each service account.

#Kubernetes #ServiceAccount #ControllerManager #K8sSecurity #RBAC #DevOps #ClusterManagement #ContainerSecurity