Deploying Your First Application

Introduction: From Cluster to Running Application

You've successfully created an EKS cluster, but it's currently empty. This lesson will guide you through deploying your first containerized application. You'll learn to write a Deployment manifest, a YAML file that declaratively tells Kubernetes how to run your application. This manifest specifies the container image, the number of copies to run, resource allocation, and health checks.

In Kubernetes, you don't run containers manually. Instead, you declare your desired state in a manifest, and Kubernetes works to maintain that state. If a container crashes, Kubernetes automatically restarts it. This declarative approach is what makes Kubernetes powerful and reliable for production applications. By the end of this lesson, you'll have a web application running on your EKS cluster, and you'll understand the fundamental workflow for deploying any containerized application.

Understanding Kubernetes Deployments

A Deployment is a Kubernetes resource that manages a set of identical Pods. Before we go further, let's clarify what a Pod is. A Pod is the smallest deployable unit in Kubernetes, and it contains one or more containers that share networking and storage. In most cases, a Pod contains just one container, which is your application. When you create a Deployment, Kubernetes creates Pods based on the template you provide and ensures that the desired number of Pods are always running.

The reason we use Deployments instead of creating Pods directly is that Deployments provide several critical features. First, they handle replication, meaning you can easily run multiple copies of your application for high availability and load distribution. Second, they provide self-healing capabilities. If a Pod crashes or a node fails, the Deployment automatically creates replacement Pods. Third, they enable rolling updates, which means you can update your application to a new version without downtime by gradually replacing old Pods with new ones. Fourth, they maintain a history of your deployments, allowing you to roll back to a previous version if something goes wrong.

When you create a Deployment, you specify how many replicas you want. A replica is simply a copy of your Pod. If you set replicas to 3, Kubernetes will ensure that exactly three Pods are running at all times. If one Pod crashes, Kubernetes immediately creates a new one to maintain the desired count. If you manually delete a Pod, Kubernetes replaces it. This automatic management is what makes Kubernetes reliable for production workloads.

The Deployment also acts as a controller that continuously monitors the actual state of your Pods and compares it to the desired state you declared in your manifest. If there's a difference, the Deployment takes action to reconcile them. This control loop is fundamental to how Kubernetes operates. You declare what you want, and Kubernetes figures out how to make it happen and keep it that way.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal