CareerByteCode
ByteBlogby CareerByteCode

How Pods, ReplicaSets and Deployments Work Together

🟢 Beginner

See how Kubernetes Deployments, ReplicaSets and Pods work together through a Minikube lab on scaling, self-healing, updates and troubleshooting.

How Pods, ReplicaSets and Deployments Work Together

✍️ Translate this blog into Hindi, Tamil or Telugu

Introduction

In our previous Kubernetes articles, we learned about Pods, ReplicaSets and Deployments individually.

But how do these three Kubernetes objects work together?

Imagine you are running a food delivery application. Your application needs to stay available even when a Pod fails. It should also handle more users when traffic increases, and you should be able to update the application without stopping everything.

🛍️✨ From the author · ByteStore1:1 DevOps Project & Learning Discussionโ‚น500View offer →

This is where Pods, ReplicaSets and Deployments work together.

Let's connect these three objects and see how they work together in a hands-on Minikube lab.

We will learn how to:

  • Understand the relationship between Pods, ReplicaSets and Deployments.

  • Create a Deployment using YAML.

  • Inspect the ReplicaSet and Pods created by a Deployment.

  • Understand labels, selectors and ownership.

  • Scale an application from three to five replicas.

  • Delete a Pod and observe automatic replacement.

  • Perform a rolling update and rollback.

  • Troubleshoot common Kubernetes problems.

1. Why Do We Need Pods, ReplicaSets and Deployments Together?

Let's understand the problem first.

Suppose we have a food delivery application running inside a single Pod.

What happens if that Pod gets deleted?

Our application may become unavailable.

What happens when more users start accessing the application?

A single Pod may not be enough to handle the increased workload.

What happens when we want to update the application to a newer version?

We need a way to manage these changes safely.

Kubernetes solves these problems using three important objects.

Kubernetes objectMain responsibility
PodRuns the application container.
ReplicaSetMaintains the required number of identical Pods.
DeploymentManages ReplicaSets and provides scaling, rolling updates and rollbacks.

Think of them as a team:

  • Pod: Does the actual application work.

  • ReplicaSet: Makes sure the required number of Pods are running.

  • Deployment: Manages the ReplicaSet and controls application updates.

2. How Do Pods, ReplicaSets and Deployments Work Together?

The relationship looks like this:

Kubernetes architecture diagram

Let's understand each relationship.

Deployment โ†’ ReplicaSet

A Deployment creates and manages a ReplicaSet.

For example, when we create a Deployment with three replicas, the Deployment controller creates a ReplicaSet to maintain three Pods.

ReplicaSet โ†’ Pods

The ReplicaSet creates Pods based on the Pod template defined in the Deployment.

It continuously checks whether the required number of Pods exists.

If a Pod is deleted, the ReplicaSet creates a replacement.

What happens during an application update?

When we change the container image in a Deployment, Kubernetes creates a new ReplicaSet for the updated Pod template.

The Deployment controller gradually replaces Pods managed by the old ReplicaSet with Pods managed by the new ReplicaSet.

This process is called a rolling update.

3. Understand Labels and Selectors

Before starting the practical lab, let's understand two important Kubernetes concepts: labels and selectors.

What is a label?

A label is a key-value pair attached to a Kubernetes object.

For example:

labels:
  app: food-app

Here:

  • app is the label key.

  • food-app is the label value.

Labels help us identify and organize Kubernetes objects.

What is a selector?

A selector is used to find Kubernetes objects that match specific labels.

For example:

selector:
  matchLabels:
    app: food-app

This tells Kubernetes to select Pods with the label app: food-app.

Why are labels and selectors important?

A ReplicaSet uses a selector to identify the Pods it should maintain.

The selector must match the labels in the Pod template.

For example:

selector:
  matchLabels:
    app: food-app

template:
  metadata:
    labels:
      app: food-app

Notice that both use the same label.

In apps/v1, the Deployment's selector must match the labels in the Pod template. If they do not match, the API server rejects the manifest with a validation error similar to:

selector does not match template labels

Kubernetes also adds a pod-template-hash label to each ReplicaSet and to the Pods it creates. This helps distinguish Pods that belong to different ReplicaSets during a Deployment update.

