Feedback

Chat Icon

Cloud-Native Microservices With Kubernetes - 2nd Edition

A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

Deploying Stateless Microservices: Introduction
20%

Pods, ReplicaSets, and Deployments

In Kubernetes, we don't run containers directly. Instead, we use a higher-level abstraction called a Pod. A Pod is the smallest and simplest unit in the Kubernetes object model, and it represents a single instance of a running process in the cluster. A Pod can contain one or more containers, which are guaranteed to run together on the same host and share the same network and storage resources (think of it as a logical host for one or more containers).

In the same fashion, when we want to deploy a Pod, we don't create it directly. Instead, a higher-level object called a ReplicaSet is used to manage its lifecycle. A ReplicaSet ensures that a specified number of Pod replicas are running at any given time. If a Pod crashes or is deleted, the ReplicaSet automatically creates a new one to maintain the desired number of replicas.

You won't be surprised to learn that we don't create ReplicaSets directly either. We use an even higher-level object called a Deployment.

This resource provides declarative updates for the Pods. In addition to managing ReplicaSets, a Deployment provides a way to do rolling updates and rollbacks of the underlying Pod template.

This is the typical hierarchy of objects in Kubernetes:

Deployment -> ReplicaSet ->

Cloud-Native Microservices With Kubernetes - 2nd Edition

A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes

Enroll now to unlock all content and receive all future updates for free.