Deployments for Stateless Apps
Use Deployments to manage stateless applications, enabling rolling updates and rollbacks.
Deployments for Stateless Apps is a free Docker & DevOps Fundamentals lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Docker & DevOps Fundamentals learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Meet Kubernetes Deployments
Welcome to a fundamental concept in Kubernetes: Deployments! They are your go-to resource for managing stateless applications.
Think of a Deployment as a blueprint for your application. It tells Kubernetes how many copies (replicas) of your app you want running and how to update them without downtime.

Beyond Pods and ReplicaSets
You've learned about Pods (the smallest unit) and ReplicaSets (ensuring a certain number of Pods).
A Deployment sits on top of a ReplicaSet. It provides a higher-level abstraction for:
- Creating and updating ReplicaSets.
- Rolling out new versions of your application.
- Rolling back to previous versions if something goes wrong.
This makes managing your applications much easier and safer.
Inside a Deployment YAML
Like other Kubernetes resources, Deployments are defined using YAML. Let's look at the basic structure:
apiVersion: Specifies the Kubernetes API version (e.g.,apps/v1).kind: AlwaysDeploymentfor a Deployment resource.metadata: Contains information like the Deployment'snameand optionallabels.
These fields help Kubernetes identify and organize your deployments.
Specifying Replicas & Template
The heart of a Deployment is its spec section. Here, you define:
replicas: The desired number of identical Pods for your application.selector: How the Deployment finds the Pods it manages (using labels).template: This is essentially a Pod definition, describing the containers, volumes, etc., for each Pod.
The template is what the Deployment uses to create new Pods.
Our Nginx Deployment
Here's a simple Deployment manifest for an Nginx web server. This tells Kubernetes to keep 3 Nginx Pods running.
Try to understand each part!
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80Creating Your Deployment
Once you have your Deployment YAML file (e.g., nginx-deployment.yaml), you can create the Deployment in your Kubernetes cluster using the kubectl apply command.
Kubernetes will then ensure the desired number of Pods are created and maintained.
kubectl apply -f nginx-deployment.yamlYou can check its status with:
kubectl get deploymentsScaling Up & Down
Need more or fewer instances of your application? Deployments make scaling easy! You can adjust the replicas field in your YAML and re-apply, or use a direct command:
kubectl scale deployment nginx-deployment --replicas=5This command will instantly tell your Deployment to create 2 more Nginx Pods, bringing the total to 5.
Zero-Downtime Updates
One of the biggest benefits of Deployments is their ability to perform rolling updates. When you update the Pod template (e.g., change the image version), Kubernetes doesn't shut down all old Pods at once.
Instead, it gradually replaces old Pods with new ones, ensuring your application remains available throughout the update process.
kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1Rolling Back with Ease
Made a mistake in an update? No worries! Deployments keep a history of your revisions, allowing you to easily revert to a previous, stable version.
This is called a rollback and it's a crucial safety net for deployments.
kubectl rollout undo deployment/nginx-deploymentYou can also check the history with kubectl rollout history deployment/nginx-deployment.
Deployment Quiz Time
A developer updates an Nginx Deployment from image nginx:1.14.2 to nginx:1.16.1. What is the primary benefit of using a Kubernetes Deployment for this update?
Deployments: Key Takeaways
Great job! You've learned about Kubernetes Deployments, a powerful resource for managing your stateless applications.
- Deployments manage ReplicaSets, which in turn manage Pods.
- They define the desired state, including the number of
replicas. - Key features include easy scaling, rolling updates for zero-downtime, and straightforward rollbacks to previous versions.
Next, we'll explore Services to expose your applications!
Frequently asked questions
Is the “Deployments for Stateless Apps” lesson free?
Yes — the full text of “Deployments for Stateless Apps” is free to read here on the web, and the Docker & DevOps Fundamentals course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Docker & DevOps Fundamentals course, upgrade to CoddyKit PRO.
What will I learn in “Deployments for Stateless Apps”?
Use Deployments to manage stateless applications, enabling rolling updates and rollbacks. You practise Docker & DevOps Fundamentals with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Docker & DevOps Fundamentals?
No prior experience is required. Docker & DevOps Fundamentals on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Deployments for Stateless Apps” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Docker & DevOps Fundamentals lesson?
Yes. Every Docker & DevOps Fundamentals lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Deployments for Stateless Apps
- Services for Network Access
- ConfigMaps & Secrets
- Ingress and External Routing