AWS, EKS, DevSecOps, Terraform, Kubernetes, Cilium, Trivy, Docker, FastAPI, Security

2026-10-18

Secure EKS Delivery Lab — Update #2: From AWS Design to a Secured Local Cluster

EKS is mostly a costly service, considering that you may need additional services like endpoints/Nat Gateway, on top of the hourly EKS costs, so for local testing I moved to kubernetes using Kind (K8s in Docker) to test the security hardening and networking policies, and well, just general testing and configurations.

This update covers mostly the point where the project advances from provisiong infra (shown in the AWS diagram below) to "on-premise" K8s.

architecture-recreated.png

Caption: Architecture diagram.

The scope and goal remains the same: build a small service, deliver it securely to Amazon EKS, use the project to use technolpgies and DevSecOps principles, through Terraform, container security, Kubernetes security, vulnerability management, and runtime detection.

AWS infrastructure: designed in layers, intentionally not running as of now

So far the layers were built following this structure:

The private-node egress design is based on VPC endpoints rather than a NAT Gateway for additional security. The intended endpoints are S3, ECR API, ECR Docker, STS, and EC2, this minimizes unnecessary internet paths and keeps all the network full private.

A local Kubernetes security baseline

The cluster is running with one control-plane node and two workers, Cilium provides the CNI and enforces the NetworkPolicies used in local testing.

The web server app is deployed into a dedicated secure-eks-delivery namespace with the Kubernetes Restricted Pod Security Admission profile enabled and proper labeling.

exec-d641161b-2b51-4f3c-9303-dfe67873ecd5.png

Caption: Kubernetes diagram used for local testing.

The deployment configuration was defined as following:

That configuration showed expected results. A test pod was rejected because it did not meet the Restricted Pod Security requirements, meanwhile the the corrected test manifest had to explicitly run as a known non-root UID, drop capabilities, disable privilege escalation, and select a seccomp profile, passing the first tests.

NetworkPolicies: proving both deny and allow paths

The namespace starts with default-deny ingress and egress policies. I then added narrowly scoped exceptions for:

The useful part was testing the policy, not just applying YAML:


Unlabelled test pod -> FastAPI service:8080 = denied (connection timeout)

Labelled test pod   -> FastAPI service:8080 = allowed (200 /health/ready)

A future RBAC and admission-policy exercise will prevent arbitrary workloads from assigning themselves the access=api-client label.

Container and dependency hardening

The Dockerfile now has separate builder and runtime stages. The runtime container uses the same non-root UID as the Kubernetes manifest and carries the application source plus the virtual environment used to run Uvicorn. Removing unnecessary package-management tooling from the final image is a documented follow-up.

I also started working on a reproducible dependency workflow:

Trivy is now installed locally and the first scan of the selected Python base image found six pip findings: five CVEs Medium and one Low, with no High or Critical findings. This is being recorded as a baseline rather than ignored. Five findings have an available fixed version; one currently has no reported fix. Before changing the pinned base image, will finish the reproducible Docker build, scan the complete application image, then test a newer candidate base-image digest and compare the reports later on.

What is next

There is still quite a lot of work to do!! So far I have come up with this checklist:


Verify the locked Docker build and application health

  -> scan the completed application image with Trivy

  -> investigate and remediate a finding

  -> add CI checks: Gitleaks, Checkov, and Trivy

  -> configure GitHub Actions OIDC with least-privilege AWS access

  -> create the EKS image overlay using an ECR digest

  -> package the workload with Helm

  -> add Falco and run controlled runtime-detection exercises

  -> introduce Argo CD and look for GitOps improvements

Signing off for now, -Ale

References