Understanding ๐Ÿš€the difference between Deployment and ReplicaSet โœ…in Kubernetes

ยท

3 min read

Understanding ๐Ÿš€the difference between Deployment and ReplicaSet โœ…in Kubernetes

Introduction:

Kubernetes is an open-source compartment arrangement stage that robotizes the sending, scaling, and boarding of containerized applications. Two important Kubernetes objects are deployment and replica set, which are used to manage pods, the smallest deployable units. Although they share some similarities, their features and application scenarios are fundamentally different.

In this blog post, we'll talk about the differences between Kubernetes deployment and replica set.

Small Intro to Deployment and ReplicaSet:

โžผ In Kubernetes, deployment and replicaSet are two crucial components that aid in application lifecycle management and high availability.

โžผ ReplicaSet ensures that a predetermined number of replica Pods are always running, while Deployment is in charge of managing the creation, scaling, and updating of ReplicaSets.

โžผ By utilizing these parts, Kubernetes can without much of a stretch deal with the application lifecycle, guarantee adaptation to non-critical failure, and give consistent updates and rollbacks.

๐™ณ๐š’๐š๐š๐šŽ๐š›๐šŽ๐š—๐šŒ๐šŽ ๐š‹๐šŽ๐š๐š ๐šŽ๐šŽ๐š— ๐š›๐šŽ๐š™๐š•๐š’๐šŒ๐šŠ๐šœ๐šŽ๐š & ๐™ณ๐šŽ๐š™๐š•๐š˜๐šข๐š–๐šŽ๐š—๐š?

๐—ฅ๐—ฒ๐—ฝ๐—น๐—ถ๐—ฐ๐—ฎ๐—ฆ๐—ฒ๐˜:
โ‘  It is a simpler object and is responsible only for maintaining a specific number of replicas of a pod.
โ‘ก It does not support rolling updates and rollbacks of application versions.
โ‘ข It is used for scaling a single type of Pod.

โ‘ฃ It's a lower-level resource than a Deployment and is mainly used by Deployments to manage replicas.

๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜:
โ‘  It provides a way to manage the lifecycle of ReplicaSets and Pods.
โ‘ก It supports rolling updates, rollbacks, and scaling of application replicas.
โ‘ข It is used for managing multiple ReplicaSets and scaling different types of Pods.

๐—ฅ๐—ผ๐—น๐—น๐—ผ๐˜‚๐˜:

If there are problems in the deployment, Kubernetes will automatically roll-back to the previous version,
however we can also explicitly role-back to a specific revision
Example:
Rollout to the previous version(one version back):
โžฃ ๐˜ฌ๐˜ถ๐˜ฃ๐˜ฆ๐˜ค๐˜ต๐˜ญ ๐˜ณ๐˜ฐ๐˜ญ๐˜ญ๐˜ฐ๐˜ถ๐˜ต ๐˜ถ๐˜ฏ๐˜ฅ๐˜ฐ ๐˜ฅ๐˜ฆ๐˜ฑ๐˜ญ๐˜ฐ๐˜บ/๐˜ฎ๐˜บ๐˜ฅ๐˜ฆ๐˜ฑ๐˜ญ๐˜ฐ๐˜บ๐˜ฎ๐˜ฆ๐˜ฏ๐˜ต
Rollout to a specific version:
โžฃ kubectl rollout undo deploy/mydeployment --to-revision=2

To check whether the deployment was created or not :
โžฃ kubectl get deploy

To check, how deployment creates Replicaset and pods:
โžฃ kubectl describe deploy mydeployment

To scale replica through the command:
โžฃ kubectl get rs (rs= replica set)
โžฃ kubectl scale --replicas=6 deploy mydeployment

To check how many versions you have created
โžฃ kubectl rollout history deployment{or deploy} mydeployment

For deleting Deployment: kubectl delete deployment mydeployment

