Architecture, how a request flows, and the core objects, with diagrams.
You cannot secure Kubernetes well without knowing how it works. This part covers the basics that Parts 2 and 3 build on, and notes why each piece matters for security.
A container packages an app with everything it needs to run. Running one is easy. Running hundreds across many machines is not:
Kubernetes (K8s) is a container orchestrator that handles all of this. You describe what you want ("run 3 copies of this image and expose port 80"), and Kubernetes keeps working to make the cluster match. It constantly compares the desired state with the actual state and fixes any difference. Most of what follows is built on that idea.
A cluster has a control plane, which makes decisions, and worker nodes, which run your apps.
kubectl, controllers, the scheduler and kubelets all go through it. It authenticates, authorizes and validates every request, and is the only component allowed to read and write etcd.| Component | Port | What an attacker gains |
|---|---|---|
| kube-apiserver | 6443 | Whoever authenticates here with enough RBAC rights controls the cluster. Anonymous access or an over-privileged token is the usual way in. |
| etcd | 2379 / 2380 | Direct read access exposes every Secret. Write access allows tampering with any object. It should accept only API server connections, with mutual TLS. |
| kubelet | 10250 | If its API allows anonymous or weakly authorized requests, an attacker can exec into any Pod on that node and read its logs. |
| Container runtime | local socket | Access to the runtime socket (or a privileged Pod) is effectively root on the node. |
kubectl applyEvery change goes through the same steps. Knowing them shows where you can add security controls.
create, get, delete) on this resource in this namespace.RBAC controls who can create objects. Admission controls what those objects can contain. Someone allowed to create Pods can still be blocked from creating a privileged Pod, but only if an admission policy is in place.
| Object | What it is | Security angle |
|---|---|---|
| Pod | Smallest deployable unit. One or more containers sharing network and storage. | Where code runs. Its securityContext decides privileges. |
| Deployment | Declares how many Pods and which image. Handles rollouts and rollbacks. | The image reference here is the start of the supply chain (Part 2). |
| Service | Stable virtual IP and DNS name in front of changing Pods. | Type LoadBalancer or NodePort exposes it outside the cluster. |
| Ingress | HTTP routing rules from outside to Services. | Public entry point. TLS and WAF decisions live here. |
| Namespace | A logical partition of the cluster. | Scope for RBAC and policies. It is not a security boundary by itself. |
| ConfigMap / Secret | Configuration data / sensitive data. | Secrets are only base64-encoded in etcd unless encryption at rest is enabled. |
| ServiceAccount | Identity a Pod uses to talk to the API server. | A token is mounted into Pods by default. A compromised Pod gets its permissions. |
| Role / RoleBinding | RBAC permissions, and who they are granted to. | Wildcards and cluster-admin bindings are common findings. |
| NetworkPolicy | Allowed traffic between Pods. | Without one, all Pods can reach all other Pods. |
Two objects: a Deployment that runs three copies of an app, and a Service that exposes them inside the cluster.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels: { app: web }
template:
metadata:
labels: { app: web }
spec:
containers:
- name: web
image: registry.example.com/web:1.4.2
ports: [{ containerPort: 8080 }]
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector: { app: web }
ports: [{ port: 80, targetPort: 8080 }]
Delete one of the three Pods and the ReplicaSet creates a replacement within seconds. That self-healing is the control loop from section 1 at work. This manifest also has security gaps: no securityContext, no resource limits, and an image tag instead of a digest. The next parts cover how to fix them.
A few defaults explain many real cluster compromises:
These often combine into one attack. The attacker exploits a vulnerable app in a Pod, reads the mounted ServiceAccount token, uses an over-privileged role to create a privileged Pod, escapes to the node, and then reaches other workloads and Secrets. A control at any of these steps can stop it.
The image in that Deployment is code that came from somewhere. Part 2 covers how to build, sign, scan and verify images, and how to enforce those checks in the cluster.
Part 2: Supply chain security →