<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MysticMc</title>
    <description>The latest articles on DEV Community by MysticMc (@nazmur96).</description>
    <link>https://dev.to/nazmur96</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3770268%2F4a286af1-ae62-4533-9578-04a4bc8fb006.png</url>
      <title>DEV Community: MysticMc</title>
      <link>https://dev.to/nazmur96</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nazmur96"/>
    <language>en</language>
    <item>
      <title>AWS API Gateway vs Kubernetes Gateway API: Learn the Difference by Building Both</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Sat, 28 Nov 2026 16:07:42 +0000</pubDate>
      <link>https://dev.to/nazmur96/aws-api-gateway-vs-kubernetes-gateway-api-learn-the-difference-by-building-both-35pi</link>
      <guid>https://dev.to/nazmur96/aws-api-gateway-vs-kubernetes-gateway-api-learn-the-difference-by-building-both-35pi</guid>
      <description>&lt;h1&gt;
  
  
  AWS API Gateway vs Kubernetes Gateway API: learn the difference by building both
&lt;/h1&gt;

&lt;p&gt;Two names, one easy misunderstanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS API Gateway&lt;/strong&gt; is an AWS-managed service for publishing APIs and controlling consumer access. &lt;strong&gt;Kubernetes Gateway API&lt;/strong&gt; is a set of Kubernetes networking APIs that a controller implements using a traffic proxy or cloud load balancer.&lt;/p&gt;

&lt;p&gt;They overlap in HTTP routing. Either can be sufficient for some applications. They can also work together when consumer-facing API management and application traffic management need separate controls.&lt;/p&gt;

&lt;p&gt;The clearest way to learn the difference is to keep one application and change how traffic reaches it.&lt;/p&gt;

&lt;p&gt;This article proposes that project. The manifests illustrate the design; they are not a complete deployment bundle or evidence of a completed lab. Verify controller, CRD, Helm chart, and Terraform provider compatibility before implementation. Product capabilities below were checked against official documentation on November 28, 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  One application, three architectures
&lt;/h2&gt;

&lt;p&gt;Imagine an e-commerce platform with three microservices on EKS:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Access requirement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Products&lt;/td&gt;
&lt;td&gt;&lt;code&gt;GET /products&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Public&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Orders&lt;/td&gt;
&lt;td&gt;&lt;code&gt;GET /orders&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid access token with order-read permission&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Payments&lt;/td&gt;
&lt;td&gt;&lt;code&gt;POST /payments&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Valid access token with payment-write permission&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use mock payments throughout. Return a service name and application version in every response so routing decisions are observable. Give each workload a separate readiness endpoint.&lt;/p&gt;

&lt;p&gt;Build these architectures sequentially:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Consumer-facing entry&lt;/th&gt;
&lt;th&gt;Application routing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;AWS API Gateway HTTP API&lt;/td&gt;
&lt;td&gt;Internal ALB configured through Ingress&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;Public NLB forwarding to Envoy&lt;/td&gt;
&lt;td&gt;Envoy configured through Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;AWS API Gateway HTTP API&lt;/td&gt;
&lt;td&gt;Private NLB forwarding to Envoy, configured through Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use one cluster within a working session. Keep the three services stable while replacing the exposure layer, and remove unused load balancers as you move between designs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture A: AWS API Gateway with an internal ALB
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer
   | HTTPS
   v
AWS API Gateway HTTP API
   | JWT authorization and API throttling
   v
VPC Link
   v
Internal ALB
   | path-based rules
   +--&amp;gt; product pods
   +--&amp;gt; order pods
   +--&amp;gt; payment pods

Configuration: Ingress --&amp;gt; AWS Load Balancer Controller --&amp;gt; ALB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An Ingress resource describes the ALB routing rules. It is configuration, not a process handling requests. With IP targets, the ALB sends requests to pod IPs; the Kubernetes Services provide backend discovery rather than an additional proxy hop in this diagram.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build
&lt;/h3&gt;

&lt;p&gt;Use Terraform for the VPC, private and public subnets as needed, EKS managed node groups, IAM, HTTP API, VPC Link, Cognito, and CloudWatch log configuration. Use Argo CD and Helm for the AWS Load Balancer Controller and Kubernetes workloads, including three Deployments, three ClusterIP Services, and an Ingress.&lt;/p&gt;

&lt;p&gt;Configure the Ingress for an &lt;strong&gt;internal ALB with IP targets&lt;/strong&gt; and rules for &lt;code&gt;/products&lt;/code&gt;, &lt;code&gt;/orders&lt;/code&gt;, and &lt;code&gt;/payments&lt;/code&gt;. Its health-check path must reach a healthy endpoint on each backend.&lt;/p&gt;

&lt;p&gt;Define these API Gateway routes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Route&lt;/th&gt;
&lt;th&gt;Authorization&lt;/th&gt;
&lt;th&gt;Integration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /products&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Internal ALB listener&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /orders&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;JWT, required order-read scope&lt;/td&gt;
&lt;td&gt;Same listener&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /payments&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;JWT, required payment-write scope&lt;/td&gt;
&lt;td&gt;Same listener&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;All three can share one HTTP proxy integration. Configure its integration method as &lt;code&gt;ANY&lt;/code&gt; so it forwards both GET and POST requests. The API routes still restrict the externally accepted methods.&lt;/p&gt;

&lt;p&gt;For an HTTP API private integration, supply the &lt;strong&gt;load balancer listener ARN&lt;/strong&gt;, with the VPC Link as the connection. The API, link, and load balancer must belong to the same AWS account. If a named stage reaches your backend as &lt;code&gt;/lab/products&lt;/code&gt;, map the integration request path to &lt;code&gt;$request.path&lt;/code&gt; so the backend receives &lt;code&gt;/products&lt;/code&gt;. Backend HTTPS requires explicit TLS configuration; a private connection does not automatically encrypt that hop. See &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-private.html" rel="noopener noreferrer"&gt;AWS private integration guidance&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prove
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Call products without a token and expect success.&lt;/li&gt;
&lt;li&gt;Call orders without a token and expect rejection.&lt;/li&gt;
&lt;li&gt;Sign in through Cognito using an appropriate OAuth flow, obtain an access token, and call orders successfully.&lt;/li&gt;
&lt;li&gt;Send an expired token or a token from an untrusted issuer and confirm rejection.&lt;/li&gt;
&lt;li&gt;Send a valid token without the required scope and confirm access is denied.&lt;/li&gt;
&lt;li&gt;Configure low rate and burst targets, generate controlled load, and capture &lt;code&gt;429&lt;/code&gt; responses.&lt;/li&gt;
&lt;li&gt;Compare access logs and latency metrics with a deliberately slow mock backend.&lt;/li&gt;
&lt;li&gt;Verify the ALB scheme, subnet placement, security-group rules, and failure of direct access from outside the VPC.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;JWT validation checks the token's signature, issuer, audience/client identifier, lifetime, and configured scopes. Application authorization still matters: an authenticated customer must not be able to read another customer's orders. See &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html" rel="noopener noreferrer"&gt;HTTP API JWT authorization&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this teaches:&lt;/strong&gt; API Gateway owns the public API contract and initial access checks. The ALB selects an application backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture B: Kubernetes Gateway API with Envoy
&lt;/h2&gt;

&lt;p&gt;Remove Architecture A's Ingress and unused API management resources, then expose the same services through Envoy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer --HTTPS--&amp;gt; Public NLB --TCP--&amp;gt; Envoy proxy --&amp;gt; application pods
                                         ^
                                         | configured by
                                  Envoy Gateway controller
                                         ^
                                         | watches
                          GatewayClass + Gateway + HTTPRoutes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The NLB forwards connections. In this design, Envoy terminates TLS and routes HTTP requests. An NLB can terminate TLS in other designs; here it uses a TCP listener to preserve the encrypted connection to Envoy.&lt;/p&gt;

&lt;p&gt;Gateway API resources describe desired behavior. &lt;strong&gt;Requests do not travel through an HTTPRoute object.&lt;/strong&gt; Envoy Gateway watches those objects and configures Envoy, which handles the requests. The &lt;a href="https://gateway-api.sigs.k8s.io/reference/api-types/httproute/" rel="noopener noreferrer"&gt;HTTPRoute reference&lt;/a&gt; describes its matching, filtering, and backend model.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build
&lt;/h3&gt;

&lt;p&gt;Install compatible Gateway API CRDs and Envoy Gateway through Helm. Configure the Envoy data-plane LoadBalancer Service for an internet-facing NLB using the selected AWS load-balancer implementation. Keep the controller and the data-plane proxy distinct: customers connect to the proxy.&lt;/p&gt;

&lt;p&gt;The following examples use the &lt;code&gt;ecommerce&lt;/code&gt; namespace for the Gateway, routes, and backend Services. Create it first. &lt;code&gt;GatewayClass&lt;/code&gt; is cluster-scoped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GatewayClass&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;envoy&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;controllerName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.envoyproxy.io/gatewayclass-controller&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Gateway&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ecommerce-gateway&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ecommerce&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;gatewayClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;envoy&lt;/span&gt;
  &lt;span class="na"&gt;listeners&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
      &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTP&lt;/span&gt;
      &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
      &lt;span class="na"&gt;allowedRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;namespaces&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Same&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPRoute&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;products-route&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ecommerce&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ecommerce-gateway&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PathPrefix&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/products&lt;/span&gt;
      &lt;span class="na"&gt;backendRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;product-service&lt;/span&gt;
          &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Service must expose &lt;strong&gt;Service port&lt;/strong&gt; &lt;code&gt;8080&lt;/code&gt;; &lt;code&gt;backendRefs.port&lt;/code&gt; is not the container's &lt;code&gt;targetPort&lt;/code&gt;. These rules preserve &lt;code&gt;/products&lt;/code&gt;, so the application must serve that path or you must configure a rewrite.&lt;/p&gt;

&lt;p&gt;The HTTP listener is an initial routing exercise. Before exposing credentials or protected traffic, add an HTTPS listener with a valid certificate referenced from a Kubernetes TLS Secret, then redirect or remove HTTP. Manage certificate provisioning declaratively and keep private keys out of Git.&lt;/p&gt;

&lt;p&gt;Create equivalent routes for orders and payments. To preserve Architecture A's method restrictions, match &lt;code&gt;GET&lt;/code&gt; for products and orders and &lt;code&gt;POST&lt;/code&gt; for payments. A path-only route accepts other methods too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extend and prove
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Exercise&lt;/th&gt;
&lt;th&gt;Evidence to capture&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Path routing&lt;/td&gt;
&lt;td&gt;Each path returns the expected service identifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host routing for &lt;code&gt;orders.example.com&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Matching host succeeds; another host does not match that route&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTPS listener&lt;/td&gt;
&lt;td&gt;Trusted certificate, correct hostname, and protected traffic over HTTPS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JWT authorization&lt;/td&gt;
&lt;td&gt;Missing/invalid token rejected; valid authorized request succeeds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rate limiting&lt;/td&gt;
&lt;td&gt;Controlled load produces gateway &lt;code&gt;429&lt;/code&gt; responses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-namespace backend&lt;/td&gt;
&lt;td&gt;Backend reference fails without permission and succeeds with a correctly scoped ReferenceGrant&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Broken backend&lt;/td&gt;
&lt;td&gt;Route status explains the unresolved reference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Request mirroring&lt;/td&gt;
&lt;td&gt;Test backend receives the copy; client receives the primary response&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use Envoy's &lt;a href="https://gateway.envoyproxy.io/docs/concepts/gateway_api_extensions/security-policy/" rel="noopener noreferrer"&gt;SecurityPolicy&lt;/a&gt; for JWT authentication. Use &lt;a href="https://gateway.envoyproxy.io/docs/concepts/rate-limiting/" rel="noopener noreferrer"&gt;BackendTrafficPolicy rate limiting&lt;/a&gt; for the rate-limit exercise. These are Envoy extensions, so their YAML is implementation-specific.&lt;/p&gt;

&lt;p&gt;Cross-namespace route attachment and cross-namespace backend references have separate permission mechanisms: the Gateway's &lt;code&gt;allowedRoutes&lt;/code&gt; controls attachment; a ReferenceGrant in the backend namespace authorizes the relevant backend reference. Check the installed CRD version before writing that grant.&lt;/p&gt;

&lt;p&gt;Mirroring is an extended Gateway API feature: verify controller support. Use a read-only mock endpoint so a copied request cannot trigger a second payment or mutate real data. See &lt;a href="https://gateway-api.sigs.k8s.io/guides/user-guides/http-request-mirroring/" rel="noopener noreferrer"&gt;the request-mirroring guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this teaches:&lt;/strong&gt; Gateway API defines routing intent; the implementation supplies the proxy and policies. Standard routes improve portability, while extensions need separate review when switching implementations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture C: put both together
&lt;/h2&gt;

&lt;p&gt;Now keep external API management in AWS while retaining Kubernetes control over backend traffic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer --HTTPS--&amp;gt; AWS API Gateway HTTP API
                              |
                    JWT checks + throttling
                              |
                           VPC Link
                              |
                         Internal NLB
                              |
                          Envoy proxy
                              |
                    HTTPRoute backend selection
                       /              \
                product-v1         product-v2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Build
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Change the declarative Envoy data-plane configuration to provision an &lt;strong&gt;internal&lt;/strong&gt; NLB. A scheme change can replace the load balancer; treat it as a migration and verify the public NLB is removed.&lt;/li&gt;
&lt;li&gt;Wait for the NLB listener and healthy Envoy targets.&lt;/li&gt;
&lt;li&gt;Create the HTTP API private integration using that listener ARN and a VPC Link in appropriate private subnets.&lt;/li&gt;
&lt;li&gt;Restore the public route definitions, JWT authorizer, throttling, and CloudWatch access logs.&lt;/li&gt;
&lt;li&gt;Keep backend selection and rollout weights in Kubernetes HTTPRoutes.&lt;/li&gt;
&lt;li&gt;Restrict backend reachability through security groups and network policy where applicable. Verify the effective source and target behavior for the chosen NLB configuration.&lt;/li&gt;
&lt;li&gt;Collect Envoy metrics with Prometheus/Grafana and correlate them with API Gateway logs using a request identifier.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the internal Envoy listener uses HTTPS, configure API Gateway's backend TLS settings and a certificate hostname that it can validate. Plan frontend and backend TLS separately.&lt;/p&gt;

&lt;p&gt;Start with path-only backend routes. When adding host matching, verify which Host header Envoy actually receives through the integration. The customer's public API hostname and the backend integration hostname may differ.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Decision&lt;/th&gt;
&lt;th&gt;Owner in this design&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Which public method/path is available?&lt;/td&gt;
&lt;td&gt;AWS API Gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is the caller's access token acceptable?&lt;/td&gt;
&lt;td&gt;AWS API Gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Is a particular customer allowed to access this order?&lt;/td&gt;
&lt;td&gt;Application authorization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Should products use v1 or v2?&lt;/td&gt;
&lt;td&gt;HTTPRoute, implemented by Envoy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which layer rejected a request?&lt;/td&gt;
&lt;td&gt;Correlated API Gateway, Envoy, and application telemetry&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These are design choices. Envoy can also enforce authentication; keeping it there provides an additional control if internal callers can reach it. If authorization is delegated to the edge, prevent bypass and never trust arbitrary client-supplied identity headers.&lt;/p&gt;

&lt;h3&gt;
  
  
  The experiment that makes the distinction clear
&lt;/h3&gt;

&lt;p&gt;Deploy product v1 and v2 behind separate Services and replace the products route with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gateway.networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HTTPRoute&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;products-route&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ecommerce&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;parentRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ecommerce-gateway&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PathPrefix&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/products&lt;/span&gt;
      &lt;span class="na"&gt;backendRefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;product-v1&lt;/span&gt;
          &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;
          &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;product-v2&lt;/span&gt;
          &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;
          &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Collect version counts over a sufficiently large sample at a rate below your throttling target. Expect an approximate distribution, not exactly nine v1 responses followed by one v2 response. Weights are proportional: &lt;code&gt;9/1&lt;/code&gt; and &lt;code&gt;90/10&lt;/code&gt; express the same split. See &lt;a href="https://gateway-api.sigs.k8s.io/guides/user-guides/traffic-splitting/" rel="noopener noreferrer"&gt;Gateway API traffic splitting&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Change the split through Git to &lt;code&gt;50/50&lt;/code&gt;, then roll back to &lt;code&gt;100/0&lt;/code&gt;. Verify that the public endpoint, API routes, and authorizer configuration remain unchanged.&lt;/p&gt;

&lt;p&gt;Record both the observed version distribution and the error/latency metrics. Weighted routing alone does not provide health-based rollout promotion or automatic rollback; those need additional automation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this teaches:&lt;/strong&gt; consumers keep the same API while the platform changes how requests reach application versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTTP API vs REST API: add an API management experiment
&lt;/h2&gt;

&lt;p&gt;AWS API Gateway offers multiple API types. HTTP API is the simpler choice for this project's main path; REST API adds management features worth testing separately.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Capability&lt;/th&gt;
&lt;th&gt;HTTP API&lt;/th&gt;
&lt;th&gt;REST API&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HTTP endpoints and private integrations&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Native JWT authorizer&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes, in current AWS documentation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cognito-backed authorization&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API keys and per-client usage plans&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Throttling&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Built-in request validation&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Response caching&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Direct AWS WAF integration&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API Gateway canary release deployments&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical API Gateway request pricing&lt;/td&gt;
&lt;td&gt;Lower&lt;/td&gt;
&lt;td&gt;Higher&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Check &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html" rel="noopener noreferrer"&gt;AWS's feature comparison&lt;/a&gt; for your requirements. Older tables that say REST APIs cannot use native JWT authorizers are outdated; AWS now documents &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-jwt-authorizer.html" rel="noopener noreferrer"&gt;REST API JWT authorizers&lt;/a&gt;. Check Terraform provider support before assuming a newly documented feature is available in your pinned provider.&lt;/p&gt;

&lt;p&gt;A private &lt;strong&gt;integration&lt;/strong&gt; describes connectivity to the backend. It does not make the consumer-facing API endpoint private.&lt;/p&gt;

&lt;p&gt;For the extra exercise, create two mock API customers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Customer&lt;/th&gt;
&lt;th&gt;Rate target&lt;/th&gt;
&lt;th&gt;Monthly quota target&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;5 requests/second&lt;/td&gt;
&lt;td&gt;1,000 requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Premium&lt;/td&gt;
&lt;td&gt;50 requests/second&lt;/td&gt;
&lt;td&gt;100,000 requests&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Give each an API key, associate the keys with the correct usage plans and deployed stage, and mark the relevant methods as requiring an API key. Configure burst targets explicitly too.&lt;/p&gt;

&lt;p&gt;Prove that a key identifies a usage-plan client while separate authorization still controls access. Usage plans are best-effort targets, not hard spending caps or exact entitlements; customers can exceed their configured quotas. See &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html" rel="noopener noreferrer"&gt;AWS usage-plan guidance&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Organize the implementation by ownership
&lt;/h2&gt;

&lt;p&gt;For a standalone comparison lab, this is a useful logical layout. In a larger project, keep the same boundaries across separate app, platform, and GitOps repositories.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws-vs-k8s-gateway/
├── applications/
│   ├── product/                 # build v1 and v2 images
│   ├── orders/
│   └── payments/                # mock only
├── terraform/
│   ├── modules/
│   │   ├── network/
│   │   ├── eks/
│   │   └── api-management/
│   └── environments/lab/
│       ├── foundation/          # VPC, EKS, IAM
│       └── api-edge/            # APIs, VPC Link, Cognito, logs
├── kubernetes/
│   ├── base/                   # workloads and ClusterIP Services
│   ├── architecture-a/         # internal ALB Ingress
│   ├── architecture-b/         # public Envoy Gateway and routes
│   └── architecture-c/         # private Envoy Gateway and routes
├── helm/
│   ├── envoy-gateway-values.yaml
│   └── aws-load-balancer-controller-values.yaml
├── argocd/
│   └── applications.yaml
├── tests/
│   ├── authentication.sh
│   ├── routing.sh
│   ├── canary.sh
│   └── rate-limit.sh
├── docs/
│   ├── decisions/
│   ├── evidence/
│   └── rca/
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Terraform owns AWS resources explicitly declared in Terraform. Argo CD owns Kubernetes resources and Helm releases; the load-balancer controller owns the AWS load balancers created from them. Do not also declare those same load balancers in Terraform.&lt;/p&gt;

&lt;p&gt;The deployment dependency is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Terraform foundation
  --&amp;gt; Argo CD controllers and workloads
  --&amp;gt; Kubernetes-managed load balancer and healthy targets
  --&amp;gt; listener ARN passed to Terraform api-edge
  --&amp;gt; API Gateway integration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Separate foundation and API-edge roots make that boundary explicit and avoid requiring a listener ARN before the controller has created it. Commit the wiring and discovery procedure; do not rely on an undocumented console copy-and-paste.&lt;/p&gt;

&lt;p&gt;Keep one active architecture overlay at a time. Record commands, versions, sanitized outputs, expected behavior, and actual outcomes. A planned proof remains pending until you run it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshoot the layer that owns the failure
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Start investigating&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;API Gateway &lt;code&gt;401&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Missing/invalid token, issuer, audience, expiration, signing keys&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Valid token receives &lt;code&gt;403&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Required scopes and authorization rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;429&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Determine whether API Gateway, Envoy, or the application emitted it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API Gateway &lt;code&gt;504&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Integration timeout, backend latency, network path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VPC Link unavailable&lt;/td&gt;
&lt;td&gt;Link state, subnet/IP availability, security groups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NLB targets unhealthy&lt;/td&gt;
&lt;td&gt;Target port, health-check protocol/path, Envoy readiness, security groups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTPRoute not attached&lt;/td&gt;
&lt;td&gt;Parent reference, listener, namespace permissions, &lt;code&gt;Accepted&lt;/code&gt; condition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend reference broken&lt;/td&gt;
&lt;td&gt;Service name/port, ReferenceGrant, &lt;code&gt;ResolvedRefs&lt;/code&gt; condition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gateway has no address&lt;/td&gt;
&lt;td&gt;Controller reconciliation, IAM, subnets, load-balancer events&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend &lt;code&gt;404&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Forwarded path, named-stage prefix, hostname, listener/route match&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Canary distribution wrong&lt;/td&gt;
&lt;td&gt;Observed generation, route weights, backend identity, sample size, caching&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authentication can be bypassed&lt;/td&gt;
&lt;td&gt;Remaining public load balancers, alternate Services/listeners, internal access paths&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read status conditions and events before guessing. Distinguish a request rejected before integration from one rejected by Envoy or the application. Preserve a sanitized request identifier and response source for each deliberate failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  When would a company choose each?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Requirement&lt;/th&gt;
&lt;th&gt;Reasonable starting point&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Expose Lambda as an API&lt;/td&gt;
&lt;td&gt;AWS API Gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Route traffic to Kubernetes services&lt;/td&gt;
&lt;td&gt;Gateway API with a suitable implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Split traffic between Kubernetes application versions&lt;/td&gt;
&lt;td&gt;Gateway API weighted backends&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Offer customer-specific API usage plans&lt;/td&gt;
&lt;td&gt;API Gateway REST API plus separate authorization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keep an external API stable while Kubernetes routing evolves&lt;/td&gt;
&lt;td&gt;Both, when the operating cost is justified&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Simple Kubernetes app with no separate API management requirement&lt;/td&gt;
&lt;td&gt;Gateway API implementation alone may be sufficient&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Envoy is one implementation, not a requirement of Gateway API. EKS Auto Mode also supports Gateway API with ALBs for layer-7 routes and NLBs for supported layer-4 routes. That is a separate deployment option; it is not required for this managed-node-group Envoy lab. Review &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/auto-configure-gateway-api.html" rel="noopener noreferrer"&gt;the Auto Mode feature support&lt;/a&gt; before assuming every standard feature maps to an AWS load balancer.&lt;/p&gt;

&lt;p&gt;Envoy is useful here because it makes the controller/proxy distinction visible and lets much of the routing configuration carry across environments. Cloud-specific Service settings, certificates, identity, and controller policies still need adaptation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Budget, timing, and cleanup
&lt;/h2&gt;

&lt;p&gt;Budget 12–18 hours if you already have working EKS, GitOps, identity, and Terraform foundations. Starting those from scratch can take substantially longer.&lt;/p&gt;

