ganesh
Ganesh Angadi
By Ganesh AngadiDEV

Journey of Your Code: From Laptop to Production

#devops#ci-cd#gitops#kubernetes#observability

When you’re developing locally, life is straightforward. You write some code, hit save, run npm run dev or go run main.go, and your browser hits localhost:3000. If it works, you celebrate.

But localhost is a sterile environment. It has direct access to your local CPU, a single mock database running on your machine, and no network latency or firewall rules to worry about. Production is a completely different beast—it's a distributed, volatile environment where things fail constantly, pods get rescheduled, and multiple instances of your app need to run in parallel.

So, how does a line of code written on your mechanical keyboard actually make it onto an AWS EKS cluster and start serving real user traffic?

Let’s trace the journey step-by-step.

✦ ✦ ✦

Step 1: The Hand-Off (Local to Version Control)

You finish a feature, run your local tests, and type the magic words:

git add . git commit -m "feat: implement user session cleanup" git push origin feature/session-cleanup

The moment you push your code, the responsibility shifts from your laptop to your version control provider (like GitHub). In a standard professional setup, you don’t merge directly into main. Instead, you open a Pull Request (PR).

This PR is the first gatekeeper. Before anyone even looks at your code, a Continuous Integration (CI) pipeline (usually powered by GitHub Actions) triggers. It spins up a temporary runner and runs:

  1. ▹Linters: To make sure you didn't leave weird formatting or unused variables.
  2. ▹Static Analysis/Security Scans: Checking for leaked API keys or obvious vulnerabilities.
  3. ▹Unit Tests: To prove your new feature doesn't break existing business logic.

If any of these checks fail, the pipeline goes red, and the merge button is blocked. Once they pass, a peer reviews your code, clicks approve, and you merge the PR into main.

✦ ✦ ✦

Step 2: Packaging the Code (Building the Artifact)

Now that your code is on the main branch, it needs to be packaged. Your raw JavaScript, Python, or Go files can't run directly in the cloud; they need to be packaged into a standard unit of execution.

Another GitHub Actions pipeline triggers. Its job is to turn your code into a Container Image (usually Docker).

Here is what that look like behind the scenes:

  1. ▹The pipeline fetches a base environment (like Node or Alpine Linux).
  2. ▹It copies your code files into the builder.
  3. ▹It installs production dependencies and compiles your app (if it’s a compiled language).
  4. ▹It compresses the result into a light, layered container image.

The Importance of Tagging

Once the image is built, it needs a name and a version tag.

[!WARNING] Never use the :latest tag in production. If you deploy an image tagged :latest, Kubernetes has no idea if the image on the node is actually the newest version or a cached older one. It makes rollbacks impossible and destroys deployment predictability.

Instead, we tag the image with a unique identifier—usually the Git Commit SHA (e.g., my-app:a1b2c3d) or a semantic version tag (my-app:v1.2.4).

Once tagged, GitHub Actions pushes this image to a secure registry, like AWS Elastic Container Registry (ECR). Your code is now a packaged artifact, resting in a cloud registry, waiting to be summoned.

✦ ✦ ✦

Step 3: The GitOps Pull Model (Reconciliation)

This is where the magic happens. How does our EKS cluster in AWS find out that a new image exists in ECR?

There are two ways to do this: the Push Model and the Pull Model (GitOps). We're focusing on the Pull Model, which is the modern industry standard for managing Kubernetes.

Why not just run kubectl apply from GitHub Actions?

In a push model, GitHub Actions would hold a secret AWS credential, authenticate with your EKS cluster, and run kubectl apply -f deployment.yaml directly.

This is a security risk. It means your CI provider (a third-party platform) has full root access to write to your production cluster. If your GitHub account is compromised, your entire infrastructure is compromised. It also requires you to open up your EKS control plane to the public internet so GitHub can reach it.

Enter GitOps and the Reconciliation Loop

In the Pull Model, we use a GitOps agent like ArgoCD or Flux running inside our EKS cluster.

Here is the setup:

  1. ▹We have a separate Git repository, often called the Config/Infrastructure Repo. This repo contains nothing but Kubernetes manifest files (YAMLs describing our deployments, services, and ingress rules).
  2. ▹When the CI pipeline finishes pushing the new Docker image (e.g., my-app:a1b2c3d) to ECR, it triggers a lightweight step that goes to our Config Repo and updates the deployment YAML file, changing the image tag from the old version to a1b2c3d.
  3. ▹The GitOps Controller (ArgoCD) inside the EKS cluster is continuously watching that Config Repo (usually polling every 30 seconds or listening to a git webhook).
  4. ▹ArgoCD detects a difference:
    • ▹Desired State (Git): Run image my-app:a1b2c3d
    • ▹Live State (EKS): Running image my-app:old-tag
  5. ▹The controller triggers a Reconciliation. It tells the Kubernetes API Server: "Update the Deployment resource to use the new image version a1b2c3d."

The security beauty of this? The cluster pulls the change from the inside out. No credentials leave your AWS VPC, and your cluster's API server remains locked down.

✦ ✦ ✦

Step 4: Spawning the Container (Kubelet takes over)

Once the API Server receives the update, the Kubernetes control plane determines which worker nodes should host the updated pods.

The Kubelet (the agent running on every worker node) gets a notification: "You need to run a pod with container image my-app:a1b2c3d."

Here is the final execution sequence:

  1. ▹Authentication: The Kubelet needs permission to pull the image from your private ECR registry. Since the EKS node is configured with an IAM Role (using IAM Roles for Service Accounts, or IRSA), it automatically authenticates with ECR using AWS credentials.
  2. ▹Image Pull: Kubelet reaches out to ECR, downloads the new container layers, and stores them on the node's local disk.
  3. ▹CRI Spawn: Kubelet talks to the Container Runtime Interface (CRI) on the node (like containerd) and commands it to spawn the container.
  4. ▹Graceful Switchover: Kubernetes starts the new pod. Once the new pod passes its configured readiness probes (proving it's ready to handle traffic), the ingress routes traffic to the new container. Only then is the old container gracefully terminated and removed.

Your code is officially alive, running inside an AWS container, serving requests.

✦ ✦ ✦

What's Next?

We successfully traced the route from code push to EKS reconciliation. But how do we structure our branches to support this without code collisions? In the next part of this series, we will dive into Git branching models, staging environments, and explain why environment !== branch.

Stay tuned.

Written by Ganesh Angadi

Systems engineer · distributed systems, cloud, networking & DevOps

Portfolio HomeGitHub ProfileLinkedIn ConnectDev.to Profile

Leave a note

Thoughts, corrections, or just saying hi — all welcome.