Kubernetes Workload Management
medium

Questão de Kubernetes Workload Management #019e3a4f

Enunciado da Questão
Kubernetes Workload Management
#deployments
#statefulsets
#kubernetes
#pods
#workloads
Médio

What do Deployments and StatefulSets have in common?

A

They manage Pods that are based on an identical container spec.

Correta
B

They support the OnDelete update strategy.

C

They support an ordered, graceful deployment and scaling.

D

They maintain a sticky identity for each of their Pods.

Explicação Oficial / Explicações da Comunidade

Summary

Deployments and StatefulSets are both Kubernetes workload resources that manage Pods based on an identical container spec. This means all Pods created by a Deployment or StatefulSet use the same container image, environment variables, and resource requests/limits defined in the Pod template. The key difference lies in how they handle Pod identity and ordering, but the underlying Pod template is identical for all replicas.

How It Works

In Kubernetes, a Deployment is designed for stateless applications where Pods are interchangeable. It ensures that a specified number of Pod replicas are running at all times, supports rolling updates, and can scale up or down. A StatefulSet, on the other hand, is used for stateful applications that require stable, unique network identifiers, persistent storage, and ordered deployment/scaling. Despite these differences, both resources define a Pod template in their spec, and all Pods created from that template are identical in terms of container configuration.

Why the Correct Answer is Right

The correct answer states that Deployments and StatefulSets manage Pods based on an identical container spec. This is true because both resources use a template field in their YAML definition that specifies the Pod's containers, volumes, and other settings. Every Pod created by the same Deployment or StatefulSet will have the same container image, command, ports, and environment variables as defined in that template. This is a fundamental property of both workload types.

Why the Incorrect Answers are Wrong

  • They support the OnDelete update strategy. This is incorrect. The OnDelete update strategy is only supported by DaemonSets, not by Deployments or StatefulSets. Deployments support RollingUpdate and Recreate strategies, while StatefulSets support RollingUpdate and OnDelete? Actually, StatefulSets do support OnDelete as an update strategy, but Deployments do not. Therefore, this is not a common feature.

  • They support an ordered, graceful deployment and scaling. This is incorrect. Only StatefulSets provide ordered, graceful deployment and scaling (e.g., Pods are created one at a time in order, and scaling down removes Pods in reverse order). Deployments do not guarantee ordering; they can create or delete Pods in any order.

  • They maintain a sticky identity for each of their Pods. This is incorrect. Only StatefulSets provide sticky identities (stable network hostnames and persistent storage) for each Pod. Deployments treat Pods as ephemeral and interchangeable, with no guaranteed identity.

Key Takeaway

The commonality between Deployments and StatefulSets is that both use a Pod template to create identical Pods. The differences lie in Pod identity, ordering, and update strategies.