Kubernetes Labels and Selectors

4. What Is OwnerReference?

Kubernetes also maintains ownership information between related objects.

This is called an OwnerReference.

For our application:

  • The Deployment is the owner of the ReplicaSet.

  • The ReplicaSet is the owner of the Pods.

We can inspect this relationship using:

kubectl get rs -l app=food-app \
  -o jsonpath='{.items[0].metadata.ownerReferences[0].kind}{"\n"}'

Expected output:

Deployment

This tells us that the selected ReplicaSet is owned by a Deployment.

Now check the Pods:

kubectl get pods -l app=food-app \
  -o custom-columns=NAME:.metadata.name,OWNER:.metadata.ownerReferences[0].kind

Note: Some columns have been omitted from the sample outputs for readability. Actual kubectl get output may also include columns such as AGE.

Expected output:

NAME                       OWNER
food-app-5754744b8-c2nr9   ReplicaSet
food-app-5754744b8-h89c9   ReplicaSet
food-app-5754744b8-jb4sr   ReplicaSet

Pod names follow the pattern food-app-<replicaset-hash>-<pod-suffix>, and the exact values will be different in your cluster.

This confirms that the Pods are owned by a ReplicaSet.

Remember:

Labels and selectors help Kubernetes find matching objects. OwnerReferences record which controller owns an object. They are related concepts, but they are not the same thing.

Kubernetes OwnerReference Relationship

5. What Happens When We Create a Deployment?

Let's understand the workflow.

When we create a Deployment, Kubernetes performs several operations.

  1. We submit the Deployment YAML to the Kubernetes API server.

  2. The Deployment controller notices the new Deployment.

  3. The Deployment controller creates a ReplicaSet.

  4. The ReplicaSet controller creates the required Pods.

  5. The scheduler assigns the Pods to suitable nodes.

  6. The kubelet on each assigned node starts the containers.

  7. Kubernetes continuously monitors the desired and actual state.

For example, if we specify:

replicas: 3

Kubernetes tries to maintain three Pods.

If one Pod is deleted, the ReplicaSet notices the difference and creates another Pod.

Now let's see this in action.


6. Hands-On Lab: Pods, ReplicaSets and Deployments

In this lab, we will create a Deployment called food-app using an NGINX container.

Lab environment

ItemValue
ToolMinikube
Namespacedefault
Deploymentfood-app
Containernginx
Initial imagenginx:1.27-alpine
Initial replicas3

Step 1: Check Minikube status

Before creating Kubernetes resources, check whether Minikube is running.

minikube status

Check your current Kubernetes context:

kubectl config current-context

Expected context:

minikube

If Minikube is stopped, start it:

minikube start

minikube

What are we checking?

We want to make sure our local Kubernetes cluster is available before creating resources.

Step 2: Create a Deployment YAML file

Create a file:

nano food-app-deployment.yaml

Add the following YAML:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: food-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: food-app
  template:
    metadata:
      labels:
        app: food-app
    spec:
      containers:
        - name: nginx
          image: nginx:1.27-alpine
          ports:
            - containerPort: 80

Save the file.

Create a Deployment YAML file

Let's understand the important fields.

FieldPurpose
apiVersion: apps/v1Uses the Kubernetes apps API.
kind: DeploymentCreates a Deployment object.
metadata.nameNames the Deployment food-app.
replicas: 3Requests three Pods.
selector.matchLabelsSelects Pods with the matching label.
templateDefines how the Pods should be created.
containersDefines the container inside each Pod.
imageUses the NGINX container image.
containerPort: 80Documents the container's application port.

Important: containerPort: 80 does not expose the application outside the Pod. We will learn how to expose applications using Kubernetes Services in the next article.

Step 3: Create the Deployment

Apply the YAML file:

kubectl apply -f food-app-deployment.yaml

Expected output:

deployment.apps/food-app created

What does this command do?

  • kubectl is the Kubernetes command-line tool.

  • apply creates or updates a Kubernetes resource.

  • -f specifies the YAML file to use.

We have now created the Deployment.

Create and check the Deployment

Step 4: Inspect the Deployment

Run:

kubectl get deployment food-app

Expected output:

NAME       READY   UP-TO-DATE   AVAILABLE
food-app   3/3     3            3