&lt;p&gt;This is a billed-cloud lab: account for EKS, nodes, load balancers, NAT or other outbound connectivity, public IPv4 addresses, API requests, identity usage, and logs. Check current regional pricing and an account-wide budget alert before provisioning. A budget alert is not a spending cap.&lt;/p&gt;

&lt;p&gt;Reuse the cluster across architectures during a session, then destroy disposable infrastructure at the end of the session. Recreate from committed configuration next time.&lt;/p&gt;

&lt;p&gt;Clean up in dependency order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stop load tests and remove the API-edge integrations and related resources through their Terraform owner.&lt;/li&gt;
&lt;li&gt;Remove the active Kubernetes exposure resources through GitOps while controllers still run. With automatic self-heal, an imperative deletion can simply recreate them.&lt;/li&gt;
&lt;li&gt;Verify the controller-created ALB/NLB, target groups, and dependent networking resources are gone.&lt;/li&gt;
&lt;li&gt;Remove the remaining applications/controllers, then destroy the Terraform foundation.&lt;/li&gt;
&lt;li&gt;Check for retained logs, persistent volumes, certificates, DNS records, and other billable leftovers. Keep a shared state backend's lifecycle separate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final proof is the ability to explain one request end to end: where authentication happened, where a backend was selected, which component handled TLS, and which logs establish the result.&lt;/p&gt;

&lt;p&gt;AWS API Gateway primarily manages consumer access to an API. Kubernetes Gateway API primarily describes how traffic reaches Kubernetes applications. Build the three paths, run the failure tests, and that distinction becomes observable behavior.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-learning-journal/blob/main/networking/aws-api-gateway-vs-kubernetes-gateway-api.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-learning-journal/blob/main/networking/aws-api-gateway-vs-kubernetes-gateway-api.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>networking</category>
    </item>
    <item>
      <title>HTTPS on EKS, Explained Simply: Certificates, ALB vs NLB, TLS Termination and mTLS</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Sat, 21 Nov 2026 12:30:28 +0000</pubDate>
      <link>https://dev.to/nazmur96/https-on-eks-explained-simply-certificates-alb-vs-nlb-tls-termination-and-mtls-1212</link>
      <guid>https://dev.to/nazmur96/https-on-eks-explained-simply-certificates-alb-vs-nlb-tls-termination-and-mtls-1212</guid>
      <description>&lt;h1&gt;
  
  
  HTTPS on EKS, explained simply
&lt;/h1&gt;

&lt;p&gt;Certificates, ALB vs NLB, TLS termination and mTLS, in plain English.&lt;/p&gt;

&lt;p&gt;This is the theory half of a hands-on repo. The practice half is 10 mini projects, listed at the end, each with a scenario, the concepts, an implementation guide and a "prove it / break it" drill.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs" rel="noopener noreferrer"&gt;https://github.com/nazmur96/eks-https-tls-labs&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  0. The big picture first
&lt;/h2&gt;

