🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 5 Min Lesezeit
0

🤔 If Data Survives in Deployments, Why Do We Need StatefulSets?

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Hola Amigos 👋



Welcome to the second episode of K8s with Pravesh. If you're new to the series, check out the repository, fork it under your own GitHub account, and clone the code:




CODE
git clone https://github.com/<your-username>/K8s_with_Pravesh.git






Navigate to the project directory:




CODE
cd K8s_with_Pravesh/part-02-statefulsets/configs






Here you'll find:




  • Secrets and ConfigMaps

  • Deployment manifest

  • StatefulSet manifest



First, apply the Secrets and ConfigMaps. These contain the MySQL password, database name, and MySQL initialization script.




CODE
kubectl apply -f secrets-and-config.yml












🧪 Experiment 1: Deployment + PVC



Now let's apply our Deployment manifest.



This file contains:




  • Persistent Volume Claim (PVC)

  • Deployment

  • Service



Apply it using:




CODE
kubectl apply -f deployment.yml






Once the pod is running, we'll create a sample record inside MySQL, delete the pod, and verify whether the data survives.



Get the pod name:




CODE
kubectl get pods






Connect to MySQL:




CODE
kubectl exec -it mysql-XXXXXX-XXXX -- mysql -uroot -p






Enter the password:




CODE
Pravesh






(You can change this value in the secrets-and-config.yml file.)



Inside MySQL, run:




CODE
USE crud_app;

INSERT INTO users(name,email,password)
VALUES('Pravesh','[email protected]','secret');






Exit MySQL:




CODE
exit








You'll notice that the data is still there.






Wait... The Data Survived?



At this point, many people expect the data to disappear because we're using a Deployment.



However, the data survived.



So the obvious question becomes:




If data survives in a Deployment, why do we even need StatefulSets?




The answer is simple.



The data survived because we attached a Persistent Volume Claim (PVC) to the MySQL container. The PVC preserved the data, not the Deployment.



In other words:




CODE
Pod

PVC

Persistent Storage






The pod can disappear and be recreated, but the storage remains intact.









🧪 Experiment 2: StatefulSet



Now let's perform the same experiment using a StatefulSet.



Apply the StatefulSet manifest:




CODE
kubectl apply -f statefulset.yml






Wait for the pod to start:




CODE
kubectl get pods






You'll notice that the pod has a predictable name:




CODE
mysql-0






Connect to MySQL:




CODE
kubectl exec -it mysql-0 -- mysql -uroot -p






Insert another record:




CODE
USE crud_app;

INSERT INTO users(name,email,password)
VALUES('Pravesh','[email protected]','secret');






Exit MySQL:




CODE
exit






Delete the pod:




CODE
kubectl delete pod mysql-0






Wait for Kubernetes to recreate it:




CODE
kubectl get pods






Notice something interesting:




CODE
mysql-0






The pod name remains exactly the same.



Connect again:




CODE
kubectl exec -it mysql-0 -- mysql -uroot -p






Verify the data:




CODE
USE crud_app;

SELECT * FROM users;






The data survived once again.





With StatefulSets, each replica gets its own dedicated PVC.



For example:




CODE
mysql-data-mysql-0
mysql-data-mysql-1
mysql-data-mysql-2






This creates a stable relationship between a pod and its storage.



StatefulSets manage a group of pods while maintaining a sticky identity for each pod. Unlike Deployments, StatefulSet pods are not interchangeable.



Each pod receives:




  • A stable hostname

  • A stable network identity

  • Persistent storage

  • Ordered deployment and termination



Even if a pod is rescheduled, it retains its identity.






When Should You Use StatefulSets?



StatefulSets are valuable when your application requires:




  • Stable, unique network identifiers

  • Stable, persistent storage

  • Ordered, graceful deployment and scaling

  • Ordered rolling updates



Common examples include:




  • MySQL

  • PostgreSQL

  • Kafka

  • ZooKeeper

  • Redis Clusters

  • Elasticsearch






Deployment vs StatefulSet






































Feature Deployment StatefulSet
Data Persistence ✅ With PVC ✅ With PVC
Stable Pod Name
Stable Network Identity
Dedicated Storage Per Replica
Ordered Startup/Shutdown








Conclusion



A common misconception is that StatefulSets exist because Deployments cannot persist data. As we saw in this blog, that isn't entirely true.



A Deployment can preserve data just fine when paired with a Persistent Volume Claim. The PVC is responsible for data persistence, not the Deployment itself.



The real strength of StatefulSets lies in providing stable identities, predictable networking, dedicated storage per replica, and ordered deployment behavior. These features make StatefulSets the ideal choice for databases and other stateful distributed systems.



If you're running stateless applications such as frontend applications, REST APIs, or microservices, Deployments are usually the right choice. But when your workloads require stable identities and persistent state, StatefulSets become essential.



I hope this hands-on comparison helped clarify the difference between Deployments and StatefulSets.



See you in the next episode of K8s with Pravesh! 🚀









🌟 Connect With Me





If you found this article helpful, consider sharing it with your network and following the series for upcoming Kubernetes content.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 🤔 If Data Survives in Deployments, Why Do We Need StatefulSets?

Thematisch verwandte Begriffe: Data, Survives, Deployments, Need · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...