Let's understand the columns:

  • READY: Number of ready Pods compared with the desired number.

  • UP-TO-DATE: Number of Pods updated to the current Pod template.

  • AVAILABLE: Number of Pods available to serve the application.

Now get more details:

kubectl describe deployment food-app

Look for these fields:

Replicas: 3 desired | 3 updated | 3 total | 3 available

This confirms that the Deployment has three available replicas.

Step 5: Inspect the ReplicaSet

Run:

kubectl get rs -l app=food-app

Expected output:

NAME                  DESIRED   CURRENT   READY
food-app-5754744b8    3         3         3

The ReplicaSet name includes a generated hash, so your output may have a different name.

ReplicaSet

Now inspect the ReplicaSet:

kubectl describe rs -l app=food-app

Look for these details:

Controlled By: Deployment/food-app
Replicas: 3 current / 3 desired

This confirms that the Deployment owns the ReplicaSet.

Step 6: Inspect the Pods

Run:

kubectl get pods -l app=food-app

Expected output:

NAME                       READY   STATUS    RESTARTS
food-app-5754744b8-c2nr9   1/1     Running   0
food-app-5754744b8-k7xpl   1/1     Running   0
food-app-5754744b8-w9dqt   1/1     Running   0

We can see three Pods.

All three are:

  • Ready: 1/1

  • Status: Running

  • Restarts: 0

This means the three NGINX containers are running successfully.

Check the Pods

Understand the relationship using kubectl

Step 7: Verify the ownership relationship

Let's verify the relationship between the Deployment, ReplicaSet and Pods.

Check the owner of the ReplicaSet:

kubectl get rs -l app=food-app \
  -o jsonpath='{.items[0].metadata.ownerReferences[0].kind}{"\n"}'

Expected output:

Deployment

Check the owner of each Pod:

kubectl get pods -l app=food-app \
  -o custom-columns=NAME:.metadata.name,OWNER:.metadata.ownerReferences[0].kind

Expected output:

NAME                       OWNER
food-app-5754744b8-c2nr9   ReplicaSet
food-app-5754744b8-k7xpl   ReplicaSet
food-app-5754744b8-w9dqt   ReplicaSet

We have now verified the ownership chain:

Deployment
    |
    v
ReplicaSet
    |
    v
Pods

Verify ownership relationships

Pod ownership

ReplicaSet ownership

Step 8: Scale the Deployment from 3 to 5 replicas

Suppose more users start accessing our food delivery application.

We want to increase the number of Pods from three to five.

Run:

kubectl scale deployment food-app --replicas=5

Expected output:

deployment.apps/food-app scaled

Now check the Deployment:

kubectl get deployment food-app

Expected result:

READY   UP-TO-DATE   AVAILABLE
5/5     5            5

Check the Pods:

kubectl get pods -l app=food-app

We should now see five Pods.

  1. using CLI:Scale the Deployment

2. using YAML

Instead of using the scale command

What happened behind the scenes?

  1. We requested five replicas.

  2. The Deployment updated the desired replica count.

  3. The ReplicaSet noticed that only three Pods existed.

  4. The ReplicaSet created two additional Pods.

  5. Kubernetes started the containers.

  6. The Deployment reached five available replicas.

Important: We scale the Deployment, not its child ReplicaSet. The Deployment manages the ReplicaSet and maintains the desired state.

Step 9: Delete a Pod and observe self-healing

Now let's test what happens when one Pod is deleted.

First, list the Pods:

kubectl get pods -l app=food-app

Choose one Pod name from your output.

For example:

kubectl delete pod food-app-5754744b8-c2nr9

Replace the example name with an actual Pod name from your output.

Now check the Pods again:

kubectl get pods -l app=food-app

You should still see five Pods after Kubernetes creates a replacement.

To watch the process in real time:

kubectl get pods -l app=food-app -w

You may observe:

Old Pod       Terminating
New Pod       Pending
New Pod       ContainerCreating
New Pod       Running

Press Ctrl + C to stop watching.

What happened?

  1. We manually deleted one Pod.

  2. The ReplicaSet noticed that only four Pods remained.

  3. It created a replacement Pod.

  4. The new Pod started successfully.

  5. The Deployment returned to five available replicas.

