>_ IzzyLab

Hands-on task

This task is step 11 of the course “Kubernetes: manifests from Namespace to RBAC”

k8s: ServiceAccount for a pod

medium~5 min

In /root/sa.yaml (two documents separated by ---) there are a ServiceAccount robot and a Pod worker, but the pod runs under the default ServiceAccount. Fix the manifest: make worker run under the ServiceAccount robot (the serviceAccountName field). Edit the file in the Editor tab.

What you'll practise:
  • kubernetes
  • serviceaccount
  • pod
  • yq
  • rbac

Topic breakdown

A ServiceAccount is the identity under which a process inside a pod talks to the Kubernetes API; it's what permissions are bound to via Role/RoleBinding. If a pod isn't explicitly assigned an SA, it gets default from its namespace. The binding is set via a field in the POD's spec (not in the ServiceAccount object) — it specifies the name of the desired account. Within a single YAML file, multiple objects are separated by a --- line, and the document you need to edit is the one with kind: Pod.

What's checked

  1. both manifests are valid (kubeconform)
  2. ServiceAccount robot is defined
  3. pod uses serviceAccountName robot

What it looks like