liveBook · Manning

Stateless system

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A stateless application is an application whose individual instances do not retain essential client or session state locally between requests.

A stateless application does not retain essential client or session data inside individual instances between requests. Because application data is decoupled from its containers, Kubernetes can replace failed pods or distribute requests across replicas without changing the expected response. section 5.1 section 5.1.1

Use a Deployment to operate stateless workloads:

  • Run multiple identical pod replicas for high availability, resilience, robustness, and self-healing. section 5.1 section 5.1.2
  • Scale replicas independently with kubectl scale or by changing the Deployment YAML. section 5.1.1 section 5.1.2
  • Update container images through a rolling update; Kubernetes creates a new ReplicaSet and replaces the old pods. section 5.1.1 section 5.1.2
  • Contrast this model with StatefulSet workloads, whose data is required for the application to run and prevents equally simple replacement. section 5.1

Scale and update an Apache Deployment

Create three replicas with `kubectl create deploy apache --image httpd:2.4.65 --replicas 3`, verify them with `kubectl get deploy`, scale to five using `kubectl scale deploy apache --replicas 5`, then change the image with `kubectl set image deploy apache httpd=httpd:alpine`. Verify the replacement pods with `kubectl get po`. section 5.1.1

root@kind-control-plane:/# kubectl create deploy apache --image 
httpd:2.4.54 --replicas 3
deployment.apps/apache created
root@kind-control-plane:/# kubectl get deploy
NAME                 READY   UP-TO-DATE   AVAILABLE   AGE
apache               3/3     3            3           14s
root@kind-control-plane:/# kubectl scale deploy apache --replicas 5
deployment.apps/apache scaled
root@kind-control-plane:/# kubectl get po
NAME                                  READY   STATUS                       
RESTARTS       AGE
apache-74f79bcc68-7lzqz               1/1     Running                      
0              7s
apache-74f79bcc68-89zwg               1/1     Running                      
0              33s
apache-74f79bcc68-v6drf               1/1     Running                      
0              33s
apache-74f79bcc68-x7bfw               1/1     Running                      
0              33s
apache-74f79bcc68-xdx4b               1/1     Running                      
0              7s

Inspect representative kubectl output showing Deployment scaling, pod naming, and the resulting replica set. section 5.1.1

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains replacement, replication, scaling, image updates, ReplicaSets, and rolling updates, without detailing application-level state design.
Examples
Uses Apache and nginx Deployments, kubectl commands, replica output, generated YAML, and ReplicaSet diagrams.
What you can do after
Operate stateless workloads with kubectl by creating, scaling, updating, and verifying replicated Deployments.
How it connects
Connects stateless applications with Deployments, Pods, ReplicaSets, rolling updates, microservices, and StatefulSets.

Also explained in

Compare how 14 books explain stateless system →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.