This is called self-healing.

Remember that Kubernetes does not restore the deleted Pod with its original name. It creates a new Pod.

Also, if a container crashes inside an existing Pod, the kubelet may restart that container according to the Pod's restart policy. That is different from the ReplicaSet replacing a deleted Pod.

Delete a Pod and observe self-healing

Step 10: Perform a rolling update

Now let's update the NGINX image.

Our current image is:

nginx:1.27-alpine

We will update it to:

nginx:1.28-alpine

Run:

kubectl set image deployment/food-app nginx=nginx:1.28-alpine

Expected output:

deployment.apps/food-app image updated

Check the rollout:

kubectl rollout status deployment/food-app

Expected output:

deployment "food-app" successfully rolled out

Now check the Deployment:

kubectl get deployment food-app

Check the Pods:

kubectl get pods -l app=food-app

Verify the image:

kubectl get deployment food-app \
  -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'

Expected output:

nginx:1.28-alpine

What happened behind the scenes?

  1. We changed the image in the Deployment's Pod template.

  2. The Deployment created a new ReplicaSet.

  3. The new ReplicaSet created Pods using NGINX 1.28.

  4. Kubernetes gradually replaced the old Pods.

  5. The rollout completed successfully.

This process is called a rolling update.

Perform a rolling update

A Deployment manages this process so that the application can remain available while Pods are being replaced, subject to the configured rollout strategy and available capacity.

Kubernetes Rolling Update diagram with three stages: Before Update โ†’ During Update โ†’ After Update.

Step 11: Check rollout history

Kubernetes maintains rollout history for Deployments.

Run:

kubectl rollout history deployment/food-app

You should see revision entries similar to:

REVISION  CHANGE-CAUSE
1         <none>
2         <none>

The number of revisions depends on the changes made to the Deployment.

Roll back the Deployment

Step 12: Roll back to the previous version

Suppose the new application version has a problem.

We can return to the previous Deployment revision.

Run:

kubectl rollout undo deployment/food-app

Expected output:

deployment.apps/food-app rolled back

Check the rollout:

kubectl rollout status deployment/food-app

Expected output:

deployment "food-app" successfully rolled out

Verify the image:

kubectl get deployment food-app \
  -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'

Expected output:

nginx:1.27-alpine

The Deployment has returned to the previous image version.

What happened?

Kubernetes restored the previous Pod template and updated the Deployment. It created or reused the appropriate ReplicaSet and replaced Pods as needed.

The original deleted or replaced Pods do not come back. New Pods are created from the restored template.

final verification


7. Common Kubernetes Troubleshooting Scenarios

During practical work, you may encounter Pods that do not start or Deployments that do not reach the desired number of available replicas.

Let's reproduce some common problems and understand how to investigate them.

Scenario 1: Pod stuck in Pending

What does Pending mean?

Pending means the Pod has been accepted by the cluster, but its containers are not running yet. For example, it may be waiting for a suitable node or waiting for its container image to be pulled.

Let's reproduce an insufficient CPU scenario.

Create a file:

nano pending-pod.yaml

Add:

apiVersion: v1
kind: Pod
metadata:
  name: pending-demo
spec:
  containers:
    - name: nginx
      image: nginx:1.27-alpine
      resources:
        requests:
          cpu: "100"

Here, 100 requests 100 CPU cores, which is intentionally unrealistic for our Minikube node.

Apply the file:

kubectl apply -f pending-pod.yaml

Check the Pod:

kubectl get pod pending-demo

The Pod should remain in Pending state.

Now investigate:

kubectl describe pod pending-demo

Look at the Events section.

Our Minikube lab produced:

Warning  FailedScheduling
0/1 nodes are available: 1 Insufficient cpu.

Why did this happen?

The scheduler could not find a node with enough available CPU to satisfy the requested resources.

How do we fix it?

Reduce the CPU request to a realistic value supported by the cluster, or provide a node with enough available CPU.

For this demonstration, we can simply delete the test Pod:

kubectl delete pod pending-demo

Pod in Pending state

Scenario 2: ImagePullBackOff

What does ImagePullBackOff mean?

Kubernetes cannot download the requested container image and is waiting before retrying.