&lt;p&gt;When a customer types &lt;code&gt;https://shop.example.com/checkout&lt;/code&gt;, this happens in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;DNS&lt;/strong&gt; finds out where the shop lives, like looking up an address.&lt;/li&gt;
&lt;li&gt;The browser connects to the &lt;strong&gt;load balancer (ALB)&lt;/strong&gt; at that address.&lt;/li&gt;
&lt;li&gt;The ALB shows a &lt;strong&gt;certificate&lt;/strong&gt;, an ID card proving "I really am shop.example.com."&lt;/li&gt;
&lt;li&gt;Browser and ALB do a &lt;strong&gt;TLS handshake&lt;/strong&gt; and agree on secret keys, so everything after that is encrypted.&lt;/li&gt;
&lt;li&gt;The ALB &lt;strong&gt;decrypts&lt;/strong&gt; the request, reads "they want &lt;code&gt;/checkout&lt;/code&gt;," and sends it to the checkout Pod in Kubernetes.&lt;/li&gt;
&lt;li&gt;The checkout app does its work and replies.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every tool here has one job in that chain:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Route 53&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The address book (DNS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ACM&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Gets and renews the ID card (certificate)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ALB&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The front door, plus the receptionist who reads the request and sends it to the right room&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;EKS / Kubernetes&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Where the apps actually run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AWS Load Balancer Controller&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The worker who builds the front door from your Kubernetes instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;cert-manager&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Like ACM, but for certificates inside Kubernetes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep this picture in mind. Everything below zooms in on one piece of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Why do we need HTTPS at all?
&lt;/h2&gt;

&lt;p&gt;Picture logging in and typing your password and credit card number. With plain HTTP, that data crosses the internet in readable form. Anyone in between can read it, for example someone on the same café Wi-Fi.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTTP is a postcard.&lt;/strong&gt; Every postman who handles it can read it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS is a locked box.&lt;/strong&gt; Only the right person can open it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTTPS gives you three guarantees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Encryption:&lt;/strong&gt; nobody else can read it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication:&lt;/strong&gt; you know you're talking to the real shop, not a fake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrity:&lt;/strong&gt; nobody can secretly change the message on the way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Names to untangle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS&lt;/strong&gt; = normal HTTP + TLS protection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLS&lt;/strong&gt; = the security protocol doing the actual work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSL&lt;/strong&gt; = the old, outdated version of TLS. It's dead, but people still say "SSL certificate" out of habit. They mean a TLS certificate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. What is a certificate?
&lt;/h2&gt;

&lt;p&gt;A certificate is a &lt;strong&gt;digital ID card for a website&lt;/strong&gt;. Before you trust a bank, you want proof it really is the bank. Websites have the same problem.&lt;/p&gt;

&lt;p&gt;A certificate contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the domain it belongs to (&lt;code&gt;shop.example.com&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;public key&lt;/strong&gt; (more on this in section 3)&lt;/li&gt;
&lt;li&gt;valid-from and valid-until dates&lt;/li&gt;
&lt;li&gt;who issued it&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;signature&lt;/strong&gt; from the issuer, like an official stamp&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The browser checks it. If the name matches, the dates are fine and the issuer is trusted, the browser trusts the site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who issues certificates? A Certificate Authority (CA).&lt;/strong&gt; Think of a CA as a passport office. It checks that you really own the domain, then issues the ID card. Examples are Let's Encrypt (free), DigiCert, GlobalSign, and Amazon through ACM. Your browser ships with a built-in list of CAs it trusts, which is why it believes their stamp.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Public key and private key
&lt;/h2&gt;

&lt;p&gt;Certificates use two keys that work as a pair:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Public key:&lt;/strong&gt; anyone can see it. It's printed inside the certificate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private key:&lt;/strong&gt; secret. Only the server, or whatever system handles the encryption, has it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Analogy: a special mailbox. Anyone can use the public slot, but only the owner holds the key that proves "this mailbox is mine."&lt;/p&gt;

&lt;p&gt;So having the public key doesn't let anyone pretend to be the site. That takes the private key, which means &lt;strong&gt;a leaked private key lets someone impersonate your website.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Golden rule:&lt;/strong&gt; never put a private key in GitHub, a Docker image or a config file in your repo. This matters in Kubernetes, because certificate Secrets contain the private key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  4. The TLS handshake
&lt;/h2&gt;

&lt;p&gt;Before any real data is sent, browser and server have a quick setup conversation, like two people agreeing on a secret language before talking privately.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ClientHello:&lt;/strong&gt; "Hi, I want shop.example.com. I can speak TLS 1.2 and 1.3, and here are the encryption methods I support."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ServerHello:&lt;/strong&gt; "Let's use TLS 1.3. Here's my certificate, and here's what we need to set up encryption."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The browser checks the certificate.&lt;/strong&gt; Was it issued by a trusted CA? Has it expired? Does it match &lt;code&gt;shop.example.com&lt;/code&gt;? Is the &lt;strong&gt;chain of trust&lt;/strong&gt; valid, meaning it was signed by a trusted CA, possibly through an intermediate CA? If anything fails, you get the scary &lt;em&gt;"Your connection is not private"&lt;/em&gt; warning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Both sides create shared session keys:&lt;/strong&gt; temporary secret keys for this one conversation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real traffic starts.&lt;/strong&gt; Passwords, cart and payment are all encrypted.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One subtle point: &lt;strong&gt;the private key does not encrypt all your data.&lt;/strong&gt; It's used during the handshake to prove identity and to help agree safely on session keys. The data itself is then encrypted with those fast, temporary session keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Domain registration vs DNS
&lt;/h2&gt;

&lt;p&gt;People mix these two up.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Domain registration = buying the name.&lt;/strong&gt; You buy &lt;code&gt;example.com&lt;/code&gt; from a registrar (Route 53, Cloudflare, GoDaddy...). It's like buying the right to use a shop name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS = the address book of the internet.&lt;/strong&gt; When someone asks "where is shop.example.com?", DNS answers. Route 53 can do this, and so can Cloudflare and others. You can buy the domain in one place and run DNS somewhere else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Connecting your domain to the ALB:&lt;/strong&gt; AWS gives your ALB an ugly name like &lt;code&gt;k8s-shop-123456.eu-central-1.elb.amazonaws.com&lt;/code&gt;. You create a DNS record, &lt;code&gt;shop.example.com&lt;/code&gt; → &lt;strong&gt;A record (Alias)&lt;/strong&gt; → your ALB. Customers type the nice name and land on the ALB.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Registrar&lt;/td&gt;
&lt;td&gt;Sells you the name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS&lt;/td&gt;
&lt;td&gt;Tells browsers where the name points&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ACM&lt;/td&gt;
&lt;td&gt;Gives you the certificate (ID card)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALB&lt;/td&gt;
&lt;td&gt;Receives and routes the traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;DNS says &lt;em&gt;where to go&lt;/em&gt;. The certificate proves &lt;em&gt;who you're talking to&lt;/em&gt; once you arrive. One doesn't replace the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. AWS Certificate Manager (ACM)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The problem without ACM:&lt;/strong&gt; imagine 50 websites, each needing a certificate. For every one you'd get it from a CA, store the private key safely, install it, watch the expiry date, renew it and reinstall it. Forget one and that site breaks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What ACM does for you:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;requests the certificate&lt;/li&gt;
&lt;li&gt;checks that you own the domain&lt;/li&gt;
&lt;li&gt;attaches it to AWS services such as the ALB&lt;/li&gt;
&lt;li&gt;renews it automatically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;keeps the private key hidden.&lt;/strong&gt; You never download it, so you can't leak it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Covering many names:&lt;/strong&gt; one certificate can list several names (&lt;code&gt;example.com&lt;/code&gt;, &lt;code&gt;shop.example.com&lt;/code&gt;, &lt;code&gt;api.example.com&lt;/code&gt;), or use a wildcard: &lt;code&gt;*.example.com&lt;/code&gt; covers &lt;code&gt;shop.&lt;/code&gt;, &lt;code&gt;api.&lt;/code&gt;, &lt;code&gt;admin.&lt;/code&gt; and so on.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ A wildcard does &lt;strong&gt;not&lt;/strong&gt; cover the bare &lt;code&gt;example.com&lt;/code&gt;. Add it separately if you need it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;How to request one (console):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Certificate Manager → &lt;strong&gt;Request a public certificate&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Type your domain name(s)&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;DNS validation&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;ACM gives you a special &lt;strong&gt;CNAME record&lt;/strong&gt;, a kind of secret code&lt;/li&gt;
&lt;li&gt;Add that record to your DNS&lt;/li&gt;
&lt;li&gt;ACM sees it and concludes "only the domain owner could add this." The certificate is issued.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Why DNS validation is recommended:&lt;/strong&gt; if you leave that CNAME in place, ACM can re-check ownership by itself and &lt;strong&gt;renew automatically, indefinitely.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Remember: ACM does not sell domains. It only handles certificates for domains you already control.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Layer 4 vs Layer 7, and ALB vs NLB
&lt;/h2&gt;

&lt;p&gt;This one is a classic interview topic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Layer 4 only knows the envelope:&lt;/strong&gt; IP address, port and protocol (TCP/UDP). &lt;em&gt;"Deliver this to 10.0.1.25, port 443."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 7 reads the letter inside:&lt;/strong&gt; the actual HTTP request. &lt;em&gt;"Host = shop.example.com, Path = /checkout, Method = POST."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Analogy: a delivery to an office building. Layer 4 is the security guard who only checks "right building, right floor?" Layer 7 is the receptionist who reads the letter, says "ah, this is for the checkout team," and walks it to the right desk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ALB (Application Load Balancer) = Layer 7.&lt;/strong&gt; It understands HTTP and HTTPS, routes by host and URL path, and is the best fit for web apps and microservices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NLB (Network Load Balancer) = Layer 4.&lt;/strong&gt; It handles raw connections (TCP/UDP/TLS) and is very fast and very simple. It &lt;strong&gt;cannot&lt;/strong&gt; look at URLs or host headers. Use it for non-HTTP traffic (databases, game servers, custom protocols), or in front of your own proxy.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;ALB&lt;/th&gt;
&lt;th&gt;NLB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Layer&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reads HTTP paths and hosts&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Raw TCP/UDP&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can terminate TLS&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅ (TLS listener)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can pass TLS through untouched&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅ (TCP listener)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;An important correction: an NLB does NOT give you Layer 7 protection.&lt;/strong&gt; Supporting TLS ≠ understanding HTTP ≠ blocking attacks. Those are three separate things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TLS&lt;/strong&gt; = encryption&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ALB&lt;/strong&gt; = HTTP routing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS WAF&lt;/strong&gt; = actually inspects and blocks malicious web requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. How the ALB routes traffic
&lt;/h2&gt;

&lt;p&gt;Goal: &lt;strong&gt;one ALB for many services&lt;/strong&gt;, instead of paying for a separate load balancer per service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Host-based routing&lt;/strong&gt; decides by domain name:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;shop.example.com&lt;/code&gt; → frontend&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api.example.com&lt;/code&gt; → API service&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;admin.example.com&lt;/code&gt; → admin service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three names point at the same ALB. It reads the &lt;code&gt;Host&lt;/code&gt; header and decides.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Path-based routing&lt;/strong&gt; decides by URL path:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;shop.example.com/&lt;/code&gt; → frontend&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;shop.example.com/checkout&lt;/code&gt; → checkout service&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;shop.example.com/payment&lt;/code&gt; → payment service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;You can combine both in one ALB:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"If host is shop.example.com AND path is /checkout → checkout"&lt;/li&gt;
&lt;li&gt;"If host is api.example.com AND path is /payments → payment"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ALB can only do this because it works at Layer 7 and can read the request.&lt;/p&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/01-one-alb-many-services.md" rel="noopener noreferrer"&gt;Lab 1: One ALB, many services&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Where the certificate fits on the ALB, and what "TLS termination" means
&lt;/h2&gt;

&lt;p&gt;Following the customer to &lt;code&gt;https://shop.example.com/checkout&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;DNS says "shop.example.com is that ALB."&lt;/li&gt;
&lt;li&gt;The browser connects to the ALB on port 443.&lt;/li&gt;
&lt;li&gt;In the TLS handshake, the ALB shows the ACM certificate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The ALB decrypts the request. This is TLS termination: the encryption ends here.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Now it can read &lt;code&gt;Host = shop.example.com&lt;/code&gt;, &lt;code&gt;Path = /checkout&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It matches a routing rule.&lt;/li&gt;
&lt;li&gt;It forwards the request to the checkout Pods, using their IP addresses directly.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser ──HTTPS (encrypted)──► ALB ──HTTP (plain)──► Checkout Pod
                           [decrypts here]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TLS termination = the place where the locked box gets opened.&lt;/strong&gt; It has to happen at the ALB, because the ALB can't read paths inside a locked box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The catch:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser → ALB is encrypted ✅&lt;/li&gt;
&lt;li&gt;ALB → Pod is &lt;strong&gt;plain HTTP&lt;/strong&gt; in this setup ❌&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is common, but it is &lt;strong&gt;not end-to-end encryption&lt;/strong&gt;. "It's inside our private VPC" doesn't mean it's encrypted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix is to re-encrypt to the backend.&lt;/strong&gt; Set the ALB target group to HTTPS, and you get two separate TLS connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser ⇄ ALB   (TLS connection 1, ACM certificate)
ALB ⇄ Pod       (TLS connection 2, the Pod's own certificate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ALB still opens the box briefly to read it, then locks it again before sending it on.&lt;/p&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/02-where-does-the-lock-open.md" rel="noopener noreferrer"&gt;Lab 2: Where does the lock open?&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Where Kubernetes fits in
&lt;/h2&gt;

&lt;p&gt;Your cluster has three apps (frontend, checkout, payment), each with a Deployment and a Service. You need a front door from the internet into the cluster.&lt;/p&gt;

&lt;p&gt;Two terms people confuse:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ingress&lt;/strong&gt; = a Kubernetes object containing routing rules, like an instruction sheet ("send &lt;code&gt;/checkout&lt;/code&gt; to &lt;code&gt;checkout-svc&lt;/code&gt;").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ingress Controller&lt;/strong&gt; = the thing that reads the instruction sheet and makes it real.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;An Ingress on its own does nothing.&lt;/strong&gt; Without a controller, it's a note nobody reads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The AWS Load Balancer Controller&lt;/strong&gt; runs inside EKS and watches your Kubernetes objects:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You write in Kubernetes&lt;/th&gt;
&lt;th&gt;AWS creates&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kind: Ingress&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ALB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Service&lt;/code&gt; with &lt;code&gt;type: LoadBalancer&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;NLB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;It also creates the routing rules and registers your Pod IPs as targets. You never click around the console building the ALB: you write YAML and the controller builds it.&lt;/p&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/03-controller-detective.md" rel="noopener noreferrer"&gt;Lab 3: Controller detective&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  11. cert-manager, and how it differs from ACM
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;cert-manager&lt;/strong&gt; runs inside Kubernetes and does for workloads in the cluster what ACM does for AWS resources.&lt;/p&gt;

&lt;p&gt;Example: you run an in-cluster gateway that needs its own certificate. cert-manager:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;asks Let's Encrypt (or another CA) for a certificate&lt;/li&gt;
&lt;li&gt;proves you own the domain&lt;/li&gt;
&lt;li&gt;gets the certificate&lt;/li&gt;
&lt;li&gt;stores it in a &lt;strong&gt;Kubernetes Secret&lt;/strong&gt; with two parts:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tls.crt&lt;/code&gt; = the certificate&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tls.key&lt;/code&gt; = &lt;strong&gt;the private key, so protect that Secret&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;lets the gateway read that Secret and use it&lt;/li&gt;
&lt;li&gt;renews the certificate before it expires&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;ACM&lt;/th&gt;
&lt;th&gt;cert-manager&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lives in&lt;/td&gt;
&lt;td&gt;AWS&lt;/td&gt;
&lt;td&gt;Kubernetes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Used for&lt;/td&gt;
&lt;td&gt;ALB / NLB / AWS services&lt;/td&gt;
&lt;td&gt;Things inside the cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Private key&lt;/td&gt;
&lt;td&gt;Hidden by AWS; you never touch it&lt;/td&gt;
&lt;td&gt;Stored in a Kubernetes Secret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical CA&lt;/td&gt;
&lt;td&gt;Amazon&lt;/td&gt;
&lt;td&gt;Let's Encrypt, Vault, a private CA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Two typical setups:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Setup A: ALB + ACM (the main one).&lt;/strong&gt; The certificate lives in ACM and is attached to the ALB. You don't need cert-manager just to get HTTPS on an ALB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setup B: NLB + in-cluster gateway + cert-manager.&lt;/strong&gt; The NLB passes the encrypted traffic through. The gateway in the cluster decrypts it with a cert-manager certificate and does the host/path routing, since the NLB can't.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/04-two-certificate-managers.md" rel="noopener noreferrer"&gt;Lab 4: Two certificate managers&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  12. NLB and TLS: two ways to handle encryption
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Option A: the NLB terminates TLS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listener type &lt;strong&gt;TLS&lt;/strong&gt;, port 443, with an ACM certificate.&lt;/li&gt;
&lt;li&gt;The NLB opens the box and sends decrypted traffic to the backend.&lt;/li&gt;
&lt;li&gt;Optionally it re-encrypts to the backend (a TLS target group, which is a second connection).&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;still can't route by URL&lt;/strong&gt;. It only handles the connection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Option B: TLS passthrough&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listener type &lt;strong&gt;TCP&lt;/strong&gt;, port 443. Note: TCP, not TLS.&lt;/li&gt;
&lt;li&gt;The NLB &lt;strong&gt;never opens the box&lt;/strong&gt;. It forwards the encrypted bytes unchanged.&lt;/li&gt;
&lt;li&gt;Your gateway inside the cluster decrypts them with a cert-manager certificate.&lt;/li&gt;
&lt;li&gt;Use this when the rule is &lt;em&gt;"the load balancer must not see our decrypted traffic."&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You want...&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS to handle public HTTPS + URL routing&lt;/td&gt;
&lt;td&gt;ALB + ACM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The NLB to handle public TLS&lt;/td&gt;
&lt;td&gt;NLB TLS listener + ACM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your own proxy to receive the original encrypted traffic&lt;/td&gt;
&lt;td&gt;NLB TCP listener (passthrough)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing by host/path&lt;/td&gt;
&lt;td&gt;ALB, or a Layer 7 proxy/gateway in the cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Encryption to the backend too&lt;/td&gt;
&lt;td&gt;HTTPS/TLS on the backend connection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Lesson: TLS termination and Layer 7 routing are different things.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/05-nlb-two-ways.md" rel="noopener noreferrer"&gt;Lab 5: NLB two ways&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Encryption inside the system
&lt;/h2&gt;

&lt;p&gt;So far we've only protected customer → load balancer. Inside the cluster, traffic goes frontend → checkout → payment → database. If all of that is plain text, an attacker who gets into the network or takes over one Pod can listen in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The layers of protection:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A. Customer → ALB:&lt;/strong&gt; HTTPS with the ACM certificate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;B. ALB → Pod:&lt;/strong&gt; an HTTPS target group (re-encryption).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;C. Pod → Pod:&lt;/strong&gt; services talk over TLS. Big systems use a &lt;strong&gt;service mesh&lt;/strong&gt; (Istio, Linkerd), so you don't configure TLS in every app by hand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;D. App → Database:&lt;/strong&gt; require TLS on PostgreSQL. &lt;code&gt;sslmode=verify-full&lt;/code&gt; means encrypt &lt;em&gt;and&lt;/em&gt; check the database's certificate and hostname, so you know it's the real database. For RDS, AWS publishes the CA certificate your app uses to verify it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;E. Application-level encryption:&lt;/strong&gt; the app encrypts sensitive fields (for example payment references) before saving them, using keys from &lt;strong&gt;AWS KMS&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is mTLS (mutual TLS)?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Normal TLS:&lt;/strong&gt; only the server shows an ID card. The browser checks the website, but the website doesn't check a certificate from the browser.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;mTLS:&lt;/strong&gt; &lt;em&gt;both&lt;/em&gt; sides show ID cards and check each other. When frontend calls checkout, frontend checks "are you really checkout?" and checkout checks "are you really frontend?" A hacked Pod can't just &lt;em&gt;claim&lt;/em&gt; to be checkout; it has to prove it. Service meshes make this automatic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Three kinds of encryption. Don't mix them up:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Protects data...&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;In transit&lt;/td&gt;
&lt;td&gt;While it travels&lt;/td&gt;
&lt;td&gt;HTTPS, Pod-to-Pod TLS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;At rest&lt;/td&gt;
&lt;td&gt;While it's stored on disk&lt;/td&gt;
&lt;td&gt;Encrypted RDS, encrypted EBS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application-level&lt;/td&gt;
&lt;td&gt;Specific fields, even inside the DB&lt;/td&gt;
&lt;td&gt;Card references encrypted with KMS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Passwords are different: hash them, don't encrypt them.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encryption is reversible with the key.&lt;/li&gt;
&lt;li&gt;Hashing is one-way: you can't get the original back, you only compare hashes at login.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Argon2id&lt;/strong&gt; or &lt;strong&gt;bcrypt&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Big takeaway:&lt;/strong&gt; "We use TLS, so we're secure" is wrong. TLS is one layer among many.&lt;/p&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/06-zero-trust-inside-the-cluster.md" rel="noopener noreferrer"&gt;Lab 6: mTLS&lt;/a&gt; · &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/07-lock-the-database.md" rel="noopener noreferrer"&gt;Lab 7: database TLS&lt;/a&gt; · &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/08-protect-the-data-itself.md" rel="noopener noreferrer"&gt;Lab 8: app-level encryption&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Certificate rotation (expiry)
&lt;/h2&gt;

&lt;p&gt;Every certificate has an expiry date. If it expires, you get browser warnings and failed connections, and &lt;strong&gt;a perfectly healthy app looks dead to customers.&lt;/strong&gt; Replacing it before expiry is called &lt;strong&gt;renewal&lt;/strong&gt; or &lt;strong&gt;rotation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ACM rotation (easy mode):&lt;/strong&gt; ACM notices that expiry is getting close, re-checks ownership through the DNS record you left in place, issues the renewed certificate and puts it on the ALB. You do nothing.&lt;/p&gt;

&lt;p&gt;Two conditions apply:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the DNS validation record must still exist&lt;/li&gt;
&lt;li&gt;the certificate must be eligible for managed renewal&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ ACM won't renew a certificate you &lt;strong&gt;imported&lt;/strong&gt; from another company. You renew it with that company and re-import it yourself.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;cert-manager rotation has one extra trap.&lt;/strong&gt; cert-manager watches the expiry date, requests a new certificate in time and updates the Kubernetes Secret. &lt;strong&gt;The app might not notice.&lt;/strong&gt; Some apps watch the file and reload automatically. Others only read the certificate at startup, so they keep serving the old one until they're restarted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; restart the Pods, or use a "reloader" tool that restarts them whenever the Secret changes.&lt;/p&gt;

&lt;p&gt;👉 Practise it: &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/09-certificate-fire-drill.md" rel="noopener noreferrer"&gt;Lab 9: Certificate fire drill&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  15. Building the project, step by step
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Phase 1: Domain&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Buy &lt;code&gt;example.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a hosted zone in Route 53.&lt;/li&gt;
&lt;li&gt;If you bought the domain elsewhere, point its nameservers at Route 53.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Phase 2: Certificate&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In ACM, request a public certificate for &lt;code&gt;shop.example.com&lt;/code&gt; with DNS validation.&lt;/li&gt;
&lt;li&gt;Add the CNAME and wait for &lt;strong&gt;Issued&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Copy the &lt;strong&gt;certificate ARN&lt;/strong&gt; (its unique AWS ID).&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;ACM certificates are regional.&lt;/strong&gt; If your ALB is in Frankfurt (&lt;code&gt;eu-central-1&lt;/code&gt;), the certificate must be in &lt;code&gt;eu-central-1&lt;/code&gt; too.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Phase 3: EKS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create the cluster.&lt;/li&gt;
&lt;li&gt;Install the AWS Load Balancer Controller, with IAM permissions that allow it to create ALBs.&lt;/li&gt;
&lt;li&gt;Deploy frontend, checkout and payment (Deployments + Services) in a &lt;code&gt;shopping&lt;/code&gt; namespace.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Phase 4: the Ingress (the key file)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;networking.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Ingress&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;shopping&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;shopping&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;alb.ingress.kubernetes.io/scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;internet-facing&lt;/span&gt;
    &lt;span class="na"&gt;alb.ingress.kubernetes.io/target-type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ip&lt;/span&gt;
    &lt;span class="na"&gt;alb.ingress.kubernetes.io/listen-ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'[{"HTTP": 80}, {"HTTPS": 443}]'&lt;/span&gt;
    &lt;span class="na"&gt;alb.ingress.kubernetes.io/certificate-arn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arn:aws:acm:eu-central-1:111122223333:certificate/...&lt;/span&gt;
    &lt;span class="na"&gt;alb.ingress.kubernetes.io/ssl-redirect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'443'&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;ingressClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;alb&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;shop.example.com&lt;/span&gt;
      &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;path:&lt;/span&gt; &lt;span class="s"&gt;/checkout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;pathType:&lt;/span&gt; &lt;span class="s"&gt;Prefix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;backend:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;service:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;name:&lt;/span&gt; &lt;span class="s"&gt;checkout-svc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;port:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;number:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;path:&lt;/span&gt; &lt;span class="s"&gt;/payment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="s"&gt;pathType:&lt;/span&gt; &lt;span class="s"&gt;Prefix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;backend:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;service:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;name:&lt;/span&gt; &lt;span class="s"&gt;payment-svc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="s"&gt;port:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;number:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;path:&lt;/span&gt; &lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="s"&gt;pathType:&lt;/span&gt; &lt;span class="s"&gt;Prefix&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;backend:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;service:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;name:&lt;/span&gt; &lt;span class="s"&gt;frontend-svc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;port:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;number:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What each line means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ingressClassName: alb&lt;/code&gt; → "AWS Load Balancer Controller, this one's yours."&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;scheme: internet-facing&lt;/code&gt; → a public ALB, reachable from the internet. (The default is &lt;code&gt;internal&lt;/code&gt;.)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;target-type: ip&lt;/code&gt; → send traffic straight to Pod IPs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;listen-ports&lt;/code&gt; → open both doors, 80 and 443.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;certificate-arn&lt;/code&gt; → attach the ACM certificate to port 443.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ssl-redirect: '443'&lt;/code&gt; → anyone on plain HTTP gets pushed to HTTPS.&lt;/li&gt;
&lt;li&gt;The rules: &lt;code&gt;/checkout&lt;/code&gt; → checkout, &lt;code&gt;/payment&lt;/code&gt; → payment, and &lt;code&gt;/&lt;/code&gt; → frontend as the catch-all.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run &lt;code&gt;kubectl apply -f shopping-ingress.yaml&lt;/code&gt; and the controller builds an ALB with listeners on 80 and 443, the ACM certificate on 443, one target group each for frontend, checkout and payment, and the routing rules and Pod IP registrations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 5: DNS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find the ALB's DNS name.&lt;/li&gt;
&lt;li&gt;In Route 53, create an &lt;strong&gt;A record (Alias)&lt;/strong&gt;: &lt;code&gt;shop.example.com&lt;/code&gt; → the ALB.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;https://shop.example.com&lt;/code&gt; now works end to end.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  16. Gateway API (the newer way)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ingress&lt;/strong&gt; = older and simpler, mostly basic HTTP routing rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway API&lt;/strong&gt; = the newer, more capable successor. It covers HTTP, TCP, TLS and service-mesh cases, and separates cleanly who owns what. Its objects are &lt;code&gt;GatewayClass&lt;/code&gt;, &lt;code&gt;Gateway&lt;/code&gt;, &lt;code&gt;HTTPRoute&lt;/code&gt;, &lt;code&gt;TLSRoute&lt;/code&gt; and &lt;code&gt;TCPRoute&lt;/code&gt;. &lt;code&gt;HTTPRoute&lt;/code&gt; does the same host/path matching as Ingress rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;News worth knowing:&lt;/strong&gt; the community &lt;strong&gt;ingress-nginx controller was retired in March 2026.&lt;/strong&gt; It still runs but gets no security fixes, so don't start new production projects on it. Use the AWS Load Balancer Controller, another maintained controller, or a Gateway API implementation. &lt;strong&gt;The Ingress API itself is not retired.&lt;/strong&gt; Only that one popular controller is.&lt;/p&gt;

&lt;h2&gt;
  
  
  17. Other security pieces: who does what
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Simple job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ACM&lt;/td&gt;
&lt;td&gt;Manages certificates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TLS&lt;/td&gt;
&lt;td&gt;Encrypts and proves identity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALB&lt;/td&gt;
&lt;td&gt;Routes HTTP requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NLB&lt;/td&gt;
&lt;td&gt;Routes network connections&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS WAF&lt;/td&gt;
&lt;td&gt;Reads requests and blocks malicious ones (attached to the ALB)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security Groups&lt;/td&gt;
&lt;td&gt;Firewall around each AWS resource&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Network ACL&lt;/td&gt;
&lt;td&gt;Firewall at the subnet level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;K8s NetworkPolicy&lt;/td&gt;
&lt;td&gt;Firewall between Pods ("frontend may talk to checkout, not to the DB")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;KMS&lt;/td&gt;
&lt;td&gt;Stores and manages encryption keys&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service mesh&lt;/td&gt;
&lt;td&gt;Automatic mTLS between services&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; an attacker sends a malicious login request over HTTPS. TLS faithfully encrypts it, and encryption doesn't make it safe. The ALB decrypts it, then &lt;strong&gt;WAF inspects it and blocks it.&lt;/strong&gt; That's why you stack several controls.&lt;/p&gt;

&lt;h2&gt;
  
  
  18. The interview answer, simplified
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"How do you do HTTPS and certificates in EKS?"&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Domain and DNS are managed in Route 53.&lt;/li&gt;
&lt;li&gt;A public certificate comes from ACM, validated by DNS.&lt;/li&gt;
&lt;li&gt;The AWS Load Balancer Controller turns our Ingress into an ALB.&lt;/li&gt;
&lt;li&gt;The ACM certificate is attached to the 443 listener.&lt;/li&gt;
&lt;li&gt;An HTTP → HTTPS redirect means nobody stays on plain HTTP.&lt;/li&gt;
&lt;li&gt;Host/path routing sends traffic to the right microservice.&lt;/li&gt;
&lt;li&gt;The ALB terminates TLS. Where needed, it uses HTTPS to the Pods too.&lt;/li&gt;
&lt;li&gt;Internal services talk over TLS or mTLS (service mesh).&lt;/li&gt;
&lt;li&gt;ACM auto-renews. We monitor expiry and make sure apps reload any certificates they use.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  19. The five things to really remember
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ACM ≠ cert-manager.&lt;/strong&gt; ACM handles certificates for AWS resources. cert-manager handles certificates inside Kubernetes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ALB ≠ NLB.&lt;/strong&gt; The ALB reads HTTP and routes by host/path. The NLB only handles connections.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Termination decides where the encryption ends.&lt;/strong&gt; HTTPS to the ALB does not mean HTTPS to the Pod.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS ≠ fully secure.&lt;/strong&gt; You also need internal TLS, database TLS, WAF, network rules, encryption at rest and proper password hashing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automate certificates.&lt;/strong&gt; An expired certificate takes down a healthy app.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  20. Quick cheat sheet
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Domain&lt;/strong&gt; = buying the name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS / Route 53&lt;/strong&gt; = address book&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Certificate&lt;/strong&gt; = website ID card&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CA&lt;/strong&gt; = passport office that issues the ID cards&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private key&lt;/strong&gt; = the secret that proves you own the ID. Never leak it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLS handshake&lt;/strong&gt; = agreeing on a secret language before talking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLS termination&lt;/strong&gt; = where the locked box gets opened&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLS passthrough&lt;/strong&gt; = forwarding the locked box unopened&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ingress&lt;/strong&gt; = instruction sheet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ingress Controller / AWS LB Controller&lt;/strong&gt; = the worker who follows the sheet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;mTLS&lt;/strong&gt; = both sides show ID&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WAF&lt;/strong&gt; = bouncer who checks requests for bad stuff&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotation&lt;/strong&gt; = swapping certificates before they expire&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Practise it: 10 mini projects
&lt;/h2&gt;

&lt;p&gt;Reading this won't make it stick. Each lab below has a &lt;strong&gt;scenario and task&lt;/strong&gt;, the &lt;strong&gt;concepts&lt;/strong&gt; behind it, an &lt;strong&gt;implementation guide&lt;/strong&gt; (steps and key settings, not copy-paste code), and a &lt;strong&gt;prove it / break it&lt;/strong&gt; drill. They focus on sections 8–14.&lt;/p&gt;

&lt;p&gt;☁️ = needs AWS (costs money while it runs) · 🏠 = free on a local kind/k3d cluster&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Lab&lt;/th&gt;
&lt;th&gt;Sections&lt;/th&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/00-lab-foundation.md" rel="noopener noreferrer"&gt;Lab foundation&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;setup&lt;/td&gt;
&lt;td&gt;☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/01-one-alb-many-services.md" rel="noopener noreferrer"&gt;One ALB, many services&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;8, 10&lt;/td&gt;
&lt;td&gt;☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/02-where-does-the-lock-open.md" rel="noopener noreferrer"&gt;Where does the lock open?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/03-controller-detective.md" rel="noopener noreferrer"&gt;Controller detective&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/04-two-certificate-managers.md" rel="noopener noreferrer"&gt;Two certificate managers&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;☁️ / 🏠&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/05-nlb-two-ways.md" rel="noopener noreferrer"&gt;NLB two ways&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/06-zero-trust-inside-the-cluster.md" rel="noopener noreferrer"&gt;Zero-trust inside the cluster&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;13 (mTLS)&lt;/td&gt;
&lt;td&gt;🏠&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/07-lock-the-database.md" rel="noopener noreferrer"&gt;Lock the database&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;13 (DB TLS)&lt;/td&gt;
&lt;td&gt;🏠 / ☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/08-protect-the-data-itself.md" rel="noopener noreferrer"&gt;Protect the data itself&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;13 (app-level, hashing)&lt;/td&gt;
&lt;td&gt;🏠 + tiny ☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/09-certificate-fire-drill.md" rel="noopener noreferrer"&gt;Certificate fire drill&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;🏠 / ☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/labs/10-capstone.md" rel="noopener noreferrer"&gt;Capstone&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;everything&lt;/td&gt;
&lt;td&gt;☁️&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Suggested order:&lt;/strong&gt; first build EKS + ALB + ACM end to end (labs 0–3). Then cert-manager and NLB passthrough (4–5). Then the internal-encryption labs (6–9), most of which run free on kind. Finish with the capstone. Each step builds on the one before.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/eks-https-tls-labs/blob/main/docs/https-on-eks-explained.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/eks-https-tls-labs/blob/main/docs/https-on-eks-explained.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>ESO vs Secrets Store CSI Driver on EKS: Two Ways to Deliver an AWS Secret</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Tue, 03 Nov 2026 14:55:58 +0000</pubDate>
      <link>https://dev.to/nazmur96/eso-vs-secrets-store-csi-driver-on-eks-two-ways-to-deliver-an-aws-secret-k45</link>
      <guid>https://dev.to/nazmur96/eso-vs-secrets-store-csi-driver-on-eks-two-ways-to-deliver-an-aws-secret-k45</guid>
      <description>&lt;p&gt;In my &lt;a href="https://github.com/nazmur96/devops-sre-authentication/blob/main/posts/eso-eks-pod-identity.md" rel="noopener noreferrer"&gt;last post&lt;/a&gt;&lt;br&gt;
an app in EKS read a database password from AWS Secrets Manager through&lt;br&gt;
&lt;strong&gt;ESO&lt;/strong&gt; (External Secrets Operator). The app just read a normal Kubernetes&lt;br&gt;
Secret, and ESO filled it in.&lt;/p&gt;

&lt;p&gt;ESO is not the only way. The other common one is the &lt;strong&gt;Secrets Store CSI&lt;br&gt;
Driver&lt;/strong&gt; with the &lt;strong&gt;AWS provider (ASCP)&lt;/strong&gt;. Both get the same secret into the&lt;br&gt;
same pod. They differ in two things that matter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Where the password ends up:&lt;/strong&gt; a Kubernetes Secret, or files inside the pod.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who holds the AWS permission:&lt;/strong&gt; one controller, or each app.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg2yl3tt76h6j93ze9r9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg2yl3tt76h6j93ze9r9y.png" alt="ESO vs CSI driver: same secret, two delivery routes into an EKS pod" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The analogy, continued
&lt;/h2&gt;

&lt;p&gt;Secrets Manager is still the bank vault.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ESO is a courier.&lt;/strong&gt; One courier has the permission slip (IAM role). It
picks up the cash and puts it in a locker inside your building (a Kubernetes
Secret). Anyone with the locker key can open it. Your app doesn't need a
slip.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSI is direct delivery to a desk.&lt;/strong&gt; Each employee (pod) has their own
permission slip. When they sit down (the pod starts), the vault delivers a
sealed envelope straight to their desk drawer (a mounted volume). There is
no locker in the building.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;ESO&lt;/th&gt;
&lt;th&gt;CSI driver (files only)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Creates a Kubernetes Secret?&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (unless you turn on sync)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App reads it as&lt;/td&gt;
&lt;td&gt;Env vars or Secret volume&lt;/td&gt;
&lt;td&gt;Files in a mounted directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who holds the IAM role&lt;/td&gt;
&lt;td&gt;The ESO controller&lt;/td&gt;
&lt;td&gt;Each app's ServiceAccount&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;When it fetches&lt;/td&gt;
&lt;td&gt;Every &lt;code&gt;refreshInterval&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;At pod start, then optional rotation polling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runs on Fargate?&lt;/td&gt;
&lt;td&gt;Yes (ESO is a normal Deployment)&lt;/td&gt;
&lt;td&gt;No, ASCP is a DaemonSet (EC2 nodes only)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical fit&lt;/td&gt;
&lt;td&gt;Apps already built around K8s Secrets / env vars&lt;/td&gt;
&lt;td&gt;Apps that can read files, and teams that don't want a copy in etcd&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The one-liner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ESO:  AWS → ESO controller → Kubernetes Secret → Pod
CSI:  AWS → ASCP + CSI driver → files in the pod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Which one should you pick?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;App already reads &lt;code&gt;DB_PASSWORD&lt;/code&gt; from an env var or a Secret → &lt;strong&gt;ESO&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You want one place that syncs many secrets into many namespaces → &lt;strong&gt;ESO&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You don't want a copy of the password in the Kubernetes API / etcd, and the
app can read a file → &lt;strong&gt;CSI&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Each app should hold its own narrowly-scoped IAM role → &lt;strong&gt;CSI&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Running on Fargate → &lt;strong&gt;ESO&lt;/strong&gt; (ASCP doesn't run there).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's a per-workload choice, not a religion. One thing to watch: CSI has an&lt;br&gt;
optional "sync as Kubernetes Secret" feature. Turn it on and you've got the&lt;br&gt;
etcd copy back, so you've lost the main reason to pick CSI.&lt;/p&gt;

&lt;p&gt;A reminder for both: a Kubernetes Secret is base64, not encrypted. If you use&lt;br&gt;
ESO, turn on etcd encryption at rest and keep RBAC on Secrets tight. If you use&lt;br&gt;
CSI, the mounted file is still the password; it's just not in etcd.&lt;/p&gt;


&lt;h1&gt;
  
  
  Hands-on: CSI driver + ASCP with Pod Identity
&lt;/h1&gt;

&lt;p&gt;The ESO walkthrough is in the&lt;br&gt;
&lt;a href="https://github.com/nazmur96/devops-sre-authentication/blob/main/posts/eso-eks-pod-identity.md" rel="noopener noreferrer"&gt;previous post&lt;/a&gt;.&lt;br&gt;
This is the CSI version for the same kind of secret.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; an EKS cluster with &lt;strong&gt;EC2 nodes&lt;/strong&gt;, the EKS Pod Identity&lt;br&gt;
Agent add-on installed, and &lt;code&gt;aws&lt;/code&gt;, &lt;code&gt;kubectl&lt;/code&gt; and &lt;code&gt;helm&lt;/code&gt; configured.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 0: Variables
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CLUSTER_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;my-cluster
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;AWS_REGION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;eu-central-1
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ACCOUNT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;aws sts get-caller-identity &lt;span class="nt"&gt;--query&lt;/span&gt; Account &lt;span class="nt"&gt;--output&lt;/span&gt; text&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 1: The secret in AWS
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws secretsmanager create-secret &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; payments/db &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--region&lt;/span&gt; &lt;span class="nv"&gt;$AWS_REGION&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--secret-string&lt;/span&gt; &lt;span class="s1"&gt;'{"username":"payments_app","password":"CHANGE_ME"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2: Install the CSI driver
&lt;/h3&gt;

&lt;p&gt;Pod Identity needs the driver to request service-account tokens for &lt;strong&gt;two&lt;/strong&gt;&lt;br&gt;
audiences. Miss the second one and mounts fail with an auth error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo add secrets-store-csi-driver &lt;span class="se"&gt;\&lt;/span&gt;
  https://kubernetes-sigs.github.io/secrets-store-csi-driver/charts
helm repo update

helm upgrade &lt;span class="nt"&gt;--install&lt;/span&gt; csi-secrets-store &lt;span class="se"&gt;\&lt;/span&gt;
  secrets-store-csi-driver/secrets-store-csi-driver &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--namespace&lt;/span&gt; kube-system &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--set&lt;/span&gt; &lt;span class="s2"&gt;"tokenRequests[0].audience=sts.amazonaws.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--set&lt;/span&gt; &lt;span class="s2"&gt;"tokenRequests[1].audience=pods.eks.amazonaws.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--set&lt;/span&gt; &lt;span class="nv"&gt;enableSecretRotation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--set&lt;/span&gt; &lt;span class="nv"&gt;rotationPollInterval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3600s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AWS recommends a one-hour poll interval. Shorter intervals mean more&lt;br&gt;
Secrets Manager API calls, and those cost money.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Install the AWS provider (ASCP)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo add aws-secrets-manager &lt;span class="se"&gt;\&lt;/span&gt;
  https://aws.github.io/secrets-store-csi-driver-provider-aws
helm repo update

helm upgrade &lt;span class="nt"&gt;--install&lt;/span&gt; secrets-provider-aws &lt;span class="se"&gt;\&lt;/span&gt;
  aws-secrets-manager/secrets-store-csi-driver-provider-aws &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--namespace&lt;/span&gt; kube-system &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--set&lt;/span&gt; secrets-store-csi-driver.install&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;install=false&lt;/code&gt; stops the ASCP chart from installing a second copy of the&lt;br&gt;
driver, because we installed it ourselves in Step 2. (The other way is to skip&lt;br&gt;
Step 2 and let the ASCP chart install the driver. Just don't do both.)&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 4: An IAM role for the &lt;strong&gt;app&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is the big difference from ESO: the role belongs to the app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; trust-policy.json &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "Service": "pods.eks.amazonaws.com" },
    "Action": ["sts:AssumeRole", "sts:TagSession"]
  }]
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; permissions-policy.json &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret"],
    "Resource": "arn:aws:secretsmanager:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;AWS_REGION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ACCOUNT_ID&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;:secret:payments/db-*"
  }]
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;aws iam create-role &lt;span class="nt"&gt;--role-name&lt;/span&gt; payments-api-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--assume-role-policy-document&lt;/span&gt; file://trust-policy.json
aws iam put-role-policy &lt;span class="nt"&gt;--role-name&lt;/span&gt; payments-api-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--policy-name&lt;/span&gt; read-payments-db &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--policy-document&lt;/span&gt; file://permissions-policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-*&lt;/code&gt; covers the random suffix AWS adds to every secret ARN. If the secret&lt;br&gt;
uses a customer-managed KMS key, also allow &lt;code&gt;kms:Decrypt&lt;/code&gt; on that key.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 5: ServiceAccount + Pod Identity association
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create namespace payments
kubectl create serviceaccount payments-api &lt;span class="nt"&gt;-n&lt;/span&gt; payments

aws eks create-pod-identity-association &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cluster-name&lt;/span&gt; &lt;span class="nv"&gt;$CLUSTER_NAME&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--namespace&lt;/span&gt; payments &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--service-account&lt;/span&gt; payments-api &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role-arn&lt;/span&gt; arn:aws:iam::&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ACCOUNT_ID&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;:role/payments-api-secrets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The app pod doesn't exist yet, so no restart is needed here. That's not true&lt;br&gt;
for ESO; see the gotchas below.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 6: SecretProviderClass (which secret, which filenames)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# secret-provider-class.yaml&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;secrets-store.csi.x-k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SecretProviderClass&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-payments-db&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;payments&lt;/span&gt;          &lt;span class="c1"&gt;# must be the pod's namespace&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws&lt;/span&gt;
  &lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eu-central-1&lt;/span&gt;
    &lt;span class="na"&gt;usePodIdentity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;true"&lt;/span&gt;
    &lt;span class="na"&gt;objects&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
      &lt;span class="s"&gt;- objectName: "payments/db"&lt;/span&gt;
        &lt;span class="s"&gt;objectType: "secretsmanager"&lt;/span&gt;
        &lt;span class="s"&gt;jmesPath:&lt;/span&gt;
          &lt;span class="s"&gt;- path: "username"&lt;/span&gt;
            &lt;span class="s"&gt;objectAlias: "DB_USERNAME"&lt;/span&gt;
          &lt;span class="s"&gt;- path: "password"&lt;/span&gt;
            &lt;span class="s"&gt;objectAlias: "DB_PASSWORD"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; secret-provider-class.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 7: Mount it in the app
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# app.yaml&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;payments-api&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;payments&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;payments-api&lt;/span&gt; &lt;span class="pi"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;payments-api&lt;/span&gt; &lt;span class="pi"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;serviceAccountName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;payments-api&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;payments-api&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;busybox&lt;/span&gt;
          &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sh"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-c"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;echo&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;started;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;sleep&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;3600"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
          &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;db-secrets&lt;/span&gt;
              &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/mnt/secrets-store&lt;/span&gt;
              &lt;span class="na"&gt;readOnly&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;db-secrets&lt;/span&gt;
          &lt;span class="na"&gt;csi&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;secrets-store.csi.k8s.io&lt;/span&gt;
            &lt;span class="na"&gt;readOnly&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
            &lt;span class="na"&gt;volumeAttributes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;secretProviderClass&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-payments-db&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; app.yaml
kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; payments deploy/payments-api &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nb"&gt;ls&lt;/span&gt; /mnt/secrets-store
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You'll see &lt;strong&gt;three&lt;/strong&gt; files, not two:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_PASSWORD
DB_USERNAME
payments_db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;payments_db&lt;/code&gt; is the whole JSON secret. ASCP mounts the full object as well as&lt;br&gt;
the &lt;code&gt;jmesPath&lt;/code&gt; keys, and turns the &lt;code&gt;/&lt;/code&gt; in the name into &lt;code&gt;_&lt;/code&gt;. So the&lt;br&gt;
"only the password" idea doesn't hold: the username and password are both in&lt;br&gt;
that file. Lock down &lt;code&gt;exec&lt;/code&gt; access accordingly.&lt;/p&gt;
&lt;h2&gt;
  
  
  Gotchas (both tools)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. ESO + Pod Identity: restart ESO after creating the association.&lt;/strong&gt;&lt;br&gt;
Pod Identity injects credentials into a pod only when the pod is &lt;em&gt;created&lt;/em&gt;.&lt;br&gt;
The usual order is "helm install ESO, then create the association", and that&lt;br&gt;
leaves the running ESO controller with no AWS credentials. Your&lt;br&gt;
ClusterSecretStore goes not-ready with a credentials or AccessDenied error.&lt;br&gt;
Fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl rollout restart deploy/external-secrets &lt;span class="nt"&gt;-n&lt;/span&gt; external-secrets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or create the association before the Helm install. The CSI walkthrough above&lt;br&gt;
avoids this only because the app pod is created after its association.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Private clusters: Pod Identity uses &lt;code&gt;eks-auth&lt;/code&gt;, not STS.&lt;/strong&gt;&lt;br&gt;
A lot of guides say "make sure the cluster can reach STS". That's the IRSA&lt;br&gt;
path. With Pod Identity, the agent on each node gets credentials from the&lt;br&gt;
&lt;strong&gt;EKS Auth API&lt;/strong&gt;. In a private cluster with no NAT you need interface VPC&lt;br&gt;
endpoints for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;com.amazonaws.&amp;lt;region&amp;gt;.eks-auth&lt;/code&gt;: Pod Identity credentials&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;com.amazonaws.&amp;lt;region&amp;gt;.secretsmanager&lt;/code&gt;: the secret itself&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;com.amazonaws.&amp;lt;region&amp;gt;.kms&lt;/code&gt;: only with a customer-managed key&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;com.amazonaws.&amp;lt;region&amp;gt;.sts&lt;/code&gt;: only if you use IRSA instead&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Lock down a ClusterSecretStore.&lt;/strong&gt; A ClusterSecretStore with no&lt;br&gt;
restrictions lets &lt;em&gt;any&lt;/em&gt; namespace that can create an ExternalSecret read&lt;br&gt;
&lt;em&gt;anything&lt;/em&gt; the ESO role can read. Use &lt;code&gt;spec.conditions&lt;/code&gt; with a&lt;br&gt;
&lt;code&gt;namespaceSelector&lt;/code&gt;, or a namespaced &lt;code&gt;SecretStore&lt;/code&gt; per team.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Nobody reloads your app.&lt;/strong&gt; ESO updates the Kubernetes Secret and CSI&lt;br&gt;
updates the file. Env vars never change in a running process. Mounted files&lt;br&gt;
change, but your DB client won't notice unless it re-reads them. Watch the&lt;br&gt;
file, use something like Reloader, or do a controlled rollout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Look here&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ExternalSecret / ClusterSecretStore not ready, AccessDenied&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe clustersecretstore …&lt;/code&gt;; restart ESO if the association came after it started; check the association's namespace and SA name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSI pod stuck in &lt;code&gt;ContainerCreating&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pod&lt;/code&gt;: mount events usually name the exact error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSI mount auth error&lt;/td&gt;
&lt;td&gt;Both &lt;code&gt;tokenRequests&lt;/code&gt; audiences set? &lt;code&gt;usePodIdentity: "true"&lt;/code&gt;? Association on the pod's SA?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSI provider not found&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get pods -n kube-system&lt;/code&gt;: is the ASCP DaemonSet on that node? (Fargate: it can't be)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File missing&lt;/td&gt;
&lt;td&gt;SecretProviderClass in the pod's namespace? &lt;code&gt;objectName&lt;/code&gt;, &lt;code&gt;jmesPath&lt;/code&gt;, &lt;code&gt;secretProviderClass&lt;/code&gt; name all spelled right?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works in public subnets, times out in private&lt;/td&gt;
&lt;td&gt;VPC endpoints from gotcha 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Cleanup
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete namespace payments
helm uninstall secrets-provider-aws &lt;span class="nt"&gt;-n&lt;/span&gt; kube-system
helm uninstall csi-secrets-store &lt;span class="nt"&gt;-n&lt;/span&gt; kube-system
aws eks delete-pod-identity-association &lt;span class="nt"&gt;--cluster-name&lt;/span&gt; &lt;span class="nv"&gt;$CLUSTER_NAME&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--association-id&lt;/span&gt; &amp;lt;id-from-list-pod-identity-associations&amp;gt;
aws iam delete-role-policy &lt;span class="nt"&gt;--role-name&lt;/span&gt; payments-api-secrets &lt;span class="nt"&gt;--policy-name&lt;/span&gt; read-payments-db
aws iam delete-role &lt;span class="nt"&gt;--role-name&lt;/span&gt; payments-api-secrets
aws secretsmanager delete-secret &lt;span class="nt"&gt;--secret-id&lt;/span&gt; payments/db &lt;span class="nt"&gt;--force-delete-without-recovery&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/ascp-eks-installation.html" rel="noopener noreferrer"&gt;AWS: ASCP for EKS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/aws/secrets-store-csi-driver-provider-aws" rel="noopener noreferrer"&gt;ASCP README&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/pod-id-association.html" rel="noopener noreferrer"&gt;EKS Pod Identity associations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://external-secrets.io/latest/provider/aws-access/" rel="noopener noreferrer"&gt;ESO AWS authentication&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://secrets-store-csi-driver.sigs.k8s.io/" rel="noopener noreferrer"&gt;Secrets Store CSI Driver&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-sre-authentication/blob/main/posts/eso-vs-csi-driver-eks.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-sre-authentication/blob/main/posts/eso-vs-csi-driver-eks.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>aws</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>Kubernetes Traffic Stack: From NLB vs ALB to a Cilium-First Setup</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Mon, 12 Oct 2026 10:26:01 +0000</pubDate>
      <link>https://dev.to/nazmur96/kubernetes-traffic-stack-from-nlb-vs-alb-to-a-cilium-first-setup-24p0</link>
      <guid>https://dev.to/nazmur96/kubernetes-traffic-stack-from-nlb-vs-alb-to-a-cilium-first-setup-24p0</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyzgvth6vb08ql06w4mla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyzgvth6vb08ql06w4mla.png" alt="An NLB forwards connections, an ALB routes requests, and a Cilium-first table of which tool to use at each layer" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short version:&lt;/strong&gt; an NLB only forwards connections, so a gateway inside the cluster makes the routing decisions; an ALB routes requests itself. The best-of-both-worlds setup uses Cilium at every layer by default and adds another tool only for a named need.&lt;/p&gt;

