Followed a layered approach that is based on defense in depth approach.
The 4C layers of Cloud Native Security
Cloud Datacenter
Cluster (Kubernetes)
Container
Code
The 4C model describes where a control lives. The current Kubernetes documentation and the CNCF Cloud Native Security Whitepaper also describe when a control applies across the workload lifecycle:
Develop: code review, dependency and secret scanning
Cloud incidents rarely fit into only one category. A vulnerable application, network exposure, workload identity, and excessive storage permissions can combine into one attack path.
The U.S. Department of Justice’s Capital One case summary describes an intrusion through a misconfigured web application firewall that enabled unauthorized access to cloud-hosted data. Public analyses of the incident describe a server-side request forgery (SSRF) that reached the cloud instance metadata service at 169.254.169.254 and obtained temporary credentials for an over-privileged role. The case is a useful reminder to evaluate the complete path from an externally reachable workload to its identity and permitted resources.
In a Kubernetes security review, ask:
What can an attacker reach after compromising this container?
Can the Pod reach the node’s cloud metadata endpoint?
Does the Pod receive a service-account token it does not need?
Which API objects and external cloud resources can that identity access?
Do network and admission policies limit lateral movement?
Would audit logs reveal the access quickly enough to respond?
Security engineers are expected to connect preventive controls with detection, incident response, and evidence.
Cloud Data Center
Cloud Provider: Their hardware their policy
Shared responsibility: the provider secures the physical facility and hypervisor; the customer secures identities, network rules, data, and workloads.
In-house infrastructures
Physical security
Network access
Database access (etcd for Kubernetes)
Instance metadata services (169.254.169.254) hand out credentials to anything running on the machine, including containers. Modern clouds offer session-oriented metadata access (for example, AWS IMDSv2), and clusters should block Pod egress to the metadata address unless a workload needs it.
Cluster (Kubernetes)
Authentication
RBAC Authorization
Admission control (Pod Security Admission, policy engines)
Kubernetes has no User object. Identities come from the authenticator:
Normal users: client certificates, OIDC tokens from an identity provider, or an authenticating proxy (Rancher, for example).
Service accounts: the only identity stored inside Kubernetes. Pods receive short-lived, audience-bound ServiceAccount tokens.
A client certificate signed by the cluster’s client CA (Certificate Authority) is considered authenticated:
the certificate Common Name (CN=) becomes the username;
each Organization (O=) becomes a group.
Authentication only answers who the caller is. A newly authenticated user is allowed to do almost nothing until RBAC grants permissions.
Authentication hands-on
All commands run on node1 of your FABRIC RKE2 slice. The setup playbook copied /etc/rancher/rke2/rke2.yaml to /home/ubuntu/.kube/config and linked RKE2’s kubectl into /usr/local/bin.
INFOConfirm that the RKE2 cluster is up and ready
1
kubectl get nodes
INFOWho is the ubuntu user, according to Kubernetes?
1
2
kubectl auth whoami
kubectl config view --minify
The username is system:admin and the groups include system:masters.
system:masters is bound to cluster-admin and bypasses RBAC entirely. This kubeconfig is the cluster’s break-glass credential.
Notice that client-certificate-data and client-key-data show as DATA+OMITTED. Anyone who copies the raw file becomes system:admin. We will not hand this file to other users.
INFOCreate a new Linux user account
New user account is called student:
1
2
sudo useradd -s /bin/bash -m student
sudo su - student
Try running kubectl commands now:
1
2
kubectl get nodes
kubectl get svc
With no kubeconfig, kubectl falls back to localhost:8080 and fails. A Linux account means nothing to the Kubernetes API server.
If you instead see permission denied when running kubectl itself, replace the symlink with a copy of the binary (as ubuntu): sudo cp --remove-destination "$(readlink -f /usr/local/bin/kubectl)" /usr/local/bin/kubectl
Type exit to return to the ubuntu account.
INFOIssue a client certificate for student
As ubuntu, generate a private key and a certificate signing request. The subject sets the username (CN=student) and a group (O=csc478-students):
kubectl auth whoami
kubectl get nodes
kubectl get pods
kubectl auth whoami succeeds: the username is student and the groups are csc478-students and system:authenticated.
kubectl get nodes and kubectl get pods fail with Forbidden. The API server knows whostudent is (authenticated) but no binding says what student may do (not authorized). Compare this to the earlier connection refused error.
INFOAuthorize student in one namespace
Exit back to ubuntu, create the lab namespace, and bind the built-in edit ClusterRole to the group, limited to that namespace:
sudo su - student
kubectl get pods
kubectl create deployment web --image=nginx
kubectl get deployments,pods
kubectl get pods -n kube-system
kubectl get nodes
kubectl auth can-i --list
Work inside csc478-lab succeeds.
kube-system and nodes remain Forbidden.
Binding a group rather than a user means future certificates with O=csc478-students receive the same access without new bindings.
Deleting the CSR does not revoke the certificate. Kubernetes has no client-certificate revocation list; a leaked certificate stays valid until it expires. That is why expirationSeconds matters, and why production clusters prefer OIDC tokens for people.
CHALLENGE
Create a second identity, auditor, in the group csc478-auditors, bound to the built-in view ClusterRole in csc478-lab. Put both identities in the student account’s kubeconfig as two contexts, and switch between them with kubectl config use-context.
Use kubectl auth can-i to show evidence that:
auditor can list Pods but cannot read Secrets or create Deployments;
student can do all three;
neither identity can list Nodes.
A kubeconfig can also hold several clusters. On FABRIC this is not practical across slices: every slice uses 192.168.1.0/24, and each API server certificate only lists its own addresses in tls-san.
RBAC Authorization
Kubernetes uses the rbac.authorization.k8s.io API group to drive RBAC-based authorization decisions,
RKE2 starts the API server with the Node and RBAC authorizers:
A stricter baseline starts from default-deny and explicitly allows DNS and required services.
Kubernetes Ingress
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
Traffic routing is controlled by rules defined on the Ingress resource.
Ingress is managed by Ingress Controllers.
There are many different Ingress Controllers
RKE2 packages its own controller. Releases have shipped rke2-ingress-nginx by default, and RKE2 also supports Traefik (ingress-controller: traefik in /etc/rancher/rke2/config.yaml).
The upstream community ingress-nginx project was retired in March 2026. Treat the controller as a component with its own CVEs and support lifecycle.
Check which controller your cluster runs:
1
2
kubectl get pods -n kube-system | grep-i-E'ingress|traefik'
kubectl get ingressclass
The Gateway API is the successor to Ingress. It separates infrastructure ownership (Gateway) from application routing (HTTPRoute), which maps well onto RBAC roles.
TLS for Kubernetes Ingress
TLS terminates at the Ingress controller. The certificate and key live in a kubernetes.io/tls Secret in the same namespace as the Ingress:
In production, cert-manager requests and renews certificates automatically (for example, from Let’s Encrypt).
Traffic from the controller to the backend Pod is plain HTTP unless the backend or a service mesh (mutual TLS) encrypts it.
Container Security
Pod Security Standards
Pod security will influence container security.
Three policies:
Privileged
Baseline
Restricted
Cumulative and range from highly permissive to highly restrictive
Enforced by the built-in Pod Security Admission controller through namespace labels (enforce, audit, warn).
RKE2 applies privileged cluster-wide by default. With profile: cis in the RKE2 config, the default becomes restricted with exemptions for system namespaces.
Privileged
Purposely open, entirely unrestricted
Enable system- and infrastructure-level workloads
Implied understanding that these workloads are run as privileged/trusted users.
Absence of restrictions and allow-by-default mechanism
Baseline
Streamline adoption for common containerized workloads
Prevent known privilege escalations
No privileged containers, host namespaces, or hostPath volumes
Linux capabilities a container may add under baseline (anything else is rejected):
The request is rejected with violates PodSecurity "restricted:latest", followed by every missing setting: allowPrivilegeEscalation, capabilities, runAsNonRoot, and seccompProfile.
The Pod was authenticated and authorized. Admission stopped it.
The unprivileged nginx image listens on port 8080, so it does not need NET_BIND_SERVICE.
automountServiceAccountToken: false removes the API token from a workload that never talks to the Kubernetes API.
INFOClean up
1
kubectl delete namespace psa-demo
Supply chain security
Most container risk arrives through the image: base OS packages, language dependencies, and whoever built and pushed it.
Common controls:
Scanning: tools such as Trivy or Grype report known CVEs in images.
SBOM: a software bill of materials lists what is inside an image, so you can answer “are we affected?” when the next CVE lands.
Signing and provenance:Sigstore cosign signs images; SLSA describes how trustworthy the build process is.
Admission policy: Kyverno, OPA Gatekeeper, or the built-in ValidatingAdmissionPolicy can reject unsigned images, latest tags, or images from unapproved registries.
Pin images by digest (image: nginx@sha256:...) so the image you scanned is the image you run.
Runtime security
Prevention eventually fails, so clusters also need detection:
Kubernetes audit logs record who called which API, and when.
Runtime detectors such as Falco watch system calls for suspicious behavior: a shell spawned in a container, a read of /etc/shadow, an unexpected outbound connection.
Cloud-native application protection platforms (CNAPP) combine posture checks, image scanning, identity analysis, and runtime detection into one product.