Let's intentionally use an invalid image tag.

Create:

nano image-error-pod.yaml

Add:

apiVersion: v1
kind: Pod
metadata:
  name: image-error-demo
spec:
  containers:
    - name: nginx
      image: nginx:this-image-does-not-exist

Apply the file:

kubectl apply -f image-error-pod.yaml

Check the Pod:

kubectl get pod image-error-demo

It may initially show ContainerCreating or ErrImagePull before reaching ImagePullBackOff.

Investigate:

kubectl describe pod image-error-demo

In our lab, the Events showed messages similar to:

Failed to pull image "nginx:this-image-does-not-exist"

manifest for nginx:this-image-does-not-exist not found

Back-off pulling image

Why did this happen?

We used an image tag that does not exist. Kubernetes could not download the image, so the container could not start.

How do we fix it?

Check the image name and tag. Replace the invalid image with a valid image and recreate or update the resource.

For this demonstration, clean up the test Pod:

kubectl delete pod image-error-demo

Scenario 2- ImagePullBackOff

Scenario 3: CrashLoopBackOff

What does CrashLoopBackOff mean?

A container starts but repeatedly exits. Kubernetes tries to restart it, but the same failure happens again.

Let's reproduce this problem.

Create:

nano crash-pod.yaml

Add:

apiVersion: v1
kind: Pod
metadata:
  name: crash-demo
spec:
  containers:
    - name: crash-container
      image: busybox:1.36
      command: ["sh", "-c", "echo Application starting; exit 1"]

Apply the file:

kubectl apply -f crash-pod.yaml

Watch the Pod:

kubectl get pod crash-demo -w

You may observe:

ContainerCreating
Error
CrashLoopBackOff

Press Ctrl + C to stop watching.

Now check the logs:

kubectl logs crash-demo

Our lab produced:

Application starting

Investigate further:

kubectl describe pod crash-demo

Look for:

State:          Waiting
  Reason:       CrashLoopBackOff
Last State:     Terminated
  Reason:       Error
  Exit Code:    1
Restart Count:  2

Why did this happen?

Our command deliberately ends with:

exit 1

An exit code of 1 indicates that the command failed.

Kubernetes restarted the container, but it failed again. After repeated failures, the container entered CrashLoopBackOff.

How do we fix it?

Check the container logs and configuration, identify why the application exits, and correct the application command or configuration.

For this demonstration, delete the test Pod:

kubectl delete pod crash-demo

Scenario 3- CrashLoopBackOff

Scenario 3-2 CrashLoopBackOff

Scenario 4: Deployment not reaching the desired replica count

Sometimes a Deployment requests five replicas, but not all Pods become available.

Let's reproduce this problem using our existing food-app Deployment.

First, verify the working image:

kubectl get deployment food-app \
  -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'

Our working image is:

nginx:1.27-alpine

Now intentionally set an invalid image:

kubectl set image deployment/food-app nginx=nginx:invalid-demo-tag

Check the rollout:

kubectl rollout status deployment/food-app --timeout=30s

In our lab, the command timed out because the new Pods could not become Ready.

Check the Deployment:

kubectl get deployment food-app

Our actual output was:

NAME       READY   UP-TO-DATE   AVAILABLE
food-app   4/5     3            4

Check the Pods:

kubectl get pods -l app=food-app

Three new Pods entered ImagePullBackOff, while four old Pods remained Running.

Now investigate:

kubectl describe deployment food-app

We could see that the new ReplicaSet used the invalid image:

Image: nginx:invalid-demo-tag

Why did this happen?

The Deployment accepted the image update, but the image could not be downloaded.

The rolling update strategy retained healthy old Pods while the new Pods failed to start.

This is an important example of why we should inspect both the Deployment and its Pods when troubleshooting.

How do we fix it?

Since the previous revision was healthy, the simplest fix is to roll back:

kubectl rollout undo deployment/food-app
kubectl rollout status deployment/food-app

Then verify that the previous image has been restored:

kubectl get deployment food-app \
  -o jsonpath='{.spec.template.spec.containers[0].image}{"\n"}'

Expected image:

nginx:1.27-alpine

Alternatively, we can explicitly set the image to the previous working version:

kubectl set image deployment/food-app nginx=nginx:1.27-alpine

For this scenario, Kubernetes' default rolling-update settings also help explain the observed output:

  • Desired replicas: 5.

  • maxSurge: 25% allows up to 2 additional Pods.

  • maxUnavailable: 25% allows 1 unavailable Pod.

  • Four old Pods remain available while three new Pods fail to start.

This matches our lab output: four available Pods, three updated Pods and seven Pods in total during the failed rollout.

Scenario 4- Deployment not reaching the desired replica count

Scenario 4-2 Deployment not reaching the desired replica countFix the Deployment


8. Useful Troubleshooting Commands

Here are some useful commands to remember when working with Deployments, ReplicaSets and Pods.

CommandPurpose
kubectl get deploymentLists Deployments.
kubectl describe deployment food-appShows detailed Deployment information.
kubectl get rsLists ReplicaSets.
kubectl describe rsShows detailed ReplicaSet information.
kubectl get podsLists Pods.
kubectl describe pod POD_NAMEShows detailed Pod information and Events.
kubectl logs POD_NAMEDisplays container logs.
kubectl get events --sort-by=.lastTimestampDisplays recent Kubernetes events.
kubectl rollout status deployment/food-appChecks rollout progress.
kubectl rollout history deployment/food-appDisplays rollout history.
kubectl rollout undo deployment/food-appRolls back the Deployment.

Remember: kubectl describe is particularly useful when a Pod is not starting because its Events section often explains the problem.


9. YAML vs kubectl Commands

We can create and manage Kubernetes resources using YAML files or imperative commands.

Here are some examples from our lab.

TaskYAML / Declarative approachkubectl command
Create Deploymentkubectl apply -f food-app-deployment.yamlkubectl create deployment food-app --image=nginx:1.27-alpine --replicas=3
Scale DeploymentUpdate replicas: 5 in YAML and apply itkubectl scale deployment food-app --replicas=5
Update imageUpdate the image in YAML and apply itkubectl set image deployment/food-app nginx=nginx:1.28-alpine
Check DeploymentNot applicablekubectl get deployment food-app
Delete PodNot applicablekubectl delete pod POD_NAME
Roll backNot normally done by editing the original manifestkubectl rollout undo deployment/food-app

Both approaches are useful.

For repeatable application configurations, YAML files are especially helpful because we can store them in Git and review changes before applying them.

Important: If we change the replica count using kubectl scale, remember to update the YAML file too if we want it to reflect the new desired state. Otherwise, applying the old manifest later may change the replica count back.


10. Pods vs ReplicaSets vs Deployments

Let's compare the three objects one more time.

FeaturePodReplicaSetDeployment
Runs containersYesNo, manages PodsNo, manages ReplicaSets
Maintains replica countNoYesThrough its ReplicaSets
Creates replacement PodsNoYesIndirectly, through ReplicaSets
ScalingNot directlyYesYes
Rolling updatesNoNoYes
RollbacksNoNoYes

A Pod runs the application.

A ReplicaSet maintains the required number of Pods.

A Deployment manages ReplicaSets and provides application update and rollback capabilities.


11. Common Mistakes to Avoid

  1. Creating standalone Pods when a Deployment is needed for self-healing.

  2. Using mismatched labels and selectors in a Deployment.

  3. Scaling a ReplicaSet directly instead of scaling its Deployment.

  4. Assuming containerPort exposes an application outside the Pod.

  5. Changing replicas using kubectl scale without updating the YAML manifest.

  6. Assuming a deleted Pod returns with the same name.


12. Things to know about Pods, ReplicaSets and Deployments

1. Can we create a Pod without a Deployment?

Yes. We can create a standalone Pod using a Pod YAML file.

However, a standalone Pod is not automatically recreated if it is deleted. For applications that need a desired number of replicas and self-healing, we generally use a Deployment.

2. Does a Deployment create Pods directly?

No. A Deployment creates and manages a ReplicaSet. The ReplicaSet creates and maintains the Pods.

3. What happens if we delete a Pod managed by a Deployment?

The ReplicaSet notices that the number of Pods is below the desired count and creates a replacement Pod.

4. What happens if we delete a ReplicaSet managed by a Deployment?