&lt;p&gt;This builds up in four parts: (1) NLB vs ALB, (2) a five-tool combo, (3) Cilium everywhere, (4) the recommended stack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1: How traffic gets in, NLB vs ALB
&lt;/h2&gt;

&lt;p&gt;When you run your own gateway (for example Cilium Gateway) in the cluster, it usually sits behind an NLB. The NLB only passes traffic through, so your gateway makes the routing decisions. An ALB would do the routing itself.&lt;/p&gt;

&lt;p&gt;Every request has two layers of information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The envelope (Layer 4):&lt;/strong&gt; source IP, destination IP, port. "Someone at 1.2.3.4 wants to talk on port 443."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The letter inside (Layer 7):&lt;/strong&gt; the actual HTTP request. "GET &lt;code&gt;shop.example.com/api/cart&lt;/code&gt;, with these headers and cookies."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An &lt;strong&gt;NLB&lt;/strong&gt; (Network Load Balancer) only reads the envelope. An &lt;strong&gt;ALB&lt;/strong&gt; (Application Load Balancer) opens the envelope and reads the letter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NLB + Cilium Gateway.&lt;/strong&gt; The NLB sees "TCP connection on port 443" and forwards it to the gateway pods. It never reads the HTTP part, and the traffic is usually still encrypted as it passes. The gateway then decrypts TLS (it holds the certificate), reads hostname, path and headers, applies your &lt;code&gt;HTTPRoute&lt;/code&gt; rules, and sends the request to the right Service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ALB on its own.&lt;/strong&gt; The ALB decrypts TLS, reads the HTTP request and applies routing rules itself. The AWS Load Balancer Controller turns your Kubernetes Ingress or Gateway objects into ALB rules. Traffic goes straight to the pods: the ALB &lt;em&gt;is&lt;/em&gt; the gateway.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NLB + in-cluster gateway
  User ──► NLB ─────────────────► [ Cilium Gateway ] ──► Services
           reads IP + port only     decrypts TLS, reads     cart · catalog · ui
           forwards the connection  host, path, headers;
                                    DECIDES

ALB alone
  User ──► [ ALB ] ─────────────────────────────────────► Services
           decrypts TLS, reads host, path, headers; DECIDES   cart · catalog · ui
           managed by AWS, rules from your Ingress/Gateway YAML

