1

I'm struggling to understand the difference between Deployments and Pods in Kubernetes.

A Deployment provides declarative updates for Pods and ReplicaSets.

Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.

It seems like kind:Pod can be used interchangeably kind: Deployment and deployments allow for Replica (which is pretty much the point of Kubernetes). Why would you ever use a Pod?

Can someone:

  • Explain the essential difference between Pods/Deployments +
  • Describe a use case where pods are preferable over deployments?
Casper Dijkstra
  • 1,615
  • 10
  • 37

1 Answers1

2

In short:

With Pods

  1. if it dies it dies. Period.
  2. you can define only one copy of particular pod. If you need to have X copies you have to define in YAML file(s) X pods
  3. usually you will never see pods created directly in production environments. Too unreliable. Why ? because of 1.

With Deployment

  1. you define desired state of a pod. If pod dies (for whatever reason) then deployment creates new pod.
  2. and more generic: you can define that you want to have X running replicas of the same pod. If one or more of them die(s) the Deployment creates new to match X
pb100
  • 736
  • 3
  • 11
  • 20
  • More precisely, a Deployment creates a ReplicaSet which then creates a set of identical, steteless, pods, w.r.t. the pod template specified inside the Deployment's yaml file, and the value of the `replica` field (which define the size of the pod set). The Deployment can manage multiple ReplicaSets in order to perfom rolling update of the managed pods, so that version of the application is upgraded without interrupting the service. – Fabrice Jammes Oct 21 '20 at 14:41