The Deployment controller notices that its desired ReplicaSet is missing and reconciles the Deployment by creating a replacement ReplicaSet.

5. Why does a Deployment create a new ReplicaSet during an update?

A new ReplicaSet represents the new Pod template, such as an updated container image.

The old ReplicaSet can be retained to support rollout history and rollback.

6. What is the difference between ImagePullBackOff and CrashLoopBackOff?

ImagePullBackOff means Kubernetes cannot download the container image.

CrashLoopBackOff means the container starts but repeatedly exits, so Kubernetes keeps trying to restart it.

7. Is containerPort enough to access an application from outside a Pod?

No. containerPort documents the container's port. To provide network access to an application, we generally use a Kubernetes Service.


13. What We Learned

Let's remember the main concepts:

  • A Pod runs one or more application containers.

  • A ReplicaSet maintains the desired number of Pods.

  • A Deployment manages ReplicaSets.

  • Labels and selectors help Kubernetes identify matching Pods.

  • OwnerReferences record ownership between Kubernetes objects.

  • Deleting a Pod managed by a ReplicaSet results in a replacement Pod.

  • Scaling changes the desired number of replicas.

  • Rolling updates help deploy a new application version gradually.

  • Rollbacks allow us to return to a previous Deployment revision.

  • kubectl describe and kubectl logs are useful troubleshooting commands.

The important relationship to remember is:

Kubernetes relationship

Kubernetes Learning Series

  1. Kubernetes Basics Through a Restaurant Kitchen

  2. Kubernetes Pods Explained: Architecture, Lifecycle and Practical Examples

  3. Kubernetes ReplicaSets Explained: Maintaining the Desired State

  4. Kubernetes Deployments Explained: Rolling Updates and Rollbacksย 

  5. How Pods, ReplicaSets and Deployments Work Together - You are here.

Official Kubernetes Documentation

📚 Sources
  1. kubernetes.io/docs/concepts/workloads/controllers/deployment/
  2. kubernetes.io/docs/concepts/workloads/controllers/replicaset/
  3. kubernetes.io/docs/concepts/workloads/pods/
  4. kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  5. kubernetes.io/docs/tasks/debug/debug-application/debug-pods/
  6. kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/

❓ Questions readers ask

What is the relationship between Pods, ReplicaSets and Deployments?

A Deployment manages ReplicaSets, and ReplicaSets create and maintain Pods.

What happens when a Pod managed by a ReplicaSet is deleted?

The ReplicaSet detects the missing Pod and creates a replacement to maintain the desired replica count.

Can we scale a Deployment without changing its YAML file?

Yes. We can use kubectl scale deployment to change the replica count imperatively.

What is the difference between a ReplicaSet and a Deployment?

A ReplicaSet maintains the required number of Pods, while a Deployment manages ReplicaSets and supports rolling updates and rollbacks.

Why does Kubernetes create a new ReplicaSet during a rolling update?

A new ReplicaSet represents the updated Pod template, allowing Kubernetes to gradually replace the old Pods.

Read next →Kubernetes Pods: Architecture, Lifecycle & Examples⏱ 16 min

🛍️ Malathi Shetty's shelf

Courses, cohorts and more from the author
Malathi Shetty
Written by Malathi Shetty
Senior QA Engineer | Cloud & DevOps Learner | AWS | Azure | Kubernetes | Hands-on Projects
🏅 Contributor writer

I am a technology professional with 13+ years of experience in Software Quality Engineering, currently expanding my expertise in Cloud and DevOps. I enjoy learning by building hands-on projects, exploring cloud technologies and sharing practical knowledge through blogs and labs.

Visit my ByteStoreLearning, building and sharing practical Cloud & DevOps experiences.

🌟 See Malathi Shetty's full profile: blogs, work and verified certificates

Get Malathi Shetty's next blog by email

One email a week when they publish. Add the weekly Best of ByteBlog too. No spam, unsubscribe with one click.

We email you once to confirm. By subscribing you agree to the privacy policy.

💬 Comments (0)

Top · Newest

Sign in to comment

More from Malathi Shetty

🛍️✨ From the author · ByteStore1:1 DevOps Project & Learning Discussionโ‚น500View offer →