[ brackets ] = where the routing decision is made
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With an NLB, the routing decision happens inside your cluster; with an ALB, it happens in AWS before traffic reaches the cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why pick one over the other
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;NLB + your own gateway&lt;/th&gt;
&lt;th&gt;ALB alone&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Who routes&lt;/td&gt;
&lt;td&gt;Gateway pods in the cluster&lt;/td&gt;
&lt;td&gt;The ALB (managed by AWS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where rules live&lt;/td&gt;
&lt;td&gt;Kubernetes YAML only&lt;/td&gt;
&lt;td&gt;Kubernetes YAML turned into AWS rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Portability&lt;/td&gt;
&lt;td&gt;Same setup on AWS, GCP, bare metal&lt;/td&gt;
&lt;td&gt;AWS only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Features&lt;/td&gt;
&lt;td&gt;Everything the gateway can do: retries, traffic splitting, header rewrites, mTLS&lt;/td&gt;
&lt;td&gt;More limited routing, but native ACM certificates, WAF and Cognito login&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost of running&lt;/td&gt;
&lt;td&gt;You run and scale the gateway; if it breaks, nothing gets in&lt;/td&gt;
&lt;td&gt;Nothing extra to run in the cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Caveats about "only passes traffic through"
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;An NLB &lt;strong&gt;can&lt;/strong&gt; terminate TLS if you attach a certificate. It still won't route by host or path.&lt;/li&gt;
&lt;li&gt;An NLB still does real work: health checks, spreading load, preserving the client's source IP.&lt;/li&gt;
&lt;li&gt;You &lt;em&gt;can&lt;/em&gt; put an ALB in front of an in-cluster gateway, but that's two Layer 7 routers in a row. Only worth it if you want the ALB for WAF and the gateway for everything else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In one line:&lt;/strong&gt; an NLB forwards connections, an ALB routes requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: The five-tool combo, is it more versatile?
&lt;/h2&gt;

&lt;p&gt;A stack that comes up a lot:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Front door&lt;/td&gt;
&lt;td&gt;HAProxy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing rules&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who makes the rules real&lt;/td&gt;
&lt;td&gt;Traefik&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service&lt;/td&gt;
&lt;td&gt;Istio&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Is it more versatile? Partly. The core idea is right: HAProxy can replace the NLB as a "dumb pipe" front door, and the routing rules still live in the cluster. That's a real, common pattern, especially on bare metal and in homelabs.&lt;/p&gt;

&lt;p&gt;But this exact combo isn't really &lt;em&gt;more versatile&lt;/em&gt;. It's &lt;em&gt;more pieces&lt;/em&gt;. Several of these tools can do each other's jobs, so you'd be running overlapping software.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's good about it
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HAProxy as the front door works.&lt;/strong&gt; Run it in &lt;strong&gt;TCP mode&lt;/strong&gt; (Layer 4), and it behaves like an NLB: it forwards connections on 80/443 to Traefik without reading the HTTP. Turn on the &lt;strong&gt;PROXY protocol&lt;/strong&gt; on both HAProxy and Traefik, or every request will look like it came from HAProxy's IP instead of the real user.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing stays in the cluster.&lt;/strong&gt; Your &lt;code&gt;Gateway&lt;/code&gt; and &lt;code&gt;HTTPRoute&lt;/code&gt; YAML is the source of truth, and Traefik turns it into real routing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway API at both levels.&lt;/strong&gt; Traefik uses it for traffic coming &lt;em&gt;into&lt;/em&gt; the cluster, and Istio can use the same &lt;code&gt;HTTPRoute&lt;/code&gt; objects for traffic &lt;em&gt;between&lt;/em&gt; services. That gives you one rule language for both.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Where it overlaps
&lt;/h3&gt;

&lt;p&gt;Traefik is the most "extra" piece: both Cilium and Istio can implement Gateway API themselves, so it adds one more proxy to run, upgrade, and debug.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;Your pick&lt;/th&gt;
&lt;th&gt;Who else in the stack can already do it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Front door / external IP&lt;/td&gt;
&lt;td&gt;HAProxy&lt;/td&gt;
&lt;td&gt;Cilium (LB-IPAM + BGP or L2 announcements)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gateway API implementation&lt;/td&gt;
&lt;td&gt;Traefik&lt;/td&gt;
&lt;td&gt;Cilium, Istio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service (mTLS, retries)&lt;/td&gt;
&lt;td&gt;Istio&lt;/td&gt;
&lt;td&gt;Cilium (partly, via its mutual auth and Envoy features)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Things that will bite you
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Traefik has to join the Istio mesh.&lt;/strong&gt; If Istio enforces strict mTLS, Traefik can't talk to your services unless it's in the mesh too. That means a sidecar in the Traefik pod, or enrolling its namespace in Istio ambient mode.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cilium and Istio need tuning to coexist.&lt;/strong&gt; It works, but Cilium's socket-level load balancing can bypass Istio's sidecars unless you configure it for that. It's a known setting in Cilium's Istio docs, but easy to miss.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Only one Gateway API controller should own each Gateway.&lt;/strong&gt; If Cilium's Gateway API support is also switched on, keep it off or make sure the GatewayClass names are clearly separate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HAProxy itself needs high availability.&lt;/strong&gt; One HAProxy box is a single point of failure. On bare metal, run two with keepalived and a floating IP. On AWS, floating IPs don't work the same way, which is exactly the problem a managed NLB solves for you, so replacing the NLB there usually isn't worth it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Leaner versions that keep the same idea
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Stack&lt;/th&gt;
&lt;th&gt;When to pick it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cilium-heavy&lt;/td&gt;
&lt;td&gt;Cilium for networking, external IPs (BGP or L2) and Gateway API; HAProxy in front only if you have a separate edge box&lt;/td&gt;
&lt;td&gt;Fewest moving parts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Istio-heavy&lt;/td&gt;
&lt;td&gt;Cilium for networking, HAProxy at the edge, Istio for both ingress gateway and mesh; drop Traefik&lt;/td&gt;
&lt;td&gt;One proxy family, Gateway API rules everywhere&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No mesh&lt;/td&gt;
&lt;td&gt;Cilium, HAProxy, Traefik&lt;/td&gt;
&lt;td&gt;You don't need mTLS or traffic policies between services yet&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Bottom line on the combo
&lt;/h3&gt;

&lt;p&gt;The architecture idea is solid: a dumb front door, with smart routing inside the cluster. The specific tool list just has redundancy.&lt;/p&gt;

&lt;p&gt;If your goal is &lt;em&gt;learning&lt;/em&gt; each tool, the full combo is a fine lab, since you'll learn a lot from making them cooperate. If your goal is something you'd &lt;em&gt;run&lt;/em&gt;, pick one of the leaner versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3: What if Cilium did every layer?
&lt;/h2&gt;

&lt;p&gt;Mostly a good idea. Cilium for networking, external IPs, Gateway API, network policy and observability (Hubble) means one tool, one Helm chart, one upgrade and one set of docs instead of four or five. It's very well proven: the 2025 annual Cilium report found over 60% of surveyed production deployments on Cilium, and more than 75% on Cilium-based data planes once managed services like Azure CNI powered by Cilium and GKE Dataplane V2 are counted (&lt;a href="https://www.infoq.com/news/2026/02/cilium-119" rel="noopener noreferrer"&gt;InfoQ&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Three corrections matter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cloud independence comes mainly from Gateway API, not from Cilium.&lt;/strong&gt; &lt;code&gt;Gateway&lt;/code&gt; and &lt;code&gt;HTTPRoute&lt;/code&gt; YAML is a Kubernetes standard, so it would work on Traefik or Istio too. The front door (the public IP) is never portable:

&lt;ul&gt;
&lt;li&gt;Bare metal / homelab: Cilium announces the IP itself (BGP or L2). No extra tool.&lt;/li&gt;
&lt;li&gt;AWS: Cilium can't create a public IP. Its Gateway creates a &lt;code&gt;LoadBalancer&lt;/code&gt; Service and AWS still puts an NLB in front.&lt;/li&gt;
&lt;li&gt;The CNI install itself also has cloud-specific settings, such as ENI mode on EKS.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Does everything" isn't "best at everything."&lt;/strong&gt; Cilium is excellent at networking, policy and ingress. Its service mesh is thinner than Istio's: in the 1.19 release, maintainers disabled the existing mutual authentication feature by default and pointed mTLS users toward a ztunnel-based path (&lt;a href="https://www.infoq.com/news/2026/02/cilium-119" rel="noopener noreferrer"&gt;InfoQ&lt;/a&gt;). For strict service identity or advanced traffic shifting, Istio (ambient mode) is still stronger, and it runs alongside Cilium.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One tool means one blast radius.&lt;/strong&gt; If the Cilium agent misbehaves or an upgrade goes wrong, pod networking, ingress, policy and mesh fail &lt;em&gt;together&lt;/em&gt;. With separate tools, a broken Traefik upgrade only breaks ingress. Manage it with careful upgrades, a staging cluster, and knowing Hubble well.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; "Cilium for everything except the mesh" is the best default today. Add Istio ambient only when a concrete need appears.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 4: Best of both worlds, Cilium first
&lt;/h2&gt;

&lt;p&gt;The rule: &lt;strong&gt;Cilium is the default at every layer; another tool comes in only when a specific requirement shows up that Cilium doesn't handle well.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;Bring in something else when…&lt;/th&gt;
&lt;th&gt;…and use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking + kube-proxy replacement&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;basically never&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Network policy (L3/L4, L7 HTTP/DNS rules)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traffic observability&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium Hubble&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;you need app metrics/traces, not just traffic&lt;/td&gt;
&lt;td&gt;Prometheus + Grafana, OpenTelemetry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node-to-node encryption&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium WireGuard&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multi-cluster networking&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium Cluster Mesh&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External IP (bare metal / homelab)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium LB-IPAM + BGP or L2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;a separate edge box outside the cluster, or several clusters behind one IP&lt;/td&gt;
&lt;td&gt;HAProxy (TCP mode) + keepalived&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External IP (cloud)&lt;/td&gt;
&lt;td&gt;cloud NLB (AWS Load Balancer Controller)&lt;/td&gt;
&lt;td&gt;you need WAF or AWS-native login at the edge&lt;/td&gt;
&lt;td&gt;ALB, or a WAF in front of the NLB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingress routing (Gateway API)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Cilium Gateway&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;you need rate limiting, OIDC/JWT login, request auth, rich middleware&lt;/td&gt;
&lt;td&gt;Envoy Gateway or Traefik&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service mTLS + traffic shifting&lt;/td&gt;
&lt;td&gt;nothing at first&lt;/td&gt;
&lt;td&gt;strict per-service identity, % or header canaries between services, per-service retries/timeouts&lt;/td&gt;
&lt;td&gt;Istio &lt;strong&gt;ambient&lt;/strong&gt; mode&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every setup also needs, whatever the networking stack: &lt;strong&gt;cert-manager&lt;/strong&gt; for TLS certificates (Let's Encrypt) and &lt;strong&gt;ExternalDNS&lt;/strong&gt; to create DNS records from your Gateways.&lt;/p&gt;

&lt;h3&gt;
  
  
  The two most likely swaps, and why
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cilium Gateway → Envoy Gateway or Traefik.&lt;/strong&gt; Cilium's gateway handles standard Gateway API routing well: hosts, paths, headers, gRPC, TLS. The extras that live &lt;em&gt;on top of&lt;/em&gt; the standard, like "log users in with Keycloak before they reach the app" or "100 requests/minute per IP", are where dedicated gateways are much stronger.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adding Istio ambient.&lt;/strong&gt; Cilium already encrypts traffic between nodes. Istio adds &lt;em&gt;identity&lt;/em&gt; ("only the cart service may call the payment service, proven by certificate") and fine-grained traffic control between services. Ambient mode coexists cleanly with Cilium and doesn't put a sidecar in every pod.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Everything else stays Cilium: a low tool count, and each extra tool arrives with a named reason attached.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it looks like in practice
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Homelab / bare metal
  [Cilium LB-IPAM]      ──► [Cilium Gateway]     ──► Services
  BGP or L2 from router     Gateway API routing      pods on Cilium networking

AWS (EKS)
  AWS NLB               ──► [Cilium Gateway]     ──► Services
  via AWS LB Controller     Gateway API routing      pods on Cilium networking

Grown-up: real requirements showed up
  NLB or HAProxy        ──► Envoy Gateway        ──► Services
  plain TCP pass-through    Gateway API routing      pods on Cilium networking
  (HAProxy only with        + OIDC login,            + Istio ambient (mTLS)
   an edge box)               rate limits

  ┌──────────────────────────────────────────────────────────────────────┐
  │ [Cilium] underneath all three: pod networking, network policy,       │
  │          Hubble, WireGuard                                           │
  └──────────────────────────────────────────────────────────────────────┘
  Also in all three: cert-manager (TLS certificates) and ExternalDNS (DNS records)

[ brackets ] = Cilium
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The homelab and AWS setups differ only at the front door; the grown-up version swaps in Envoy Gateway and adds Istio ambient once a named need appears, while Cilium stays underneath.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: things only an NLB can do
&lt;/h2&gt;

&lt;p&gt;The flip side of "an ALB routes requests" is that some jobs need the plain connection-forwarder:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Only with an NLB&lt;/th&gt;
&lt;th&gt;Why an ALB can't&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Static IPs&lt;/strong&gt; (one fixed or Elastic IP per AZ)&lt;/td&gt;
&lt;td&gt;An ALB's IPs change. You'd need an NLB or Global Accelerator in front of it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Non-HTTP traffic&lt;/strong&gt; (raw TCP, UDP: databases, MQTT, game servers, DNS)&lt;/td&gt;
&lt;td&gt;An ALB only understands HTTP and HTTPS.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;PrivateLink&lt;/strong&gt; (sharing your service privately with another VPC or account)&lt;/td&gt;
&lt;td&gt;An endpoint service has to sit on an NLB (or a Gateway Load Balancer).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;TLS passthrough&lt;/strong&gt; (the encrypted connection goes untouched to the pod)&lt;/td&gt;
&lt;td&gt;An ALB always decrypts.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.infoq.com/news/2026/02/cilium-119" rel="noopener noreferrer"&gt;Cilium at Ten Years: Stronger Encryption, Safer Policies, and Clearer Visibility for Large Clusters (InfoQ, Feb 2026)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-learning-journal/blob/main/networking/kubernetes-traffic-stack-cilium-first.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-learning-journal/blob/main/networking/kubernetes-traffic-stack-cilium-first.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>aws</category>
      <category>networking</category>
      <category>devops</category>
    </item>
    <item>
      <title>Why Can't My App Connect to My Database?</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Fri, 09 Oct 2026 11:39:55 +0000</pubDate>
      <link>https://dev.to/nazmur96/why-cant-my-app-connect-to-my-database-2i00</link>
      <guid>https://dev.to/nazmur96/why-cant-my-app-connect-to-my-database-2i00</guid>
      <description>&lt;p&gt;&lt;em&gt;A beginner's guide to the 4 checks on AWS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frpgb5fl7fqw85x1g6108.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frpgb5fl7fqw85x1g6108.png" alt="Can't connect to your database? 4 gates in order: security group, PostgreSQL listening, pg_hba.conf, username and password, each with the error you see when it fails" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The big idea first
&lt;/h2&gt;

&lt;p&gt;When your app connects to a database, the connection has to pass &lt;strong&gt;4 checks, one after another&lt;/strong&gt;. If any one fails, the connection fails.&lt;/p&gt;

&lt;p&gt;Think of visiting a friend in a secure apartment building:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Building analogy&lt;/th&gt;
&lt;th&gt;On AWS + PostgreSQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;The front gate lets you in&lt;/td&gt;
&lt;td&gt;Security group allows the traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Someone is home to answer the door&lt;/td&gt;
&lt;td&gt;PostgreSQL is listening for connections&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Your name is on the visitor list&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pg_hba.conf&lt;/code&gt; allows your app&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;You know the secret password&lt;/td&gt;
&lt;td&gt;Username and password are correct&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep this picture in mind. Everything below explains one of these steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1: Security groups (gate 1)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a security group?
&lt;/h3&gt;

&lt;p&gt;A security group is a &lt;strong&gt;firewall for your AWS resources&lt;/strong&gt;, like an EC2 instance (a virtual server). It decides which network traffic is allowed in.&lt;/p&gt;

&lt;p&gt;Two rules to remember:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Everything coming in is blocked by default.&lt;/strong&gt; You add rules to allow what you need.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replies are automatic.&lt;/strong&gt; If a request is allowed in, the response is allowed back out. You don't need a separate rule for that.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What's in a rule?
&lt;/h3&gt;

&lt;p&gt;Every inbound rule has 3 parts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Question it answers&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Protocol&lt;/td&gt;
&lt;td&gt;What kind of traffic?&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Port&lt;/td&gt;
&lt;td&gt;Which "door" on the server?&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;Who is allowed to connect?&lt;/td&gt;
&lt;td&gt;Your IP address&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The "Type" dropdown is just a shortcut
&lt;/h3&gt;

&lt;p&gt;When you pick a Type like SSH or HTTP, AWS fills in the protocol and port for you:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Used for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SSH&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;Logging in to a Linux server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;td&gt;Normal websites&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTPS&lt;/td&gt;
&lt;td&gt;443&lt;/td&gt;
&lt;td&gt;Secure websites&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom TCP&lt;/td&gt;
&lt;td&gt;You choose&lt;/td&gt;
&lt;td&gt;Anything else&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;AWS does &lt;strong&gt;not&lt;/strong&gt; check what's actually running on that port. Picking "SSH" just means "open port 22." If your SSH runs on port 2222, pick Custom TCP and type 2222.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: Who can connect? (the source)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What does &lt;code&gt;0.0.0.0/0&lt;/code&gt; mean?
&lt;/h3&gt;

&lt;p&gt;It means &lt;strong&gt;anyone on the internet&lt;/strong&gt; (any IPv4 address).&lt;/p&gt;

&lt;h3&gt;
  
  
  Does that mean anyone can log in?
&lt;/h3&gt;

&lt;p&gt;No. It means anyone can &lt;strong&gt;reach the door and try the lock&lt;/strong&gt;. They still need the right key, such as your SSH private key.&lt;/p&gt;

&lt;p&gt;But it's still risky:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bots&lt;/strong&gt; scan the internet all day and will try to break in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bugs&lt;/strong&gt; in software sometimes let attackers in without a key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Future mistakes&lt;/strong&gt;, like a weak password, become much more dangerous.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Safer options for SSH
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use "My IP" as the source.&lt;/strong&gt; AWS fills in your IP with &lt;code&gt;/32&lt;/code&gt; at the end, which means "only this one address." If your home IP changes, you'll need to update the rule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use AWS Session Manager.&lt;/strong&gt; It gives you a terminal on your server without opening port 22 at all.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Part 3: Ports
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What happens when you open a port?
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nothing is running on that port&lt;/td&gt;
&lt;td&gt;Connection fails, nothing to talk to&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An app is running on that port&lt;/td&gt;
&lt;td&gt;Traffic can reach that app&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Why big port ranges are dangerous
&lt;/h3&gt;

&lt;p&gt;Opening &lt;code&gt;3000-9000&lt;/code&gt; opens &lt;strong&gt;6,001 ports&lt;/strong&gt;, not just the one you need.&lt;/p&gt;

&lt;p&gt;Today, maybe only your web app is running. Next week you install PostgreSQL on port 5432, and it's suddenly exposed to the internet without you changing anything in AWS.&lt;/p&gt;

&lt;p&gt;Common ports to know:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Usually used by&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3000&lt;/td&gt;
&lt;td&gt;Dev web apps, Grafana&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5432&lt;/td&gt;
&lt;td&gt;PostgreSQL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6379&lt;/td&gt;
&lt;td&gt;Redis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8080&lt;/td&gt;
&lt;td&gt;Jenkins, Tomcat&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Rule of thumb:&lt;/strong&gt; open only the ports you need, only to the sources that need them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Part 4: Connecting an app server to a database server
&lt;/h2&gt;

&lt;p&gt;You have two servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;App server:&lt;/strong&gt; runs your website&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database server:&lt;/strong&gt; runs PostgreSQL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You want the app to reach the database and block everyone else.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option A: allow the app server's IP (works, but annoying)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Port: 5432    Source: 10.0.1.25/32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you replace the app server, it gets a new IP, and you have to update the rule.&lt;/li&gt;
&lt;li&gt;If you add 10 app servers, you need 10 rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Option B: allow a security group (better)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a security group called &lt;code&gt;app-sg&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Attach it to your app server.&lt;/li&gt;
&lt;li&gt;On the database's security group, allow:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Port: 5432    Source: app-sg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means: "Allow any server wearing the &lt;code&gt;app-sg&lt;/code&gt; badge."&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Replace a server?&lt;/strong&gt; Give the new one &lt;code&gt;app-sg&lt;/code&gt;. No rule changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add 10 servers?&lt;/strong&gt; Give them all &lt;code&gt;app-sg&lt;/code&gt;. Still one rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;One catch:&lt;/strong&gt; this only works when the app connects to the database's &lt;strong&gt;private IP&lt;/strong&gt; (inside the same network). If it uses the database's public IP, the badge isn't recognized and the connection will time out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Part 5: The 4 gates in detail
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Gate 1: Security group
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is traffic allowed to reach port 5432?&lt;/p&gt;

&lt;p&gt;The database's security group needs a rule allowing TCP 5432 from &lt;code&gt;app-sg&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gate 2: Is PostgreSQL listening?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is PostgreSQL accepting connections from other machines?&lt;/p&gt;

&lt;p&gt;By default, PostgreSQL usually listens only to itself (&lt;code&gt;localhost&lt;/code&gt;). Other servers can't reach it.&lt;/p&gt;

&lt;p&gt;To fix it, edit &lt;code&gt;postgresql.conf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;listen_addresses&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'*'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means "listen on all network connections." It does &lt;strong&gt;not&lt;/strong&gt; mean anyone can log in. Gates 3 and 4 still protect you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 You must &lt;strong&gt;restart&lt;/strong&gt; PostgreSQL after changing this. A reload isn't enough.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Gate 3: PostgreSQL's visitor list (&lt;code&gt;pg_hba.conf&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Is this app allowed to connect to this database as this user?&lt;/p&gt;

&lt;p&gt;PostgreSQL has its own list of who's allowed, separate from AWS. You need a line in &lt;code&gt;pg_hba.conf&lt;/code&gt; allowing your app server to connect to &lt;code&gt;mydb&lt;/code&gt; as user &lt;code&gt;app&lt;/code&gt;. For example, to allow the app server's whole subnet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# TYPE  DATABASE  USER  ADDRESS        METHOD
host    mydb      app   10.0.1.0/24    scram-sha-256
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 After editing, &lt;strong&gt;reload&lt;/strong&gt; PostgreSQL.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Gate 4: Username and password
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; Are the login details correct?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host:     10.0.2.40
Port:     5432
Database: mydb
Username: app
Password: (the correct one)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if gates 1–3 are perfect, a wrong password means no entry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 6: Reading error messages
&lt;/h2&gt;

&lt;p&gt;The error message tells you which gate failed. &lt;strong&gt;This is the most useful skill in this guide.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Error message&lt;/th&gt;
&lt;th&gt;What it feels like&lt;/th&gt;
&lt;th&gt;Which gate&lt;/th&gt;
&lt;th&gt;What to check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Connection timed out&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Waits a long time, then gives up&lt;/td&gt;
&lt;td&gt;Gate 1 (network)&lt;/td&gt;
&lt;td&gt;Security group rules, network settings, server firewall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Connection refused&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fails instantly&lt;/td&gt;
&lt;td&gt;Gate 2&lt;/td&gt;
&lt;td&gt;Is PostgreSQL running? Is it listening on the network?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;no pg_hba.conf entry for host...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;PostgreSQL answered but said no&lt;/td&gt;
&lt;td&gt;Gate 3&lt;/td&gt;
&lt;td&gt;Your &lt;code&gt;pg_hba.conf&lt;/code&gt; rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;password authentication failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Got all the way to login&lt;/td&gt;
&lt;td&gt;Gate 4&lt;/td&gt;
&lt;td&gt;Username, password, does the user exist?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Good news hidden in errors:&lt;/strong&gt; the further down the table your error is, the more is already working. A password error means gates 1–3 are fine.&lt;/p&gt;

&lt;p&gt;💡 "Password authentication failed" also appears if the user doesn't exist at all. PostgreSQL does this on purpose so attackers can't guess usernames.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Part 7: Two commands to test
&lt;/h2&gt;

&lt;p&gt;Run these from the app server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test 1: Can I reach the port? (gates 1–2)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nc &lt;span class="nt"&gt;-zv&lt;/span&gt; 10.0.2.40 5432
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Success&lt;/strong&gt; means the network path works and something is listening.&lt;/li&gt;
&lt;li&gt;It does &lt;strong&gt;not&lt;/strong&gt; test the password or &lt;code&gt;pg_hba.conf&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Test 2: Can I log in? (all 4 gates)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;psql &lt;span class="nt"&gt;-h&lt;/span&gt; 10.0.2.40 &lt;span class="nt"&gt;-U&lt;/span&gt; app &lt;span class="nt"&gt;-d&lt;/span&gt; mydb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-h 10.0.2.40&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Database server's address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-U app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Log in as user &lt;code&gt;app&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-d mydb&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Connect to database &lt;code&gt;mydb&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Success&lt;/strong&gt; means all 4 gates pass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failure&lt;/strong&gt; means you read the error and match it to the table in Part 6.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Part 8: Troubleshooting checklist
&lt;/h2&gt;

&lt;p&gt;When the app can't connect, don't change random settings. Go in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Security group:&lt;/strong&gt; Does the DB allow port 5432 from &lt;code&gt;app-sg&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network:&lt;/strong&gt; Can the app server reach the DB's private IP? (&lt;code&gt;nc -zv&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL running:&lt;/strong&gt; Is it running and listening on the network?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visitor list:&lt;/strong&gt; Does &lt;code&gt;pg_hba.conf&lt;/code&gt; allow this app, database, and user?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Login:&lt;/strong&gt; Are the username and password correct? (&lt;code&gt;psql&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Quick recap
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;One-line meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Security group&lt;/td&gt;
&lt;td&gt;AWS firewall that controls incoming traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Type dropdown&lt;/td&gt;
&lt;td&gt;Shortcut that fills in the port&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0.0.0.0/0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Anyone on the internet. Avoid for SSH and databases&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/32&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exactly one IP address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Port range&lt;/td&gt;
&lt;td&gt;Opens every port in the range. Keep it narrow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SG as source&lt;/td&gt;
&lt;td&gt;"Allow anything with this badge"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;listen_addresses&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Makes PostgreSQL listen to the network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pg_hba.conf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;PostgreSQL's own visitor list&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The one thing to remember:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Security group → PostgreSQL listening → &lt;code&gt;pg_hba.conf&lt;/code&gt; → Password&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are 4 separate locks. Fixing one doesn't fix the others. The error message tells you which lock is stuck.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good to know later (skip for now)
&lt;/h2&gt;

&lt;p&gt;Once you're comfortable with the basics, look into these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network ACLs&lt;/strong&gt;, a second, stricter firewall layer on subnets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outbound rules&lt;/strong&gt; on the app's security group.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IPv6 (&lt;code&gt;::/0&lt;/code&gt;)&lt;/strong&gt;, the IPv6 equivalent of &lt;code&gt;0.0.0.0/0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS RDS&lt;/strong&gt;, a managed database where gates 2 and 3 work a bit differently.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-learning-journal/blob/main/networking/why-cant-my-app-connect-to-my-database.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-learning-journal/blob/main/networking/why-cant-my-app-connect-to-my-database.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>postgres</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>How Code Goes from Your Laptop to the User</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Thu, 08 Oct 2026 14:15:27 +0000</pubDate>
      <link>https://dev.to/nazmur96/how-code-goes-from-your-laptop-to-the-user-3m1d</link>
      <guid>https://dev.to/nazmur96/how-code-goes-from-your-laptop-to-the-user-3m1d</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flaewnwbvxfqfj7yjflpv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flaewnwbvxfqfj7yjflpv.png" alt="Every language, same 4 jobs: entry point, dependencies, build tool and final output for Go, Rust, Java, C#, Python and JavaScript" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The big idea
&lt;/h2&gt;

&lt;p&gt;Every programming language solves the same four problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Where does the program start?&lt;/strong&gt; → the &lt;em&gt;Entry Point&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do I get other people's code (libraries)?&lt;/strong&gt; → the &lt;em&gt;Dependency Manager&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do I turn my code into something ready to ship?&lt;/strong&gt; → the &lt;em&gt;Build Tool&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What do I actually give to the user or server?&lt;/strong&gt; → the &lt;em&gt;Final Output&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simple analogy is a recipe:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Recipe analogy&lt;/th&gt;
&lt;th&gt;Software&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Entry Point&lt;/td&gt;
&lt;td&gt;"Step 1" of the recipe&lt;/td&gt;
&lt;td&gt;The first file that runs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependency Manager&lt;/td&gt;
&lt;td&gt;Going shopping for ingredients&lt;/td&gt;
&lt;td&gt;Downloading libraries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build Tool&lt;/td&gt;
&lt;td&gt;Cooking&lt;/td&gt;
&lt;td&gt;Compiling and packaging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Final Output&lt;/td&gt;
&lt;td&gt;The finished dish&lt;/td&gt;
&lt;td&gt;The file you deploy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The tools have different names in each language, but the job is the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two families of languages
&lt;/h2&gt;

&lt;p&gt;Most of the differences come from one question: &lt;strong&gt;does the final output need a runtime installed to work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Family A: compiled to a single binary (Go, Rust).&lt;/strong&gt;&lt;br&gt;
The output is one file that runs by itself. You copy it to a server and run it. Nothing else needs to be installed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Family B: needs a runtime (Java, C#, Python, JavaScript).&lt;/strong&gt;&lt;br&gt;
The output only works if a "helper program" is installed on the machine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Java needs the &lt;strong&gt;JVM&lt;/strong&gt; (Java Virtual Machine)&lt;/li&gt;
&lt;li&gt;C# needs the &lt;strong&gt;.NET runtime&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Python needs the &lt;strong&gt;Python interpreter&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;JavaScript needs a &lt;strong&gt;browser&lt;/strong&gt; (or Node.js on a server)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this in mind, the rest is easier to remember.&lt;/p&gt;

&lt;h2&gt;
  
  
  Language by language
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. JavaScript (frontend)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry Point:&lt;/strong&gt; &lt;code&gt;index.html&lt;/code&gt; loads &lt;code&gt;index.js&lt;/code&gt; (or &lt;code&gt;main.js&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; npm, yarn, or pnpm, listed in &lt;code&gt;package.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tool:&lt;/strong&gt; Vite or Webpack. These combine many files into a few, make them smaller, and make them work in all browsers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt; A folder (usually &lt;code&gt;dist/&lt;/code&gt;) with &lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.css&lt;/code&gt;, and image files. A web server or CDN serves these to the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Java
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry Point:&lt;/strong&gt; A class with a &lt;code&gt;public static void main()&lt;/code&gt; method, such as &lt;code&gt;Main.java&lt;/code&gt;, or &lt;code&gt;Application.java&lt;/code&gt; in Spring Boot&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; Maven (&lt;code&gt;pom.xml&lt;/code&gt;) or Gradle (&lt;code&gt;build.gradle&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tool:&lt;/strong&gt; The same Maven or Gradle. They both download libraries and build.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.jar&lt;/code&gt;: runs directly with &lt;code&gt;java -jar app.jar&lt;/code&gt; (the modern way)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.war&lt;/code&gt;: deployed into a server like Tomcat (the older way)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Python
&lt;/h3&gt;

&lt;p&gt;Python is interpreted. It reads and runs your &lt;code&gt;.py&lt;/code&gt; files directly, so normally there is no real "build" step.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry Point:&lt;/strong&gt; &lt;code&gt;main.py&lt;/code&gt; (or whichever script you run first)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; pip with &lt;code&gt;requirements.txt&lt;/code&gt;, or newer tools like Poetry or uv with &lt;code&gt;pyproject.toml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build/Packaging Tool:&lt;/strong&gt; Only needed in special cases:

&lt;ul&gt;
&lt;li&gt;setuptools or Poetry, to publish a library for others&lt;/li&gt;
&lt;li&gt;PyInstaller, to make a standalone program for people without Python&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt; Usually just your source code plus its dependencies. Optionally a package on PyPI (a &lt;code&gt;.whl&lt;/code&gt; file) or a &lt;code&gt;.exe&lt;/code&gt; from PyInstaller.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Go
&lt;/h3&gt;

&lt;p&gt;Go was built by Google to compile fast and to produce one self-contained file. Everything you need comes with Go itself.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry Point:&lt;/strong&gt; &lt;code&gt;main.go&lt;/code&gt;, specifically the &lt;code&gt;main()&lt;/code&gt; function inside &lt;code&gt;package main&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; Go Modules (&lt;code&gt;go.mod&lt;/code&gt; and &lt;code&gt;go.sum&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tool:&lt;/strong&gt; &lt;code&gt;go build&lt;/code&gt;, which is built in&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt; One binary file that includes your code and all libraries. No runtime needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Rust
&lt;/h3&gt;

&lt;p&gt;Rust focuses on speed and safety. One tool, Cargo, handles almost everything.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry Point:&lt;/strong&gt; &lt;code&gt;src/main.rs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; Cargo. Libraries are called "crates" and are listed in &lt;code&gt;Cargo.toml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tool:&lt;/strong&gt; &lt;code&gt;cargo build&lt;/code&gt;, which calls the &lt;code&gt;rustc&lt;/code&gt; compiler for you&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt; One fast binary file, or a &lt;code&gt;.wasm&lt;/code&gt; (WebAssembly) file that runs in browsers&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. C# / .NET
&lt;/h3&gt;

&lt;p&gt;Modern C# works much like Java: code is compiled for a runtime, not directly for the machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry Point:&lt;/strong&gt; &lt;code&gt;Program.cs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependencies:&lt;/strong&gt; NuGet, listed in the &lt;code&gt;.csproj&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build Tool:&lt;/strong&gt; &lt;code&gt;dotnet build&lt;/code&gt; (which uses MSBuild behind the scenes)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Output:&lt;/strong&gt; A &lt;code&gt;.dll&lt;/code&gt; file that runs on the .NET runtime, or a self-contained executable that bundles the runtime inside&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Entry Point&lt;/th&gt;
&lt;th&gt;Dependency Manager&lt;/th&gt;
&lt;th&gt;Build Tool&lt;/th&gt;
&lt;th&gt;Final Output&lt;/th&gt;
&lt;th&gt;Needs runtime?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;JavaScript&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;index.html&lt;/code&gt; / &lt;code&gt;index.js&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;npm / yarn&lt;/td&gt;
&lt;td&gt;Vite / Webpack&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;dist/&lt;/code&gt; folder (JS, CSS, assets)&lt;/td&gt;
&lt;td&gt;Yes (browser)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Main.java&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Maven / Gradle&lt;/td&gt;
&lt;td&gt;Maven / Gradle&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.jar&lt;/code&gt; / &lt;code&gt;.war&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Yes (JVM)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;&lt;code&gt;main.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;pip / Poetry / uv&lt;/td&gt;
&lt;td&gt;Usually none (PyInstaller optional)&lt;/td&gt;
&lt;td&gt;Source code, &lt;code&gt;.whl&lt;/code&gt;, or &lt;code&gt;.exe&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Yes (Python)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;&lt;code&gt;main.go&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Go Modules&lt;/td&gt;
&lt;td&gt;&lt;code&gt;go build&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Single binary&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;&lt;code&gt;main.rs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cargo&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cargo build&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Single binary / &lt;code&gt;.wasm&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C#&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Program.cs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;NuGet&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dotnet build&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.dll&lt;/code&gt; / executable&lt;/td&gt;
&lt;td&gt;Usually (.NET)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Two things people often get wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python &lt;code&gt;.pyc&lt;/code&gt; files are not a deployment output.&lt;/strong&gt; Python creates them automatically as a speed cache. You don't ship them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In Java and Rust, one tool does two jobs.&lt;/strong&gt; Maven/Gradle and Cargo both download dependencies &lt;em&gt;and&lt;/em&gt; build. Go is similar with the &lt;code&gt;go&lt;/code&gt; command. Only JavaScript clearly separates the two (npm + Vite).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why this matters for DevOps
&lt;/h2&gt;

&lt;p&gt;This is the knowledge you need when writing Dockerfiles and CI pipelines. The &lt;strong&gt;Final Output&lt;/strong&gt; decides what goes into your container image:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Go / Rust:&lt;/strong&gt; Copy just the binary into a tiny image (&lt;code&gt;scratch&lt;/code&gt; or distroless). The result is very small and secure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Java:&lt;/strong&gt; Build the &lt;code&gt;.jar&lt;/code&gt;, then copy it into an image that has a Java runtime (JRE).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python:&lt;/strong&gt; Use a Python base image, install dependencies, and copy in the source code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript frontend:&lt;/strong&gt; Build the &lt;code&gt;dist/&lt;/code&gt; folder, then serve it with Nginx. Node isn't needed in the final image.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is why &lt;strong&gt;multi-stage Docker builds&lt;/strong&gt; are common: stage 1 has all the build tools, and stage 2 contains only the final output.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-learning-journal/blob/main/foundations/how-code-goes-from-laptop-to-user.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-learning-journal/blob/main/foundations/how-code-goes-from-laptop-to-user.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Kubernetes Networking, Explained Simply</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Thu, 08 Oct 2026 10:47:47 +0000</pubDate>
      <link>https://dev.to/nazmur96/kubernetes-networking-explained-simply-p3o</link>
      <guid>https://dev.to/nazmur96/kubernetes-networking-explained-simply-p3o</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fljwte5fyqzwcbv3nty6x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fljwte5fyqzwcbv3nty6x.png" alt="Kubernetes networking is 5 jobs, not one tool fight: Pod networking, front door, routing rules, rule follower, service mesh" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  0. Two words you need first
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pod:&lt;/strong&gt; a running copy of your app. Pods come and go, and their addresses change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service:&lt;/strong&gt; a stable name and address that always points to the right Pods, even when they change. Other parts of the system talk to the Service, not to Pods directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all the Kubernetes you need for the rest of this.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The big idea: sort tools by job, not by rivalry
&lt;/h2&gt;

&lt;p&gt;When you see a list like ALB, NGINX, Traefik, Cilium, F5, it looks like they're all fighting each other. Most of them aren't. They do different jobs.&lt;/p&gt;

&lt;p&gt;So don't ask "which tool is best?" Ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What job needs doing, and which tool will do it?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. The 5 networking jobs
&lt;/h2&gt;

&lt;p&gt;Think of a Kubernetes cluster like an office building:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;Simple question&lt;/th&gt;
&lt;th&gt;Building analogy&lt;/th&gt;
&lt;th&gt;Common tools&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Pod networking (CNI)&lt;/td&gt;
&lt;td&gt;How does each Pod get an address and talk to others?&lt;/td&gt;
&lt;td&gt;Wiring and room numbers inside the building&lt;/td&gt;
&lt;td&gt;AWS VPC CNI, Cilium, Calico, Flannel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;External load balancer&lt;/td&gt;
&lt;td&gt;Who receives traffic from the internet first?&lt;/td&gt;
&lt;td&gt;The front door&lt;/td&gt;
&lt;td&gt;AWS ALB, AWS NLB, F5, HAProxy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Routing rules (written)&lt;/td&gt;
&lt;td&gt;How do I describe where traffic should go?&lt;/td&gt;
&lt;td&gt;The sign on the wall: "Sales → 2nd floor"&lt;/td&gt;
&lt;td&gt;Ingress (older), Gateway API (newer)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Routing implementation&lt;/td&gt;
&lt;td&gt;Who actually follows those rules?&lt;/td&gt;
&lt;td&gt;The receptionist who reads the sign and sends people the right way&lt;/td&gt;
&lt;td&gt;AWS Load Balancer Controller, NGINX, Traefik, Kong, Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Service-to-service control (mesh)&lt;/td&gt;
&lt;td&gt;How do services inside talk to each other safely and reliably?&lt;/td&gt;
&lt;td&gt;Internal security and hallway rules&lt;/td&gt;
&lt;td&gt;Istio, Linkerd, Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;CNI stands for Container Network Interface. It's just the name for "the plugin that gives Pods their networking."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Job 3 is just rules written down. Gateway API does nothing on its own. It needs a tool from Job 4 to make the rules real.&lt;/p&gt;

&lt;p&gt;You pick one tool per job, and only for the jobs you actually need. A service mesh (Job 5), for example, is optional.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Gateway API instead of Ingress?
&lt;/h3&gt;

&lt;p&gt;Both are ways to write routing rules. The difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ingress&lt;/strong&gt; can only describe simple things, like "this URL goes to that Service." For anything fancier (splitting traffic 90/10, matching on headers), every tool invented its own custom add-ons, so your rules only worked with that one tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gateway API&lt;/strong&gt; builds those features into the standard itself, so your rules work the same way no matter which tool follows them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The popular community ingress-nginx controller was retired in March 2026, which is pushing many teams to switch to Gateway API now.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. One key idea: "L4" vs "L7" front doors
&lt;/h2&gt;

&lt;p&gt;You'll see these terms everywhere. They describe how much a load balancer looks at before passing traffic on.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Mail analogy&lt;/th&gt;
&lt;th&gt;AWS example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;L4&lt;/td&gt;
&lt;td&gt;Passes connections through without looking inside. Fast and simple.&lt;/td&gt;
&lt;td&gt;A mail sorter that only reads the building address&lt;/td&gt;
&lt;td&gt;NLB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;L7&lt;/td&gt;
&lt;td&gt;Opens the request and reads it (the URL, headers, etc.), then decides where to send it. Smarter.&lt;/td&gt;
&lt;td&gt;A mail sorter that also reads "Attention: Sales department"&lt;/td&gt;
&lt;td&gt;ALB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep this in mind. It explains why the projects below pick different front doors.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The example app
&lt;/h2&gt;

&lt;p&gt;We'll build the same small online shop three different ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;frontend   →  the website
api        →  the backend logic
payment    →  handles payments
database   →  stores data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;About the database: it isn't part of the incoming-traffic story. Internet users never reach it directly. Only the api and payment services talk to it. In AWS setups it often lives outside the cluster as a managed service (Amazon RDS). So in the pictures below, it sits at the very end.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Project 1: The "let AWS do it" setup
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mindset:&lt;/strong&gt; "I use Kubernetes, but I want AWS to handle as much networking as possible."&lt;/p&gt;

&lt;p&gt;Very common in AWS-heavy companies.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking&lt;/td&gt;
&lt;td&gt;AWS VPC CNI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Front door&lt;/td&gt;
&lt;td&gt;AWS ALB (L7)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing rules&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who makes the rules real&lt;/td&gt;
&lt;td&gt;AWS Load Balancer Controller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service&lt;/td&gt;
&lt;td&gt;None yet (no mesh)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            INTERNET
                │
                ▼
            AWS ALB  ◄──── AWS Load Balancer Controller
                │          (reads your Gateway API rules
                │           and sets up the ALB to match)
                ▼
        ┌───────┴───────┐
        ▼               ▼
    frontend           api
                        │
                        ▼
                     payment
                        │
                        ▼
                    database
                 (Amazon RDS,
               outside the cluster)

Underneath: AWS VPC CNI gives every Pod a real IP from your AWS VPC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How a request travels.&lt;/strong&gt; A user visits &lt;code&gt;https://shop.example.com/api&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The request hits the AWS ALB.&lt;/li&gt;
&lt;li&gt;Because the ALB is L7, it reads the URL and sees "/api goes to the api service."&lt;/li&gt;
&lt;li&gt;The request reaches the api Pod.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Worth knowing:&lt;/strong&gt; the AWS Load Balancer Controller is not in the path the traffic takes. It works behind the scenes: it reads your Gateway API rules and sets up the ALB to match them. The traffic itself goes ALB → Pod.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When would you add a service mesh later?&lt;/strong&gt; When you start needing things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;encrypted traffic between your own services (called mTLS)&lt;/li&gt;
&lt;li&gt;automatic retries when a service briefly fails&lt;/li&gt;
&lt;li&gt;detailed numbers on how each service is talking to the others&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Until then, skipping the mesh keeps things simpler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why choose this setup:&lt;/strong&gt; less to install and maintain yourself, because AWS runs the hard parts. The downside is that you're tied to AWS.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Project 2: AWS outside, open-source inside
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mindset:&lt;/strong&gt; "We use AWS for the cloud, but we want the Kubernetes networking to not depend on AWS."&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Front door&lt;/td&gt;
&lt;td&gt;AWS NLB (L4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing rules&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who makes the rules real&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            INTERNET
                │
                ▼
            AWS NLB        (L4: just passes traffic in)
                │
                ▼
             Cilium        (reads the URL and follows
                │           your Gateway API rules)
     ┌──────────┼──────────┐
     ▼          ▼          ▼
 frontend      api      payment
     └──────────┴──────────┘
                │
                ▼
            database

   Cilium also controls traffic and
   security between the services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice: one tool, Cilium, does many jobs at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pod networking (CNI)&lt;/li&gt;
&lt;li&gt;Network policy (who is allowed to talk to whom)&lt;/li&gt;
&lt;li&gt;Following your Gateway API rules&lt;/li&gt;
&lt;li&gt;Both simple (L4) and smart (L7) traffic handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why the NLB instead of the ALB?&lt;/strong&gt; This is where L4 vs L7 matters. The NLB is a simple front door that just passes traffic through, and Cilium makes the smart routing decisions. If you used the ALB, it would do the routing itself, and that's exactly the AWS-specific part you're trying to avoid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why choose this setup:&lt;/strong&gt; if you ever move off AWS, most of your Kubernetes networking (Cilium + Gateway API) comes with you. Only the NLB needs replacing.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Project 3: Mostly open-source, runs anywhere
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mindset:&lt;/strong&gt; "The same platform has to run on AWS, Azure, our own servers, bare metal and private cloud."&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Front door&lt;/td&gt;
&lt;td&gt;HAProxy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing rules&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who makes the rules real&lt;/td&gt;
&lt;td&gt;Traefik&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service&lt;/td&gt;
&lt;td&gt;Istio&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            INTERNET
                │
                ▼
            HAProxy        OUTSIDE the cluster
                │          (stable front door)
   - - - - - - -│- - - - - - - - - - - - -
                ▼
            Traefik        INSIDE the cluster
                │          (follows your Gateway API rules)
     ┌──────────┼──────────┐
     ▼          ▼          ▼
 frontend      api      payment
     └──────────┴──────────┘
                │
                ▼
            database

   Istio controls traffic between services
   (encryption, retries, monitoring)

Underneath: Cilium gives every Pod networking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why two proxies in a row (HAProxy, then Traefik)?&lt;/strong&gt; They do different jobs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HAProxy&lt;/strong&gt; sits outside the cluster. Its job is to be a stable front door with a fixed address. If a server inside the cluster dies, HAProxy just stops sending traffic there. It doesn't need to understand Kubernetes at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traefik&lt;/strong&gt; sits inside the cluster. It understands Kubernetes, reads your Gateway API rules, and knows which Pods are running right now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of HAProxy as the building's front door and Traefik as the receptionist inside.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why choose this setup:&lt;/strong&gt; almost nothing here is tied to a cloud provider, so the same design works everywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The cost:&lt;/strong&gt; you run and maintain everything yourself. There are more moving parts, more to learn and more that can break.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. All three side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;th&gt;Project 1 (AWS-heavy)&lt;/th&gt;
&lt;th&gt;Project 2 (mixed)&lt;/th&gt;
&lt;th&gt;Project 3 (open-source)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod networking&lt;/td&gt;
&lt;td&gt;AWS VPC CNI&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Front door&lt;/td&gt;
&lt;td&gt;AWS ALB (L7)&lt;/td&gt;
&lt;td&gt;AWS NLB (L4)&lt;/td&gt;
&lt;td&gt;HAProxy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing rules&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;td&gt;Gateway API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rule follower&lt;/td&gt;
&lt;td&gt;AWS LB Controller&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;td&gt;Traefik&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service-to-service&lt;/td&gt;
&lt;td&gt;None (yet)&lt;/td&gt;
&lt;td&gt;Cilium&lt;/td&gt;
&lt;td&gt;Istio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tied to AWS?&lt;/td&gt;
&lt;td&gt;A lot&lt;/td&gt;
&lt;td&gt;A little&lt;/td&gt;
&lt;td&gt;Barely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Effort to run&lt;/td&gt;
&lt;td&gt;Lowest&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Highest&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice: Gateway API stays the same in all three. That's its whole point. It's a standard way to write routing rules, and you can swap out the tool that follows them.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Where does MetalLB fit?
&lt;/h2&gt;

&lt;p&gt;People sometimes call MetalLB "Kubernetes' version of HAProxy." That's not quite right.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem it solves:&lt;/strong&gt; in Kubernetes, you can create a Service of &lt;code&gt;type: LoadBalancer&lt;/code&gt;, which basically means "give me an address the outside world can reach."&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On AWS, Azure or GCP, the cloud automatically creates a load balancer and gives you that address.&lt;/li&gt;
&lt;li&gt;On bare metal or your own servers, nobody does this. The Service just sits there stuck on &lt;code&gt;&amp;lt;pending&amp;gt;&lt;/code&gt; forever.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;MetalLB fills that gap. It hands out outside-reachable addresses to your LoadBalancer Services, doing the job the cloud would normally do.&lt;/p&gt;

&lt;p&gt;So a better way to think of it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;MetalLB = "the cloud's load-balancer feature, for clusters that don't have a cloud."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;How it connects to Project 3:&lt;/strong&gt; when Project 3 runs on bare metal, something has to give the entry point a stable address. MetalLB is a common way to do that. It can be used alongside HAProxy, or in simpler setups it can replace the need for a separate outside proxy, giving Traefik its address directly.&lt;/p&gt;

&lt;p&gt;In the 5-job list, MetalLB belongs to Job 2 (the front door), but only for clusters without a cloud provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. One-sentence summary
&lt;/h2&gt;

&lt;p&gt;Split networking into 5 jobs, pick one tool per job, and remember that the tools mostly work together rather than compete. How much you hand over to AWS versus run yourself is the real choice you're making.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-learning-journal/blob/main/networking/kubernetes-networking-explained.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-learning-journal/blob/main/networking/kubernetes-networking-explained.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>networking</category>
      <category>aws</category>
      <category>devops</category>
    </item>
    <item>
      <title>Getting AWS Secrets into EKS Pods with ESO and Pod Identity</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Mon, 05 Oct 2026 13:54:14 +0000</pubDate>
      <link>https://dev.to/nazmur96/getting-aws-secrets-into-eks-pods-with-eso-and-pod-identity-55if</link>
      <guid>https://dev.to/nazmur96/getting-aws-secrets-into-eks-pods-with-eso-and-pod-identity-55if</guid>
      <description>&lt;p&gt;So we have an app/microservice/pod which needs access to a secret that we&lt;br&gt;
stored in AWS Secrets Manager, let's say the database password.&lt;/p&gt;

&lt;p&gt;We don't want our app to talk to AWS at all. We want the app to just find the&lt;br&gt;
password inside Kubernetes as a normal K8s Secret. So we bring in a middleman&lt;br&gt;
to fetch it for us: &lt;strong&gt;ESO&lt;/strong&gt; (External Secrets Operator).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqy1myuo5lja3epsjhnov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqy1myuo5lja3epsjhnov.png" alt="ESO and EKS Pod Identity: the app reads a K8s Secret, ESO fetches it from Secrets Manager using temporary credentials from the Pod Identity Agent" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Part 1: Setup (done once)
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1: Install ESO in the cluster
&lt;/h3&gt;

&lt;p&gt;We install External Secrets Operator, usually with Helm, into its own namespace&lt;br&gt;
(&lt;code&gt;external-secrets&lt;/code&gt;). This creates the ESO pods and a ServiceAccount for them,&lt;br&gt;
also called &lt;code&gt;external-secrets&lt;/code&gt;. Now we have a courier living in our cluster,&lt;br&gt;
but it has no AWS ID card yet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EKS
 ├── App pod
 └── ESO pod  (ServiceAccount: external-secrets)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Install the Pod Identity Agent
&lt;/h3&gt;

&lt;p&gt;We install the EKS Pod Identity Agent add-on. It runs a small helper on every&lt;br&gt;
node. Its job is to hand out AWS credentials to pods that are allowed to have&lt;br&gt;
them. Think of it as the ID card office.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Create an IAM role for ESO
&lt;/h3&gt;

&lt;p&gt;We create an IAM role, say &lt;code&gt;ESO-Secrets-Reader&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Permissions policy:&lt;/strong&gt; "you can read the secret &lt;code&gt;my-app/database&lt;/code&gt;"
(&lt;code&gt;GetSecretValue&lt;/code&gt;, &lt;code&gt;DescribeSecret&lt;/code&gt;, limited to only the secrets ESO needs).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust policy:&lt;/strong&gt; "I trust EKS Pod Identity (&lt;code&gt;pods.eks.amazonaws.com&lt;/code&gt;) to
hand me out to pods."&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Step 4: Connect the role to ESO's ServiceAccount
&lt;/h3&gt;

&lt;p&gt;We create a Pod Identity association that tells EKS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;namespace: external-secrets + ServiceAccount: external-secrets
                    ↓
            IAM role: ESO-Secrets-Reader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meaning: "any pod running with this ServiceAccount gets this role." Now ESO has&lt;br&gt;
an ID card.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; if ESO was already running before you created the association,&lt;br&gt;
restart the ESO pods. Pod Identity sets up the credential wiring when a pod&lt;br&gt;
starts, so old pods won't pick it up.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Part 2: Telling ESO what to do
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 5: Create a SecretStore
&lt;/h3&gt;

&lt;p&gt;This tells ESO &lt;strong&gt;where&lt;/strong&gt; to look: "AWS Secrets Manager, region&lt;br&gt;
&lt;code&gt;eu-central-1&lt;/code&gt;." There are no access keys in here. ESO uses its Pod Identity&lt;br&gt;
credentials automatically.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 6: Create an ExternalSecret
&lt;/h3&gt;

&lt;p&gt;This tells ESO &lt;strong&gt;what&lt;/strong&gt; to fetch: "Get &lt;code&gt;my-app/database&lt;/code&gt; from that store,&lt;br&gt;
create a K8s Secret called &lt;code&gt;database-secret&lt;/code&gt; in my app's namespace, and check&lt;br&gt;
for changes every hour."&lt;/p&gt;
&lt;h2&gt;
  
  
  Part 3: What happens automatically
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 7: ESO gets its credentials
&lt;/h3&gt;

&lt;p&gt;ESO needs to call AWS, so the AWS SDK inside ESO asks the Pod Identity Agent&lt;br&gt;
for credentials. The agent checks the association, gets temporary credentials&lt;br&gt;
for &lt;code&gt;ESO-Secrets-Reader&lt;/code&gt;, and gives them to ESO. They expire and get refreshed&lt;br&gt;
automatically. No access keys are stored anywhere.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 8: ESO fetches the secret
&lt;/h3&gt;

&lt;p&gt;ESO calls Secrets Manager with those credentials and gets the password.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 9: ESO creates the K8s Secret
&lt;/h3&gt;

&lt;p&gt;ESO creates a normal Kubernetes Secret called &lt;code&gt;database-secret&lt;/code&gt;. If someone&lt;br&gt;
changes the password in AWS later, ESO notices on its next refresh and updates&lt;br&gt;
it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 10: The app reads the secret
&lt;/h3&gt;

&lt;p&gt;The app's YAML just says "give me &lt;code&gt;DB_PASSWORD&lt;/code&gt; from Secret &lt;code&gt;database-secret&lt;/code&gt;,"&lt;br&gt;
as an env variable or a file. The app has no IAM role, no AWS credentials, and&lt;br&gt;
no idea AWS exists.&lt;/p&gt;
&lt;h2&gt;
  
  
  The picture to remember
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pod Identity Agent ──gives temp creds──► ESO pod
                                          │
                                          │ fetch
                                          ▼
                                   Secrets Manager
                                          │
                                          │ password
                                          ▼
                                    ESO creates
                                          │
                                          ▼
                                 K8s Secret (database-secret)
                                          │
                                          │ reads
                                          ▼
                                       App pod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  The whole thing in one line
&lt;/h2&gt;

&lt;p&gt;Install ESO and the Pod Identity Agent → give ESO an AWS role through a Pod&lt;br&gt;
Identity association → tell ESO where to look (SecretStore) and what to fetch&lt;br&gt;
(ExternalSecret) → ESO copies the secret into a K8s Secret → the app reads it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The analogy
&lt;/h2&gt;

&lt;p&gt;Secrets Manager is a bank vault. ESO is a courier we hire (Step 1). The Pod&lt;br&gt;
Identity Agent is the office that issues ID cards (Step 2). The IAM role is the&lt;br&gt;
permission slip that says what the courier can pick up (Step 3), and the&lt;br&gt;
association assigns that slip to our courier (Step 4). We tell the courier&lt;br&gt;
which bank (SecretStore) and which box (ExternalSecret). The courier picks up&lt;br&gt;
the cash and puts it in a locker inside our building (the K8s Secret), and our&lt;br&gt;
app just opens the locker.&lt;/p&gt;


&lt;h1&gt;
  
  
  Hands-on: step-by-step template
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; an app in EKS reads a secret from AWS Secrets Manager without having&lt;br&gt;
any AWS credentials itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; a running EKS cluster, plus &lt;code&gt;aws&lt;/code&gt;, &lt;code&gt;kubectl&lt;/code&gt;, and &lt;code&gt;helm&lt;/code&gt;&lt;br&gt;
installed and configured.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 0: Set your variables
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CLUSTER_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;my-cluster
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;AWS_REGION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;eu-central-1
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ACCOUNT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;aws sts get-caller-identity &lt;span class="nt"&gt;--query&lt;/span&gt; Account &lt;span class="nt"&gt;--output&lt;/span&gt; text&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 1: Create a secret in AWS Secrets Manager
&lt;/h3&gt;

&lt;p&gt;This is the secret our app needs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws secretsmanager create-secret &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; my-app/database &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--region&lt;/span&gt; &lt;span class="nv"&gt;$AWS_REGION&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--secret-string&lt;/span&gt; &lt;span class="s1"&gt;'{"username":"admin","password":"S3cr3t!"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Install ESO (the courier)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo add external-secrets https://charts.external-secrets.io
helm repo update

helm &lt;span class="nb"&gt;install &lt;/span&gt;external-secrets external-secrets/external-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--namespace&lt;/span&gt; external-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--create-namespace&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates the ESO pods and a ServiceAccount named &lt;code&gt;external-secrets&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Install the Pod Identity Agent (the ID card office)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws eks create-addon &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cluster-name&lt;/span&gt; &lt;span class="nv"&gt;$CLUSTER_NAME&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--addon-name&lt;/span&gt; eks-pod-identity-agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check that it's running on every node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get daemonset eks-pod-identity-agent &lt;span class="nt"&gt;-n&lt;/span&gt; kube-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Create an IAM role for ESO (the permission slip)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Trust policy:&lt;/strong&gt; lets EKS Pod Identity hand this role to pods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; trust-policy.json &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "Service": "pods.eks.amazonaws.com" },
      "Action": ["sts:AssumeRole", "sts:TagSession"]
    }
  ]
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;aws iam create-role &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role-name&lt;/span&gt; ESO-Secrets-Reader &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--assume-role-policy-document&lt;/span&gt; file://trust-policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Permissions policy:&lt;/strong&gt; allows reading only our app's secrets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; permissions-policy.json &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "secretsmanager:GetSecretValue",
        "secretsmanager:DescribeSecret"
      ],
      "Resource": "arn:aws:secretsmanager:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;AWS_REGION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ACCOUNT_ID&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;:secret:my-app/*"
    }
  ]
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;aws iam put-role-policy &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role-name&lt;/span&gt; ESO-Secrets-Reader &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--policy-name&lt;/span&gt; read-my-app-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--policy-document&lt;/span&gt; file://permissions-policy.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your secret is encrypted with a custom KMS key instead of the AWS default,&lt;br&gt;
also allow &lt;code&gt;kms:Decrypt&lt;/code&gt; on that key.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 5: Connect the role to ESO's ServiceAccount (give the courier the slip)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws eks create-pod-identity-association &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cluster-name&lt;/span&gt; &lt;span class="nv"&gt;$CLUSTER_NAME&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--namespace&lt;/span&gt; external-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--service-account&lt;/span&gt; external-secrets &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--role-arn&lt;/span&gt; arn:aws:iam::&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ACCOUNT_ID&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;:role/ESO-Secrets-Reader
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then restart ESO so its pods pick up the new identity. Pods only get the&lt;br&gt;
credential wiring when they start.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl rollout restart deployment &lt;span class="nt"&gt;-n&lt;/span&gt; external-secrets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Tell ESO where to look (ClusterSecretStore)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# cluster-secret-store.yaml&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;external-secrets.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterSecretStore&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-secrets-manager&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;aws&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SecretsManager&lt;/span&gt;
      &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eu-central-1&lt;/span&gt;   &lt;span class="c1"&gt;# change to your region&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's no &lt;code&gt;auth&lt;/code&gt; section and no access keys. ESO automatically uses the&lt;br&gt;
credentials Pod Identity gives it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; cluster-secret-store.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're on an older ESO version, use &lt;code&gt;external-secrets.io/v1beta1&lt;/code&gt; instead of&lt;br&gt;
&lt;code&gt;v1&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Tell ESO what to fetch (ExternalSecret)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# external-secret.yaml&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;external-secrets.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ExternalSecret&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;database-secret&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;refreshInterval&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1h&lt;/span&gt;            &lt;span class="c1"&gt;# how often ESO checks AWS for changes&lt;/span&gt;
  &lt;span class="na"&gt;secretStoreRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-secrets-manager&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterSecretStore&lt;/span&gt;
  &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;database-secret&lt;/span&gt;        &lt;span class="c1"&gt;# the K8s Secret ESO will create&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;secretKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;username&lt;/span&gt;        &lt;span class="c1"&gt;# key name inside the K8s Secret&lt;/span&gt;
      &lt;span class="na"&gt;remoteRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app/database&lt;/span&gt;     &lt;span class="c1"&gt;# secret name in AWS&lt;/span&gt;
        &lt;span class="na"&gt;property&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;username&lt;/span&gt;       &lt;span class="c1"&gt;# JSON field inside it&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;secretKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt;
      &lt;span class="na"&gt;remoteRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app/database&lt;/span&gt;
        &lt;span class="na"&gt;property&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create namespace my-app
kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; external-secret.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 8: The app reads the K8s Secret (opens the locker)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# app.yaml&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-app&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;busybox&lt;/span&gt;
          &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sh"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-c"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;echo&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;App&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;started;&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;sleep&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;3600"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
          &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DB_USERNAME&lt;/span&gt;
              &lt;span class="na"&gt;valueFrom&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;secretKeyRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;database-secret&lt;/span&gt;
                  &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;username&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DB_PASSWORD&lt;/span&gt;
              &lt;span class="na"&gt;valueFrom&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;secretKeyRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;database-secret&lt;/span&gt;
                  &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; app.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The app has no IAM role and no AWS credentials. It just reads a normal K8s&lt;br&gt;
Secret.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 9: Verify it works
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Did ESO sync the secret? Look for STATUS = SecretSynced, READY = True&lt;/span&gt;
kubectl get externalsecret &lt;span class="nt"&gt;-n&lt;/span&gt; my-app

&lt;span class="c"&gt;# 2. Does the K8s Secret exist with the right value?&lt;/span&gt;
kubectl get secret database-secret &lt;span class="nt"&gt;-n&lt;/span&gt; my-app &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.data.password}'&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;

&lt;span class="c"&gt;# 3. Does the app see it?&lt;/span&gt;
kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; my-app deploy/my-app &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nb"&gt;printenv &lt;/span&gt;DB_USERNAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ExternalSecret shows &lt;code&gt;AccessDenied&lt;/code&gt;:&lt;/strong&gt; check the association exists
(&lt;code&gt;aws eks list-pod-identity-associations --cluster-name $CLUSTER_NAME&lt;/code&gt;),
confirm the namespace and ServiceAccount names match exactly, and restart the
ESO pods.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ResourceNotFound&lt;/code&gt;:&lt;/strong&gt; the secret name or region in AWS doesn't match
&lt;code&gt;remoteRef.key&lt;/code&gt; or the store's region.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secret changed in AWS but the app still has the old value:&lt;/strong&gt; ESO updated
the K8s Secret, but env vars are only read when a pod starts. Restart the
app, mount the secret as a volume instead, or use a tool like Reloader to
restart pods automatically.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cleanup
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete namespace my-app
helm uninstall external-secrets &lt;span class="nt"&gt;-n&lt;/span&gt; external-secrets
aws eks delete-pod-identity-association &lt;span class="nt"&gt;--cluster-name&lt;/span&gt; &lt;span class="nv"&gt;$CLUSTER_NAME&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--association-id&lt;/span&gt; &amp;lt;id-from-list-command&amp;gt;
aws iam delete-role-policy &lt;span class="nt"&gt;--role-name&lt;/span&gt; ESO-Secrets-Reader &lt;span class="nt"&gt;--policy-name&lt;/span&gt; read-my-app-secrets
aws iam delete-role &lt;span class="nt"&gt;--role-name&lt;/span&gt; ESO-Secrets-Reader
aws secretsmanager delete-secret &lt;span class="nt"&gt;--secret-id&lt;/span&gt; my-app/database &lt;span class="nt"&gt;--force-delete-without-recovery&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/devops-sre-authentication/blob/main/posts/eso-eks-pod-identity.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/devops-sre-authentication/blob/main/posts/eso-eks-pod-identity.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>aws</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>HD-101 — The first pull request</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Tue, 25 Aug 2026 14:08:50 +0000</pubDate>
      <link>https://dev.to/nazmur96/hd-101-the-first-pull-request-2fep</link>
      <guid>https://dev.to/nazmur96/hd-101-the-first-pull-request-2fep</guid>
      <description>&lt;h1&gt;
  
  
  HD-101 — The first pull request
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Builds:&lt;/strong&gt; nothing. &lt;strong&gt;Teaches:&lt;/strong&gt; why the next six tickets exist.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ticket
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Add a feature to the helpdesk CLI. Don't push to &lt;code&gt;main&lt;/code&gt; — open a pull request.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What you do
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch &lt;span class="nt"&gt;-c&lt;/span&gt; hd-101-priority-filter
&lt;span class="c"&gt;# ... write the code ...&lt;/span&gt;
git add &lt;span class="nt"&gt;-A&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"feat: filter tickets by priority"&lt;/span&gt;
git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin hd-101-priority-filter

gh &lt;span class="nb"&gt;pr &lt;/span&gt;create &lt;span class="nt"&gt;--base&lt;/span&gt; main &lt;span class="nt"&gt;--head&lt;/span&gt; hd-101-priority-filter &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--title&lt;/span&gt; &lt;span class="s2"&gt;"HD-101: filter tickets by priority"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--body&lt;/span&gt; &lt;span class="s2"&gt;"Adds --priority to the list command."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then merge it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually happened
&lt;/h2&gt;

&lt;p&gt;The PR merged. Green tick, satisfying. And &lt;strong&gt;nothing had checked anything.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There were no tests running, no required reviewers, no status checks. The PR was a&lt;br&gt;
change of scenery, not a gate. Anyone could have merged anything.&lt;/p&gt;

&lt;p&gt;That is the entire point of this ticket. You are supposed to feel how empty it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two words that cause the most confusion
&lt;/h2&gt;

&lt;p&gt;Every PR has a &lt;strong&gt;base&lt;/strong&gt; and a &lt;strong&gt;head&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Word&lt;/th&gt;
&lt;th&gt;Means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;base&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Destination.&lt;/strong&gt; Where the code lands.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;head&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Source.&lt;/strong&gt; Where the code comes from.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;--base main --head hd-101-priority-filter&lt;/code&gt; reads: &lt;em&gt;this branch ends up in &lt;code&gt;main&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Get these backwards and you will open a PR proposing to merge &lt;code&gt;main&lt;/code&gt; into your&lt;br&gt;
feature branch, which looks almost right and is completely wrong. It happens to&lt;br&gt;
everyone at least once. It happened here — see &lt;a href="https://github.com/nazmur96/git-promotion-ladder/blob/main/docs/mistakes.md" rel="noopener noreferrer"&gt;mistakes.md&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also:&lt;/strong&gt; a PR's &lt;code&gt;head&lt;/code&gt; has nothing to do with git's &lt;code&gt;HEAD&lt;/code&gt; pointer. Same word,&lt;br&gt;
unrelated meanings. Git's &lt;code&gt;HEAD&lt;/code&gt; is "where I am standing right now"; a PR's head is&lt;br&gt;
"the branch being proposed".&lt;/p&gt;

&lt;h2&gt;
  
  
  What to look at before moving on
&lt;/h2&gt;

&lt;p&gt;Open the merged PR and look at the checks section. It's empty. Remember that.&lt;/p&gt;




&lt;p&gt;Next: &lt;strong&gt;&lt;a href="https://github.com/nazmur96/git-promotion-ladder/blob/main/docs/hd-102-continuous-integration.md" rel="noopener noreferrer"&gt;HD-102 — Continuous integration&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;originally published at &lt;a href="https://github.com/nazmur96/git-promotion-ladder/blob/main/docs/hd-101-first-pull-request.md" rel="noopener noreferrer"&gt;https://github.com/nazmur96/git-promotion-ladder/blob/main/docs/hd-101-first-pull-request.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>5 Docker Scenarios Every Developer Should Practice (With Fixes &amp; Best Practices)</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Tue, 21 Apr 2026 20:56:35 +0000</pubDate>
      <link>https://dev.to/nazmur96/5-docker-scenarios-every-developer-should-practice-with-fixes-best-practices-3l70</link>
      <guid>https://dev.to/nazmur96/5-docker-scenarios-every-developer-should-practice-with-fixes-best-practices-3l70</guid>
      <description>&lt;p&gt;So you know the basics of Docker — &lt;code&gt;docker run&lt;/code&gt;, &lt;code&gt;docker build&lt;/code&gt;, maybe some &lt;code&gt;docker compose up&lt;/code&gt;. But do you know what happens when things break?&lt;/p&gt;

&lt;p&gt;This guide walks you through &lt;strong&gt;5 real-world Docker scenarios&lt;/strong&gt; that will sharpen your skills around debugging, security, storage, and production-readiness.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scenario 1: The Broken Build 🔨
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Goal
&lt;/h3&gt;

&lt;p&gt;Fix a broken Dockerfile, then optimize it to be 10x smaller and production-ready.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;app.py&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello from Docker!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0.0.0.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;requirements.txt&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flask==2.3.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ❌ The Broken Dockerfile
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; ubuntu:latest&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;python3

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /opt/app&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; root&lt;/span&gt;

&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; python /opt/app/app.py&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tasks
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Troubleshoot the Build
&lt;/h4&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; broken-app &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are &lt;strong&gt;at least 3 issues&lt;/strong&gt; hiding in that Dockerfile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pip&lt;/code&gt; is never installed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;apt-get install&lt;/code&gt; is missing the &lt;code&gt;-y&lt;/code&gt; flag (hangs waiting for input)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;COPY&lt;/code&gt; happens before dependency install — busting the cache on every change&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Fix Layer Caching
&lt;/h4&gt;

&lt;p&gt;Copy &lt;code&gt;requirements.txt&lt;/code&gt; first, install deps, &lt;em&gt;then&lt;/em&gt; copy the rest of the app. This way, changing &lt;code&gt;app.py&lt;/code&gt; won't trigger a full &lt;code&gt;pip install&lt;/code&gt; on every build.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; requirements.txt .&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /opt/app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Optimize the Image
&lt;/h4&gt;

&lt;p&gt;Switch from &lt;code&gt;ubuntu:latest&lt;/code&gt; to a slim base:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.12-slim&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /opt/app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; requirements.txt .&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--no-cache-dir&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;

&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 5000&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["python", "app.py"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Target:&lt;/strong&gt; &amp;lt; 150MB image size ✅&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Security Hardening
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run as non-root&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; 1001&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run with a read-only filesystem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--read-only&lt;/span&gt; &lt;span class="nt"&gt;--tmpfs&lt;/span&gt; /tmp myapp:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Scenario 2: The Ghost Data 👻
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Goal
&lt;/h3&gt;

&lt;p&gt;Understand Docker's storage lifecycle and how to make data actually persist.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tasks
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Run an Ephemeral Container
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; web-test &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:80 nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Write Data Inside the Container
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; web-test bash
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"hello"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /usr/share/nginx/html/test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;code&gt;http://localhost:8080/test.txt&lt;/code&gt; — it's there!&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Destroy &amp;amp; Recreate
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop web-test
docker &lt;span class="nb"&gt;rm &lt;/span&gt;web-test
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; web-test2 &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:80 nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The file is gone. Why?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because the container filesystem is &lt;strong&gt;ephemeral&lt;/strong&gt; — it only lives as long as the container does.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  4. Named Volume Persistence
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker volume create web-data

docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; web-test &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:80 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-v&lt;/span&gt; web-data:/usr/share/nginx/html &lt;span class="se"&gt;\&lt;/span&gt;
  nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Verify Persistence
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; web-test bash
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"persistent data"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /usr/share/nginx/html/test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stop and remove the container, then start a new one with the same volume — your file will still be there. 🎉&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Cleanup
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker system prune &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;system prune&lt;/code&gt; removes stopped containers, dangling images, and unused networks — but &lt;strong&gt;not named volumes&lt;/strong&gt; unless you add &lt;code&gt;--volumes&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Scenario 3: The Flaky Database Connection 🐘
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Goal
&lt;/h3&gt;

&lt;p&gt;Fix service startup dependency issues in Docker Compose.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Broken &lt;code&gt;docker-compose.yml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5000:5000"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;DB_HOST=postgres&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;

  &lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:15&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_PASSWORD=secret&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tasks
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Run the Stack
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt; &lt;code&gt;depends_on&lt;/code&gt; only waits for the container to &lt;em&gt;start&lt;/em&gt;, not for Postgres to be &lt;em&gt;ready to accept connections&lt;/em&gt;. Your web app crashes on startup.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Add a Healthcheck to Postgres
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:15&lt;/span&gt;
  &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_PASSWORD=secret&lt;/span&gt;
  &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CMD-SHELL"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pg_isready&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-U&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;postgres"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
    &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
    &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Fix &lt;code&gt;depends_on&lt;/code&gt; with a Condition
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;condition&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;service_healthy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your web service won't start until Postgres passes its healthcheck. ✅&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Move Secrets to &lt;code&gt;.env&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;.env&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;secret&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;docker-compose.yml&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_PASSWORD=${POSTGRES_PASSWORD}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Keep Secrets Out of Git
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;.gitignore&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;.&lt;span class="n"&gt;env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Never commit &lt;code&gt;.env&lt;/code&gt; files. Ever.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scenario 4: The Evil Image Scanner 🔍
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Goal
&lt;/h3&gt;

&lt;p&gt;Find and fix vulnerabilities hiding in your Docker images.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tasks
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Build a Vulnerable Image
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; nginx:1.21.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Install Trivy
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;aquasecurity/trivy/trivy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or on Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sfL&lt;/span&gt; https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. Scan the Image
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;trivy image nginx:1.21.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see a wall of &lt;strong&gt;HIGH&lt;/strong&gt; and &lt;strong&gt;CRITICAL&lt;/strong&gt; CVEs. This is what ships to production when nobody checks.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Fix the Base Image
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; nginx:1.25-bookworm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or go even lighter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; nginx:alpine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Rescan
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;trivy image nginx:1.25-bookworm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Expected:&lt;/strong&gt; 0 CRITICAL vulnerabilities ✅&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make image scanning part of your CI/CD pipeline — not an afterthought.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Scenario 5: The Limited Resource Box 📦
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Goal
&lt;/h3&gt;

&lt;p&gt;Run containers safely under strict resource constraints and enable offline portability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tasks
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Build the Optimized Image
&lt;/h4&gt;

&lt;p&gt;Use the hardened image from Scenario 1.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Run with Resource Limits
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;256m &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.5 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--read-only&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--tmpfs&lt;/span&gt; /tmp &lt;span class="se"&gt;\&lt;/span&gt;
  myapp:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Flag&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--memory=256m&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hard cap on RAM usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--cpus=0.5&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Limits to half a CPU core&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--read-only&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Prevents filesystem writes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--tmpfs /tmp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mounts writable in-memory temp dir&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  3. Verify the Restrictions
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &amp;lt;container_id&amp;gt; bash
&lt;span class="nb"&gt;touch&lt;/span&gt; /etc/test
&lt;span class="c"&gt;# Permission denied ✅&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Monitor resource usage live:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stats
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Export the Image
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker save &lt;span class="nt"&gt;-o&lt;/span&gt; myapp.tar myapp:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  5. Simulate an Offline Machine
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker rmi myapp:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  6. Restore the Image
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker load &lt;span class="nt"&gt;-i&lt;/span&gt; myapp.tar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  7. Run Without Internet
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run myapp:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Works fully offline. 🚀 Great for air-gapped environments, demos, or CI runners without registry access.&lt;/p&gt;




&lt;h2&gt;
  
  
  What You've Learned 🎓
&lt;/h2&gt;

&lt;p&gt;After completing all five scenarios, you now have hands-on experience with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Dockerfile debugging &amp;amp; optimization&lt;/strong&gt; — fixing real build errors and shrinking image sizes&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Layer caching strategies&lt;/strong&gt; — speeding up builds without reinstalling dependencies&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Volume persistence&lt;/strong&gt; — understanding ephemeral vs. persistent storage&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Compose healthchecks&lt;/strong&gt; — preventing race conditions between services&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Image vulnerability scanning&lt;/strong&gt; — catching CVEs before they reach production&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Runtime security hardening&lt;/strong&gt; — non-root users, read-only filesystems, resource limits&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Offline container portability&lt;/strong&gt; — shipping containers without a registry&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Want more? Drop a comment and I can turn this into a full GitHub repo with solutions, or expand each scenario into its own deep-dive post.&lt;/em&gt;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>containers</category>
      <category>beginners</category>
    </item>
    <item>
      <title>⚙️ My first CI/CD pipeline: From git push to production in 10 minutes</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Thu, 02 Apr 2026 19:45:56 +0000</pubDate>
      <link>https://dev.to/nazmur96/my-first-cicd-pipeline-from-git-push-to-production-in-10-minutes-1h4f</link>
      <guid>https://dev.to/nazmur96/my-first-cicd-pipeline-from-git-push-to-production-in-10-minutes-1h4f</guid>
      <description>&lt;p&gt;Remember the old days?&lt;/p&gt;

&lt;p&gt;You write code. You test it manually (maybe). You open FileZilla. You drag and drop files to a server. You pray.&lt;/p&gt;

&lt;p&gt;Then someone yells: "Who deployed on a Friday?!"&lt;/p&gt;

&lt;p&gt;Those days are dead.&lt;/p&gt;

&lt;p&gt;CI/CD pipelines are the reason modern developers ship code 10x faster with 90% fewer bugs. And the best part? You can set one up in 10 minutes. For free.&lt;/p&gt;

&lt;p&gt;Let me show you.&lt;/p&gt;




&lt;p&gt;What is CI/CD? (The 30-second explanation)&lt;/p&gt;

&lt;p&gt;CI = Continuous Integration – Every time you push code, automatically test it.&lt;/p&gt;

&lt;p&gt;CD = Continuous Delivery/Deployment – If tests pass, automatically deploy it.&lt;/p&gt;

&lt;p&gt;In practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin main
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;Automatic] Run tests
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;Automatic] Build the app
   ↓
&lt;span class="o"&gt;[&lt;/span&gt;Automatic] Deploy to server
   ↓
You get a notification: &lt;span class="s2"&gt;"✅ Deployment successful"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You never touch a server. You never run scp or FTP. You just push code.&lt;/p&gt;




&lt;p&gt;The 10-Minute Challenge&lt;/p&gt;

&lt;p&gt;By the end of this guide, you will have:&lt;/p&gt;

&lt;p&gt;· A simple Node.js/Express app (or your own project)&lt;br&gt;
· A GitHub repository&lt;br&gt;
· A GitHub Actions workflow that:&lt;br&gt;
  · Runs tests automatically&lt;br&gt;
  · Deploys to a free hosting service (Render.com – no credit card)&lt;/p&gt;

&lt;p&gt;Total time: ~10 minutes. I'll wait.&lt;/p&gt;



&lt;p&gt;What You'll Need (All Free)&lt;/p&gt;

&lt;p&gt;Tool Why&lt;br&gt;
GitHub account Hosts your code + runs CI/CD&lt;br&gt;
Render.com account Free hosting (similar to Heroku)&lt;br&gt;
A simple app We'll make one in 2 minutes&lt;/p&gt;

&lt;p&gt;No credit card required. No servers to manage.&lt;/p&gt;



&lt;p&gt;Step 1: The App (2 minutes)&lt;/p&gt;

&lt;p&gt;Create a new folder and a simple Express app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-cicd-app
&lt;span class="nb"&gt;cd &lt;/span&gt;my-cicd-app
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create index.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CI/CD works! 🚀&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/health&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OK&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// A simple test endpoint&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/add/:a/:b&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`App running on port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a test file test.js (we'll use Node's built-in assert):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;assert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;assert&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Simple tests that will run in CI&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Running tests...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Test 1: Addition works&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strictEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;✅ Test 1 passed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Test 2: String test&lt;/span&gt;
&lt;span class="nx"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strictEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;✅ Test 2 passed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;🎉 All tests passed!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update package.json with a test script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node test.js"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test it locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;test&lt;/span&gt;          &lt;span class="c"&gt;# Should show "All tests passed!"&lt;/span&gt;
npm start         &lt;span class="c"&gt;# Visit http://localhost:3000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Step 2: Push to GitHub (2 minutes)&lt;/p&gt;

&lt;p&gt;Create a repository on GitHub (don't initialize with README – we have our own).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit"&lt;/span&gt;
git remote add origin https://github.com/YOUR_USERNAME/my-cicd-app.git
git branch &lt;span class="nt"&gt;-M&lt;/span&gt; main
git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Step 3: Create the CI/CD Pipeline (3 minutes)&lt;/p&gt;

&lt;p&gt;This is where the magic happens. GitHub Actions reads a file in .github/workflows/ and runs it.&lt;/p&gt;

&lt;p&gt;Create this folder and file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; .github/workflows
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create .github/workflows/deploy.yml:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to Production&lt;/span&gt;

&lt;span class="c1"&gt;# When should this run?&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;main&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# Every push to main branch&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;    &lt;span class="c1"&gt;# Also allow manual trigger&lt;/span&gt;

&lt;span class="c1"&gt;# What environment variables do we need?&lt;/span&gt;
&lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;NODE_VERSION&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;18'&lt;/span&gt;

&lt;span class="c1"&gt;# Jobs run in parallel by default&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# JOB 1: Test&lt;/span&gt;
  &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run Tests&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;  &lt;span class="c1"&gt;# Free Linux runner&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Setup Node.js&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v4&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ env.NODE_VERSION }}&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install dependencies&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm ci&lt;/span&gt;  &lt;span class="c1"&gt;# ci is faster and stricter than install&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run tests&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm test&lt;/span&gt;

  &lt;span class="c1"&gt;# JOB 2: Deploy (only if tests passed)&lt;/span&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to Render&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;  &lt;span class="c1"&gt;# Wait for test job to succeed&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to Render&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;johnbeynon/render-deploy-action@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;service-id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.RENDER_SERVICE_ID }}&lt;/span&gt;
          &lt;span class="na"&gt;api-key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.RENDER_API_KEY }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On every git push to main:&lt;/li&gt;
&lt;li&gt;Spin up a fresh Linux machine (free)&lt;/li&gt;
&lt;li&gt;Run npm test&lt;/li&gt;
&lt;li&gt;If tests pass → deploy to Render&lt;/li&gt;
&lt;li&gt;If tests fail → stop (no deploy)&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Step 4: Hosting on Render (3 minutes)&lt;/p&gt;

&lt;p&gt;Render is like the old Heroku (but with a free tier that actually works).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to render.com and sign up with GitHub.&lt;/li&gt;
&lt;li&gt;Click "New +" → "Web Service"&lt;/li&gt;
&lt;li&gt;Connect your GitHub repository (my-cicd-app)&lt;/li&gt;
&lt;li&gt;Fill in the settings:
· Name: my-cicd-app
· Environment: Node
· Build Command: npm install
· Start Command: npm start
· Plan: Free&lt;/li&gt;
&lt;li&gt;Click "Create Web Service"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Render will deploy your app once manually. Wait for the green "Live" badge.&lt;/p&gt;

&lt;p&gt;You'll get a URL like: &lt;a href="https://my-cicd-app.onrender.com" rel="noopener noreferrer"&gt;https://my-cicd-app.onrender.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Visit it. You should see your JSON message.&lt;/p&gt;




&lt;p&gt;Step 5: Connect GitHub Actions to Render (2 minutes)&lt;/p&gt;

&lt;p&gt;Now we need to give GitHub Actions permission to deploy to Render.&lt;/p&gt;

&lt;p&gt;Get your Render API Key:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Render Dashboard → Account Settings (top right)&lt;/li&gt;
&lt;li&gt;Scroll to "API Keys" → Click "Create API Key"&lt;/li&gt;
&lt;li&gt;Name it github-actions → Copy the key (starts with rnd_)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Get your Render Service ID:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to your Web Service page on Render&lt;/li&gt;
&lt;li&gt;Look at the URL: &lt;a href="https://dashboard.render.com/web/srv-abc123def" rel="noopener noreferrer"&gt;https://dashboard.render.com/web/srv-abc123def&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The srv-abc123def part is your Service ID&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Add them as GitHub Secrets:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to your GitHub repository → Settings → Secrets and variables → Actions&lt;/li&gt;
&lt;li&gt;Click "New repository secret"&lt;/li&gt;
&lt;li&gt;Add RENDER_API_KEY → paste your API key&lt;/li&gt;
&lt;li&gt;Add RENDER_SERVICE_ID → paste your Service ID&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Step 6: Trigger Your First Pipeline (1 minute)&lt;/p&gt;

&lt;p&gt;Make a small change to trigger the pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Change the message in index.js&lt;/span&gt;
res.json&lt;span class="o"&gt;({&lt;/span&gt; message: &lt;span class="s1"&gt;'My first CI/CD pipeline! 🎉'&lt;/span&gt; &lt;span class="o"&gt;})&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;# Commit and push&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Test CI/CD pipeline"&lt;/span&gt;
git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go to your GitHub repository → Actions tab.&lt;/p&gt;

&lt;p&gt;You'll see a workflow running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Deploy to Production
  ├── Run Tests (yellow → green)
  └── Deploy to Render (yellow → green)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When both turn green ✅, visit your Render URL. Your new message is live.&lt;/p&gt;

&lt;p&gt;You just did CI/CD. 🚀&lt;/p&gt;




&lt;p&gt;What Just Happened? (The Diagram)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your laptop
    │
    │ git push origin main
    ▼
GitHub (Actions)
    │
    │ Spins up runner
    ▼
┌─────────────────────────────────────┐
│  CI Pipeline (Test)                 │
│  ├── npm ci                         │
│  ├── npm test                       │
│  └── ✅ All tests passed            │
└─────────────────────────────────────┘
    │
    │ Tests pass → trigger CD
    ▼
┌─────────────────────────────────────┐
│  CD Pipeline (Deploy)               │
│  ├── Call Render API                │
│  ├── Render pulls code              │
│  ├── npm install                    │
│  ├── npm start                      │
│  └── ✅ Live at your URL            │
└─────────────────────────────────────┘
    │
    ▼
Production server (Render)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Common Variations (Adapt to Your Stack)&lt;/p&gt;

&lt;p&gt;For a Python (Django/Flask) app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/deploy.yml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Setup Python&lt;/span&gt;
  &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-python@v4&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;python-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.11'&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install dependencies&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;pip install -r requirements.txt&lt;/span&gt;
    &lt;span class="s"&gt;pip install pytest&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Run tests&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pytest&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;# Render handles Python automatically&lt;/span&gt;
    &lt;span class="s"&gt;# Or use: flyctl deploy, railway up, etc.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a React/Vite static site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install dependencies&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm ci&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm run build&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to Netlify&lt;/span&gt;
  &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nwtgck/actions-netlify@v2&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;publish-dir&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;./dist'&lt;/span&gt;
    &lt;span class="na"&gt;production-branch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;NETLIFY_AUTH_TOKEN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.NETLIFY_TOKEN }}&lt;/span&gt;
    &lt;span class="na"&gt;NETLIFY_SITE_ID&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.NETLIFY_SITE_ID }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a Docker container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build Docker image&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker build -t myapp .&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Push to Docker Hub&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin&lt;/span&gt;
    &lt;span class="s"&gt;docker push myusername/myapp:latest&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to DigitalOcean&lt;/span&gt;
  &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;appleboy/ssh-action@v1&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.HOST }}&lt;/span&gt;
    &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.USERNAME }}&lt;/span&gt;
    &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.SSH_KEY }}&lt;/span&gt;
    &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker pull myusername/myapp &amp;amp;&amp;amp; docker-compose up -d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Pro Tips (From Someone Who Broke Production)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Always test before deploying (duh)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The needs: test line ensures you never deploy broken code. Add a failing test and watch the pipeline stop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Add this to test.js – it will FAIL&lt;/span&gt;
