Stateful set in kubernetes implementation & usecases
This document summarizes a presentation on StatefulSets in Kubernetes. It discusses why StatefulSets are useful for running stateful applications in containers, the differences between stateful and stateless applications, how volumes are used in StatefulSets, examples of running single-instance and multi-instance stateful applications like Zookeeper, and the current status and future roadmap of StatefulSets in Kubernetes.
Agenda
Why StatefulSet
Stateful application in the Cloud
Stateful Vs Stateless
Cloud Native/Micro Service
Volumes in Statefulset
Use Case
Single Instance Stateful Application
Multiple Instance Stateful Application
Demo of Stateful Application Deployment
Future Roadmap
References
3.
Why stateful set?
Deployments and ReplicaSets are a great way to run stateless replicas of an
application. Stateless containers like web servers - so-called “cattle” because they are
interchangeable, users are increasingly deploying stateful workloads with containers
to benefit from “build once, run anywhere”
These “pets” - so-called because each requires special handling - bring new
requirements including longer life cycle, configuration dependencies, stateful failover,
and performance sensitivity.
Pet Set sequences through the startup phase of each database replica (for example),
ensuring orderly master/slave configuration.
Pet Set also simplifies service discovery by leveraging ubiquitous DNS SRV records, a
well-recognized and long-understood mechanism.
1.3. Kubernetes support for stateful apps called pet set and 1.5 renamed it to stateful
set - Name change plus “at most one pod per index”, ordered deployment, ordered
termination, unique network names, and persistent stable storage.
Volumes in statefulset
Kubernetesto manage the stateless tiers of your ecosystem, you should
consider using the same infrastructure to manage your storage
applications.
Kubernetes doesn’t yet support isolation for network or storage I/O
across containers. Colocating your storage application with a noisy
neighbor can reduce the QPS that your application can handle.
•emptyDir
•hostPath
•gcePersistentDisk
•awsElasticBlockStore
•Nfs
•Iscsi
•Flocker
•Glusterfs
•Rbd
•gitRepo
•Secret
•persistentVolumeClaim
6.
CloudNative / Microservices
Cloudnative not necessary 12 factor(Heroku way of doing)
Microservices is and architecture not necessarily cloud native
Workload could be data streaming instead of web.
Cloud Native is a set of patterns? (e.g: Cloud Foundry is one of the
patterns)
OCI is for standards but CNCF is or projects, tools, APIs
Go is not necessary the language. Any language is OK. E.g:
Linkerd – is JVM
Cloudnative need not be containers only. Unikernals and functions
can be different.
Special purpose dev environment is serverless, it can be cloud
native or not.
Netflix OSS is JVM based
.
Running a Multi-InstanceStateful Application
e.g:#1
Zookeeper is an interesting use case for StatefulSet for two reasons. First, it
demonstrates that StatefulSet can be used to run a distributed, strongly
consistent storage application on Kubernetes. Second, it's a prerequisite for
running workloads like Apache Hadoop and Apache Kakfa on Kubernetes.
An in-depth tutorial on deploying a ZooKeeper ensemble on Kubernetes is
available in the Kubernetes documentation, and we’ll outline a few of the key
features below.
e.g:#2
Current Status
Wasoriginally proposed as PetSet
Became Statefulset from 1.5, you could migrate
Petset to statefulset now
Re-written recently.
Ordered/Sequenced Starting of PODs are going to
be relaxed. New Annotation
Debug Annotation will be removed.
More Focus on Stability
More charts are converted to Statefulset
11.
Statefulset and Friends
Always needs additional Kubernetes entities to make
it work very well
Service - Mandatory
Initcontainers
PodDisruptionBudget
Interpod Anti-affinity / Anti-Affinity
ConfigMaps
12.
Future roadmap
Supportwell defined upgrade
Support arbitery field update
Statefulset in federated clusters
Statefulset compatible with shard based application /
legacy applications.
A good Cleanup mechanism
GC leftover PODs, leftover PVC and Services