In the realm of Kubernetes orchestration, containers follow a structured hierarchy. Fundamentally, pods house containers, organized within replica sets. Taking it a step further, replica sets are orchestrated within a Deployment.
The Deployment Cascade
Initiating a Deployment sets off a chain reaction, spawning a replica set that hosts pods. This replica set acts as a Kubernetes controller, ensuring automatic healing for pods and maintaining alignment between desired and actual states.
Deployment vs. Replica Set
Both Deployment and replica set serve as Kubernetes controllers, but Deployment goes the extra mile. It enables seamless updates to container versions within pods. Unlike replica sets, which recreate pods with initial configurations, Deployment empowers users to upgrade or roll back container versions.
Upgrading with Deployment
During a container version update, Deployment crafts a new replica set housing the updated version. This ensures a smooth transition. The default strategy is the Rolling Update, involving creating a new replica set, terminating some pods from the current set, introducing pods with the latest configuration, and eventually phasing out the remaining pods for the new replica set.
Undoing Changes
Deployment's versatility shines when changes need to be undone. Whether rolling back a version or reverting configuration, Deployment supports an undo operation. Executing this operation reverts to a previous replica set, effectively restoring pods to their earlier state.
In essence, Kubernetes Deployments provide a robust and flexible approach to managing containerized applications, ensuring a controlled deployment lifecycle.
Check out this deployment manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Executing this manifest results in one deployment with three replica sets and three pods.
When a pod is deleted, the replica set detects the change in actual state versus desired state and creates a new pod to maintain balance.
Top comments (0)