&lt;span class="nx"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strictEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;This line never runs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push it. Watch the pipeline fail at the test stage. Deploy never happens. You just saved production.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use npm ci instead of npm install&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;· npm install can update package-lock.json (unexpected changes)&lt;br&gt;
· npm ci installs exactly what's in package-lock.json (reproducible builds)&lt;/p&gt;

&lt;p&gt;Always use npm ci in CI.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add a "staging" environment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For real projects, deploy to staging first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;main&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;     &lt;span class="c1"&gt;# Deploys to staging&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;production&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# Deploys to production&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add notifications&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Get a Slack/Discord message when deploy finishes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Send Slack notification&lt;/span&gt;
  &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;slackapi/slack-github-action@v1&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
      &lt;span class="s"&gt;{&lt;/span&gt;
        &lt;span class="s"&gt;"text": "✅ Deployed to production!"&lt;/span&gt;
      &lt;span class="s"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;SLACK_WEBHOOK_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.SLACK_WEBHOOK }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Manual approval for production (for serious teams)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy-prod&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;needs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;production&lt;/span&gt;  &lt;span class="c1"&gt;# Requires approval in GitHub&lt;/span&gt;
  &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
  &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to production&lt;/span&gt;
      &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./deploy.sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then go to GitHub → Settings → Environments → Add protection rule.&lt;/p&gt;




