- Hands-On Kubernetes on Windows
- Piotr Tylenda
- 228字
- 2021-06-24 16:54:10
StatefulSets
Deployments are usually used to deploy stateless components of your application. For stateful components, Kubernetes provides another API Object named StatefulSet. The principle of this operation is very similar to Deployment – it manages ReplicaSets and Pods in a declarative way and provides smooth rollouts and rollbacks. However, there are some key differences:
- StatefulSets ensure a deterministic (sticky) ID of Pods, which consists of <statefulSetName>-<ordinal>. For Deployments, you would have a random ID consisting of <deploymentName>-<randomHash>.
- For StatefulSets, the Pods are started and terminated in a specific, predictable order while scaling the ReplicaSet.
- In terms of storage, Kubernetes creates PersistentVolumeClaims based on volumeClaimTemplates of the StatefulSet Object for each Pod in the StatefulSet and always attaches this to the Pod with the same ID. For Deployments, if you choose to use volumeClaimTemplates, Kubernetes will create a single PersistentVolumeClaim and attach the same to all the Pods in the Deployment.
- You need to create a headless Service Object that is responsible for managing the deterministic network identity (DNS names) for Pods. The Headless Service allows us to return all Pod IPs behind the Service as DNS A records instead of a single DNS A record with a Service Cluster IP.
StatefulSets use a similar Spec to Deployments – you can find out more regarding StatefulSets by looking at the official documentation: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/.
推薦閱讀
- C#程序設計實訓指導書
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰
- 程序員數學:用Python學透線性代數和微積分
- Architecting the Industrial Internet
- Learning Bayesian Models with R
- Getting Started with Python Data Analysis
- Cocos2d-x學習筆記:完全掌握Lua API與游戲項目開發 (未來書庫)
- Python算法從菜鳥到達人
- 高級語言程序設計(C語言版):基于計算思維能力培養
- C語言程序設計
- R Data Analysis Cookbook(Second Edition)
- Unity 2017 Mobile Game Development
- 多模態數據分析:AGI時代的數據分析方法與實踐
- App Inventor少兒趣味編程動手做
- Oracle Data Guard 11gR2 Administration Beginner's Guide