The 4Cs
Security is four layers, each inside the next
Cloud, cluster, container, code: each is only as safe as the layer around it.
Cloud native security is taught as four layers, the four Cs. The outside layer is the cloud: the accounts, the networks and the machines themselves. Inside it is the cluster. Who can reach the A P I server, what they may do, and which pods may talk. Inside that is the container. Is the image trusted, and does it run as root? And in the middle is your code. A weakness in an outer layer undoes every layer inside it, so you defend all four.
The 4Cs · Going deeper
What protects each layer
Each layer has its own threats and controls. Trivy scans, Falco watches at runtime.
RBAC
Who, bound to what they may do
A Role lists permissions. A RoleBinding gives it to a subject. Nothing else is allowed.
Inside the cluster, access is decided by role based access control. A role is a list of permissions: here, get, list and watch pods, in the namespace dev. A subject is who is asking: a user, a group, or a service account, which is the identity of a pod. A role binding joins them. That is the grant. So this account can list the pods in dev. It cannot delete one, and it can do nothing in prod, because no role says it may.
RBAC · Going deeper
The request path and the RBAC objects
Authentication, authorization, then admission control.
Check yourself
The request in the last row arrives. What happens?
Pod security
Three levels of what a pod may ask for
Privileged, Baseline, Restricted: each allows less than the one before.
A pod can ask for dangerous things, such as a privileged container, or the network of the node itself. The pod security standards define three levels. Privileged allows everything. It is meant for system add-ons only. Baseline blocks the known ways out of a container, but still lets a process run as root. Restricted blocks all of these. It is today's hardening practice. You choose a level for each namespace with a label.
Pod security · Going deeper
Security contexts and Secrets
A security context hardens one pod. A Secret is encoded, not encrypted.
Troubleshooting
The status says where the pod is stuck
Pending, ImagePullBackOff, CrashLoopBackOff, or running but not ready.
Now troubleshooting. A pod starts in four stages, and each has its own way to fail. First it is scheduled. If no node fits, it stays pending. Then the image is pulled. A wrong name or tag, or no access to the registry, gives image pull back off. Then the container starts. If the process keeps exiting, you see crash loop back off. Last, it must pass its readiness probe. Until it does, it runs, but receives no traffic.
Troubleshooting · Going deeper
Statuses, meanings and where to look
Each status points to one kind of cause. OOMKilled is exit code 137.
Check yourself
What is the most likely cause?
Debugging commands
Three questions, three commands
describe for events, logs for the application's output, exec to look inside.
Three commands solve most problems. Why did it not start? Describe the pod, and read the events at the bottom: scheduling, image pulls, failed probes. What did the application say? Read its logs. For a container that crashed, add previous, to see the run that died. What is true inside? Exec opens a shell in the running container, so you can check files, D N S and connections yourself.
Debugging commands · Going deeper
Clue words for security and troubleshooting
RBAC, ServiceAccount, Pending and CrashLoopBackOff.
Check yourself
Which change gets this pod running?
Lesson complete
You finished “Security and troubleshooting”
Answer the questions along the way to see your score here.