&lt;p&gt;Troubleshooting (When Things Go Wrong)&lt;/p&gt;

&lt;p&gt;Symptom Most likely fix&lt;br&gt;
Workflow doesn't trigger Check branch name: main vs master&lt;br&gt;
Tests fail but work locally Different Node version? Add .nvmrc file&lt;br&gt;
Deploy step fails Wrong Render Service ID or API key&lt;br&gt;
"Module not found" Forgot npm ci step?&lt;br&gt;
"Permission denied" GitHub Actions needs write permissions → Settings → Actions → General → Workflow permissions&lt;/p&gt;



&lt;p&gt;What You Just Learned&lt;/p&gt;

&lt;p&gt;✅ CI = Automatic testing on every push&lt;br&gt;
✅ CD = Automatic deployment if tests pass&lt;br&gt;
✅ GitHub Actions = Free CI/CD runners&lt;br&gt;
✅ Render = Free hosting with API deploys&lt;br&gt;
✅ Secrets = Store API keys safely&lt;/p&gt;

&lt;p&gt;You can now add CI/CD to any project in ~10 minutes.&lt;/p&gt;



&lt;p&gt;Next Steps (Level Up)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add more tests – Unit tests, integration tests&lt;/li&gt;
&lt;li&gt;Add a database – Render has free PostgreSQL&lt;/li&gt;
&lt;li&gt;Add a staging environment – Deploy to staging first, then production&lt;/li&gt;
&lt;li&gt;Add end-to-end tests – Cypress or Playwright&lt;/li&gt;
&lt;li&gt;Try other platforms – Vercel, Netlify, Railway, Fly.io&lt;/li&gt;
&lt;/ol&gt;



