StatefulSet


Purpose

1. creation order is guaranteed unless podManagementPolicy: parallel. The default podManagementPolicy value is OrderedReady
2. pod name remain same even after restart
3. Use volumeClaimTemplate . Its an array. The content of array element is same as PVC. Each pod will get its own PV.

If we delete statefulset then all pods may not get deleted. First we shall scale statefulset to 0 then delete statefulset. After that we shall manually delete PVC.

For statefulset hostname and pod name are same. 

kubectl patch statefulset
It can be used to update: 
- label
- annotation
- container image
- resource requests
- resource limits

Two types of updtateStrategy
- RollingUpdate: The RollingUpdate update strategy will update all Pods in a StatefulSet, in reverse ordinal order
- OnDelete
During update, if any pod, that is not under update process, fails, then it will restored back to its original version. Support N pod. Updates goes from pod-N to pod-1 and change container image to version 1 to version 2. Now suppose update for pod-i is going on. pod-j is crashed. if j > i then it will be restored back to version 2 and if j < i then it will be restored back to version 1

Headeless service will add DNS entries
- for each pod: "pod name"."headless service name"."namespace name".svc.cluster.local
Here pod IP address is not used.
- for headeless service: DNS is mapped to all pod's DNS. 

To create Headless service, specify ClusterIP: None

1. Headless service with deployment. 
Pod shall have value for subdomain as same as name of headless service.
Also specify hostname then only pod's dns name A record will be created. But all pod will have same hostname

2. To create Headless service with statefulset, no need to specify (1) subdomain (2) hostname

Instead of subdomain, we shall specify serviceName

1 comments:

Manish Panchmatia said...

https://containerlabs.kubedaily.com/Kubernetes/fundamentals/StatefulSets.html

Post a Comment