Kubernetes security basics: RBAC, pod security and secrets

ExplainedKubernetesDevOps, Hands OnBy Cloud Hands On

Who can do what in a cluster, what pods are allowed to do, and how to handle passwords safely.

Security in a cluster has layers. Access to the API: people and pipelines sign in (on AKS, with Microsoft Entra ID), and RBAC decides what they may do, namespace by namespace. What pods may do: Pod Security Admission enforces the baseline or restricted standards per namespace (no privileged containers, no host access, run as non-root), and a pod's securityContext drops capabilities and makes the file system read-only.

Secrets are only base64-encoded, so protect them: limit who can read them, encrypt etcd, and prefer a vault (such as Key Vault through the CSI driver) with workload identity so pods never hold long-lived keys. NetworkPolicies limit which pods can talk, and image policies limit which registries pods can pull from.

Service accounts deserve attention: every pod runs as one, and its token is mounted by default. Turn off automounting where the app never calls the API, and give each app its own account with only the rights it needs.

Cost. Free to learn. Key Vault and Defender for Containers are charged in Azure.

Use it when

How it works

Authenticate
Who you are: Entra ID users, groups or workload identities.
Authorise
RBAC: Roles and bindings, as small as possible.
Admit
Pod Security Admission and policies reject unsafe pods.
Isolate
Namespaces, NetworkPolicies and separate node pools.
Protect secrets
Vaults, encryption at rest and tight read access.

Options

Baseline standard
Blocks the most dangerous settings; most apps pass.
Restricted standard
Strict hardening; some apps need changes.
Policy engines
Kyverno, Gatekeeper or Azure Policy for custom rules.

Example. Fernhill Cloud labels every app namespace pod-security.kubernetes.io/enforce: restricted, gives each team a RoleBinding to edit in its own namespace, and lets only the platform group read Secrets in kube-system.

Don't confuse it with

Namespaces
Organise and scope access, but aren't a hard security boundary on their own.
Container image scanning
Finds known flaws before deploy; admission controls what may run.

Words to know

Pod Security Admission
Built-in checks that enforce pod security standards per namespace.
securityContext
Pod and container settings such as runAsNonRoot and readOnlyRootFilesystem.
Workload identity
Lets a pod sign in to Azure as a managed identity without a stored secret.

Where to look

  1. kubectl auth can-i
  2. kubectl label namespace

Practise it

Read it in the guide, next to the tasks and labs.

Open in DevOps, Hands On

Keep going