&lt;p&gt;The Ultimate Test&lt;/p&gt;

&lt;p&gt;Break something on purpose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Add this to index.js – a hidden bug&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/broken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oops&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// This will crash the server&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push it. Watch the pipeline deploy it (tests passed, right?). Then visit /broken and watch it fail.&lt;/p&gt;

&lt;p&gt;Now fix it. Push again. Watch the pipeline fix production automatically.&lt;/p&gt;

&lt;p&gt;That's the power of CI/CD. You're not afraid to deploy anymore. Because if something breaks, you fix it and push again. No panic. No Friday deploys. Just code.&lt;/p&gt;




&lt;p&gt;Your 10-Minute Challenge Recap&lt;/p&gt;

&lt;p&gt;· Created an Express app&lt;br&gt;
· Pushed to GitHub&lt;br&gt;
· Created .github/workflows/deploy.yml&lt;br&gt;
· Signed up for Render&lt;br&gt;
· Added API keys as GitHub Secrets&lt;br&gt;
· Made a change and watched the pipeline run&lt;/p&gt;

&lt;p&gt;You did it. 🎉&lt;/p&gt;

&lt;p&gt;Now go add CI/CD to your real project. Your future self (and your team) will thank you.&lt;/p&gt;




&lt;p&gt;What stack do you want to see a CI/CD example for next? Drop a comment (Django, Spring Boot, Next.js, Go, Rust...).&lt;/p&gt;

&lt;p&gt;Follow for more DevOps-for-beginners content.&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>devops</category>
      <category>githubactions</category>
    </item>
    <item>
      <title>🚪 Authentication vs. Authorization – The Bouncer Analogy (Clear up the confusion forever)</title>
      <dc:creator>MysticMc</dc:creator>
      <pubDate>Thu, 02 Apr 2026 19:36:53 +0000</pubDate>
      <link>https://dev.to/nazmur96/authentication-vs-authorization-the-bouncer-analogy-clear-up-the-confusion-forever-5118</link>
      <guid>https://dev.to/nazmur96/authentication-vs-authorization-the-bouncer-analogy-clear-up-the-confusion-forever-5118</guid>
      <description>&lt;p&gt;I can't tell you how many times I've seen these two words used interchangeably.&lt;/p&gt;

&lt;p&gt;Even experienced developers sometimes slip up:&lt;/p&gt;

&lt;p&gt;"We need to add Google Auth so users can authorize with their email."&lt;/p&gt;

&lt;p&gt;No. That's authentication.&lt;/p&gt;

&lt;p&gt;"The JWT token authenticates whether the user is an admin."&lt;/p&gt;

&lt;p&gt;No. That's authorization.&lt;/p&gt;

&lt;p&gt;They sound similar. They work together. But they are not the same thing.&lt;/p&gt;

&lt;p&gt;And mixing them up leads to security holes, confused code, and embarrassing bugs.&lt;/p&gt;

&lt;p&gt;Here's the one analogy that makes it stick forever.&lt;/p&gt;




&lt;p&gt;The Bouncer Analogy 🚪&lt;/p&gt;

&lt;p&gt;Imagine you're at a nightclub.&lt;/p&gt;

&lt;p&gt;Step 1: Authentication (Getting past the front door)&lt;/p&gt;

&lt;p&gt;You walk up to the bouncer. He asks:&lt;/p&gt;

&lt;p&gt;"Do you have an ID?"&lt;/p&gt;

&lt;p&gt;You show your driver's license. He checks the photo. He scans it. He confirms:&lt;/p&gt;

&lt;p&gt;"Okay, you are who you say you are. You're on the guest list. Come in."&lt;/p&gt;

&lt;p&gt;That's authentication. You proved your identity. You're in the club.&lt;/p&gt;

&lt;p&gt;Authentication answers: "Are you who you claim to be?"&lt;/p&gt;




&lt;p&gt;Step 2: Authorization (Getting into VIP)&lt;/p&gt;

&lt;p&gt;Now you're inside the club. You see the VIP section – better drinks, better view, actual seats that aren't sticky.&lt;/p&gt;

&lt;p&gt;You try to walk in. Another bouncer stops you:&lt;/p&gt;

&lt;p&gt;"Whoa there. This is VIP. Do you have a wristband?"&lt;/p&gt;

&lt;p&gt;You show your black wristband (which you paid $500 for). He checks it and says:&lt;/p&gt;

&lt;p&gt;"Cool. You're authorized. Go ahead."&lt;/p&gt;

&lt;p&gt;That's authorization. Your identity is already confirmed. Now we're checking what you're allowed to do.&lt;/p&gt;

&lt;p&gt;Authorization answers: "Are you allowed to do this specific thing?"&lt;/p&gt;




&lt;p&gt;The Table That Finally Makes It Click&lt;/p&gt;

&lt;p&gt;Authentication Authorization&lt;br&gt;
Question it answers "Who are you?" "What can you do?"&lt;br&gt;
When it happens First (at login) After (on each request)&lt;br&gt;
What it proves Identity Permissions&lt;br&gt;
How it works Passwords, biometrics, security keys Roles, permissions, policies&lt;br&gt;
Tells you "You are Bob" "Bob can delete posts"&lt;br&gt;
Bouncer analogy Checking your ID at the door Checking your VIP wristband&lt;br&gt;
HTTP Status Code 401 Unauthorized (ironically named) 403 Forbidden&lt;/p&gt;

&lt;p&gt;Side note: Yes, HTTP 401 says "Unauthorized" but actually means "unauthenticated." It's a historical mistake that confuses everyone. Just remember: 401 = Login first. 403 = You're logged in but not allowed.&lt;/p&gt;



&lt;p&gt;Real Web Examples&lt;/p&gt;

&lt;p&gt;Example 1: Logging into Gmail&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Authentication: You type your email + password. Google checks it's really you. (Success → you get a session cookie or JWT token)&lt;/li&gt;
&lt;li&gt;Authorization: You try to delete an email. Google checks: "Does this user have 'delete' permission for this email?" (Yes, it's your own email)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Same user, same login, but authorization happens on every single action.&lt;/p&gt;



&lt;p&gt;Example 2: Google Drive sharing&lt;/p&gt;

&lt;p&gt;· Authentication: You log into your Google account.&lt;br&gt;
· Authorization: You try to open a shared document. Google checks: "Is this user on the 'can view' list?" If yes → authorized. If no → 403 error.&lt;/p&gt;

&lt;p&gt;You are authenticated (Google knows it's you), but not authorized (you don't own that doc).&lt;/p&gt;



&lt;p&gt;Example 3: Admin dashboard&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Authentication: Did the user log in?&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please log in first&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Authorization: Is the logged-in user an admin?&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Admins only&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// If we reach here, user is BOTH authenticated AND authorized&lt;/span&gt;
&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome to the admin panel&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the difference? Two checks, two different purposes.&lt;/p&gt;




&lt;p&gt;The Technologies (What actually powers authN and authZ)&lt;/p&gt;

&lt;p&gt;Now let's connect the theory to the actual code you'll write.&lt;/p&gt;

&lt;p&gt;Authentication Technologies (Proving who you are)&lt;/p&gt;

&lt;p&gt;Technology What it does When to use&lt;br&gt;
Passwords + Hash (bcrypt) User provides secret; you compare hashed version Most apps (standard)&lt;br&gt;
JWT (JSON Web Token) Encoded token containing user ID + signature Stateless APIs, mobile apps&lt;br&gt;
Sessions (with cookies) Server stores user data; cookie acts as key Traditional web apps (Rails, PHP, Node with express-session)&lt;br&gt;
OAuth 2.0 "Login with Google/GitHub/Facebook" Letting third parties prove identity&lt;br&gt;
Biometrics Fingerprint, FaceID, passkeys Mobile apps, high-security&lt;br&gt;
2FA / MFA Password + one-time code from phone Any app with sensitive data&lt;/p&gt;

&lt;p&gt;Authentication result: You get a credential (session cookie, JWT token, API key) that you send with every subsequent request.&lt;/p&gt;



&lt;p&gt;Authorization Technologies (What you're allowed to do)&lt;/p&gt;

&lt;p&gt;Technology What it does When to use&lt;br&gt;
RBAC (Role-Based Access Control) Users have roles (admin, editor, viewer); roles have permissions Most business apps (simplest)&lt;br&gt;
ABAC (Attribute-Based Access Control) Permissions based on attributes (time of day, user location, resource owner) Complex systems (healthcare, finance)&lt;br&gt;
ACL (Access Control Lists) Each resource has a list of who can access it File systems, legacy apps&lt;br&gt;
Policies (Casbin, OPA) Declarative rules: "user can edit post if user.id == post.authorId" Fine-grained permissions&lt;/p&gt;

&lt;p&gt;Authorization result: A yes/no answer for each action. No tokens. Just logic.&lt;/p&gt;



&lt;p&gt;The Confusion: JWT, Sessions, Cookies, localStorage&lt;/p&gt;

&lt;p&gt;This is where beginners get lost. Let me untangle it.&lt;/p&gt;

&lt;p&gt;What stores your authentication state?&lt;/p&gt;

&lt;p&gt;After you log in, you need to remember that you're authenticated for future requests.&lt;/p&gt;

&lt;p&gt;Option 1: Sessions (Server-side)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. You log in.
2. Server creates a session record in its database (or Redis).
3. Server sends you a cookie containing a session ID.
4. You send that cookie with every request.
5. Server looks up the session ID to know who you are.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Option 2: JWT (Client-side)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. You log in.
2. Server creates a JWT token (contains your user ID, expiration, signature).
3. Server sends you the token.
4. You store it in localStorage or an HTTP-only cookie.
5. You send the token in the Authorization header with every request.
6. Server verifies the signature (no database lookup needed).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which one should you use?&lt;/p&gt;

&lt;p&gt;Sessions JWT&lt;br&gt;
Where is data stored? Server (database/Redis) Client (token itself)&lt;br&gt;
Can you revoke instantly? ✅ Yes (delete session from DB) ❌ No (token valid until expiration)&lt;br&gt;
Scales how? Need shared session store (Redis) Stateless (any server can verify)&lt;br&gt;
Best for... Traditional web apps Mobile apps, microservices, SPAs&lt;/p&gt;

&lt;p&gt;My advice for beginners: Start with sessions + HTTP-only cookies. It's simpler and more secure by default. Move to JWT only when you have a reason (e.g., mobile app, separate API server).&lt;/p&gt;



&lt;p&gt;localStorage vs. cookies (Security warning!)&lt;/p&gt;

&lt;p&gt;This is critical.&lt;/p&gt;

&lt;p&gt;Storage method Accessible by JavaScript? Vulnerable to XSS? HttpOnly option?&lt;br&gt;
localStorage ✅ Yes (any script can read it) ❌ Yes (high risk) ❌ No&lt;br&gt;
Regular cookie ✅ Yes ❌ Yes ❌ No&lt;br&gt;
HttpOnly cookie ❌ No (JS cannot read it) ✅ No (much safer) ✅ Yes&lt;/p&gt;

&lt;p&gt;Rule of thumb:&lt;/p&gt;

&lt;p&gt;· Never store authentication tokens in localStorage if you care about security. Any XSS vulnerability = attacker steals every user's token.&lt;br&gt;
· Use HttpOnly cookies for sessions or JWTs. They can't be read by JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// BAD (vulnerable to XSS)&lt;/span&gt;
&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;token&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;userJWT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// GOOD (more secure)&lt;/span&gt;
&lt;span class="c1"&gt;// Set cookie on server with:&lt;/span&gt;
&lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Cookie&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;xyz&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;HttpOnly&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;Secure&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;SameSite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;Strict&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;OAuth 2.0 – The special case&lt;/p&gt;

&lt;p&gt;OAuth is often called "authentication," but that's not quite right.&lt;/p&gt;

&lt;p&gt;OAuth is actually authorization that implies authentication.&lt;/p&gt;

&lt;p&gt;Here's how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You click "Login with Google."&lt;/li&gt;
&lt;li&gt;Google asks: "This app wants to see your email and name. Allow?"&lt;/li&gt;
&lt;li&gt;You say yes.&lt;/li&gt;
&lt;li&gt;Google tells your app: "This user is &lt;a href="mailto:bob@gmail.com"&gt;bob@gmail.com&lt;/a&gt;" (authentication info) AND "Here's a token to access their Google Drive" (authorization).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;OAuth solves: "Let me prove who I am without giving you my password, and also let me give you limited access to my data."&lt;/p&gt;

&lt;p&gt;Common confusion: People call OAuth "social login" (authentication), but OAuth was designed for delegated authorization (like "let this app post to my Twitter"). The login part is a bonus.&lt;/p&gt;




&lt;p&gt;Common Real-World Scenarios&lt;/p&gt;

&lt;p&gt;Scenario 1: You're logged into Netflix but can't watch a specific movie&lt;/p&gt;

&lt;p&gt;· Authentication: ✅ You logged in. Netflix knows it's you.&lt;br&gt;
· Authorization: ❌ Your plan doesn't include that movie (or it's region-locked).&lt;/p&gt;

&lt;p&gt;Error message: "This title is not available in your region." (403 Forbidden)&lt;/p&gt;



&lt;p&gt;Scenario 2: You try to delete a comment on Reddit that isn't yours&lt;/p&gt;

&lt;p&gt;· Authentication: ✅ You're logged in.&lt;br&gt;
· Authorization: ❌ You didn't write that comment.&lt;/p&gt;

&lt;p&gt;Error message: "You cannot delete this comment." (403)&lt;/p&gt;



&lt;p&gt;Scenario 3: You open a private GitHub repo without logging in&lt;/p&gt;

&lt;p&gt;· Authentication: ❌ GitHub has no idea who you are.&lt;br&gt;
· Authorization: ⏸️ Not even checked because you're not authenticated.&lt;/p&gt;

&lt;p&gt;Error message: "Not Found" (404 – GitHub does this on purpose to hide private repos exist). But technically it's a 401.&lt;/p&gt;



&lt;p&gt;The 5-Minute Implementation (Node.js + Express)&lt;/p&gt;

&lt;p&gt;Here's a minimal example showing both concepts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Fake database&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;alice@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;alice123&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bob@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bob123&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;viewer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Post 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;authorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Post 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;authorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// ---------- AUTHENTICATION ----------&lt;/span&gt;
&lt;span class="c1"&gt;// Login endpoint – proves who you are&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="c1"&gt;// 401 = unauthenticated&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Create a session (in real life, use express-session)&lt;/span&gt;
  &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Logged in!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Check authentication middleware&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Please log in first&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ---------- AUTHORIZATION ----------&lt;/span&gt;
&lt;span class="c1"&gt;// Check authorization middleware (role-based)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Admins only&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="c1"&gt;// 403 = forbidden&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Check authorization (ownership)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isOwner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;postId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;postId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authorId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You can only edit your own posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ---------- ROUTES ----------&lt;/span&gt;
&lt;span class="c1"&gt;// Anyone can view (no authentication needed)&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Authenticated only (any logged-in user)&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Create a new post&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Post created&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Authorization: must be admin OR owner&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/posts/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isOwner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Post updated&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Authorization: admin only&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/posts/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isAdmin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Post deleted&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the pattern?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Authentication happens first (isAuthenticated).&lt;/li&gt;
&lt;li&gt;Authorization happens second (isAdmin, isOwner).&lt;/li&gt;
&lt;li&gt;You can be authenticated but not authorized (403).&lt;/li&gt;
&lt;li&gt;You can be neither (401).&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;The Security Checklist&lt;/p&gt;

&lt;p&gt;When building auth, use this mental checklist:&lt;/p&gt;

&lt;p&gt;Question Check&lt;br&gt;
Are passwords hashed with bcrypt (not plain text)? ☐&lt;br&gt;
Is HTTPS enabled everywhere? ☐&lt;br&gt;
Are session cookies marked HttpOnly + Secure? ☐&lt;br&gt;
Do you have rate limiting on login attempts? ☐&lt;br&gt;
Does every protected endpoint check authentication FIRST? ☐&lt;br&gt;
Does every sensitive endpoint check authorization SECOND? ☐&lt;br&gt;
Are you using the correct HTTP status codes (401 vs 403)? ☐&lt;br&gt;
Are JWT tokens (if used) stored in HttpOnly cookies, not localStorage? ☐&lt;/p&gt;



&lt;p&gt;Quick Reference Card (Save This)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────────┐
│  AUTHENTICATION                     AUTHORIZATION           │
│  "Who are you?"                     "What can you do?"      │
│                                                             │
│  First (login)                      After (every action)    │
│  Passwords, JWT, OAuth              Roles, permissions      │
│  HTTP 401 (Unauthorized)            HTTP 403 (Forbidden)    │
│                                                             │
│  Bouncer at the door 🚪             Bouncer at VIP 🎟️        │
│  "Show ID"                           "Show wristband"       │
└─────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Your Turn&lt;/p&gt;

&lt;p&gt;Go check your own code (or a project you're working on):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do you have endpoints that check authentication?&lt;/li&gt;
&lt;li&gt;Do you have separate checks for authorization?&lt;/li&gt;
&lt;li&gt;Are you using 401 vs 403 correctly?&lt;/li&gt;
&lt;li&gt;Are your tokens in localStorage? (Move them if yes!)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Leave a comment with your biggest "aha moment" or your worst auth-related bug story.&lt;/p&gt;

&lt;p&gt;Follow for more security deep dives (next up: JWT vs. Sessions – which one actually wins?)&lt;/p&gt;




&lt;p&gt;TL;DR: Authentication = proving you're you (login). Authorization = proving you're allowed to do the thing (permissions). One happens first, one happens on every request. Mix them up and hackers win.&lt;/p&gt;

</description>
      <category>authentication</category>
      <category>authorization</category>
      <category>security</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