๐˜„๐—ต๐—ฒ๐—ป ๐—ผ๐˜‚๐—ฟ ๐—ฑ๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜ ๐—ฐ๐—ผ๐˜‚๐—น๐—ฑ ๐—ณ๐—ฎ๐—ถ๐—น๐—ฒ๐—ฑ ?

1. Insufficient quota: the required resources are not allocated.
2. readiness prob failures: let's say a node is not ready while applying deployment
3. Image pull error: due to version, image not available etc.
4. Insufficient permission
5. Limit Ranges
6. Application runtime misconfiguration

๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜ ๐—ณ๐—ถ๐—น๐—ฒ:

๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜ ๐—ณ๐—ถ๐—น๐—ฒ:

๐™ ๐™ž๐™ฃ๐™™: ๐˜ฟ๐™š๐™ฅ๐™ก๐™ค๐™ฎ๐™ข๐™š๐™ฃ๐™ฉ
๐™–๐™ฅ๐™ž๐™‘๐™š๐™ง๐™จ๐™ž๐™ค๐™ฃ: ๐™–๐™ฅ๐™ฅ๐™จ/๐™ซ1
๐™ข๐™š๐™ฉ๐™–๐™™๐™–๐™ฉ๐™–:
 ๐™ฃ๐™–๐™ข๐™š: ๐™ข๐™ฎ๐™™๐™š๐™ฅ๐™ก๐™ค๐™ฎ๐™ข๐™š๐™ฃ๐™ฉ๐™จ
๐™จ๐™ฅ๐™š๐™˜:
 ๐™ง๐™š๐™ฅ๐™ก๐™ž๐™˜๐™–๐™จ: 2
 ๐™จ๐™š๐™ก๐™š๐™˜๐™ฉ๐™ค๐™ง:  
 ๐™ข๐™–๐™ฉ๐™˜๐™๐™‡๐™–๐™—๐™š๐™ก๐™จ:
  ๐™ฃ๐™–๐™ข๐™š: ๐™™๐™š๐™ฅ๐™ก๐™ค๐™ฎ๐™ข๐™š๐™ฃ๐™ฉ
 ๐™ฉ๐™š๐™ข๐™ฅ๐™ก๐™–๐™ฉ๐™š:
  ๐™ข๐™š๐™ฉ๐™–๐™™๐™–๐™ฉ๐™–:
  ๐™ฃ๐™–๐™ข๐™š: ๐™ฉ๐™š๐™จ๐™ฉ๐™ฅ๐™ค๐™™
  ๐™ก๐™–๐™—๐™š๐™ก๐™จ:
   ๐™ฃ๐™–๐™ข๐™š: ๐™™๐™š๐™ฅ๐™ก๐™ค๐™ฎ๐™ข๐™š๐™ฃ๐™ฉ
  ๐™จ๐™ฅ๐™š๐™˜:
  ๐™˜๐™ค๐™ฃ๐™ฉ๐™–๐™ž๐™ฃ๐™š๐™ง๐™จ:
  - ๐™ฃ๐™–๐™ข๐™š: ๐™˜00
   ๐™ž๐™ข๐™–๐™œ๐™š: ๐™ช๐™—๐™ช๐™ฃ๐™ฉ๐™ช
   ๐™˜๐™ค๐™ข๐™ข๐™–๐™ฃ๐™™: ["/๐™—๐™ž๐™ฃ/๐™—๐™–๐™จ๐™", "-๐™˜", "๐™ฌ๐™๐™ž๐™ก๐™š ๐™ฉ๐™ง๐™ช๐™š; ๐™™๐™ค ๐™š๐™˜๐™๐™ค ๐˜ฟ๐™š๐™–๐™ฉ๐™-๐™‰๐™ค๐™ฉ๐™š; ๐™จ๐™ก๐™š๐™š๐™ฅ 5; ๐™™๐™ค๐™ฃ๐™š"]
ย