Skip to content

Commit

Permalink
docs: Update k8s docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradumnasaraf committed Oct 23, 2024
1 parent 8b806f9 commit e66c97c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/kubernetes/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,16 +525,19 @@ StatefulSet is a controller that manages the deployment and scaling of a set of

`serviceName` is used to create a headless service. We need to create a headless service while creating a StatefulSet. The purpose of the headless service is that it allows a client to connect to whichever pod it prefers.

Another great thing about the StatefulSet is that pod naming is predictable. The pod name is in the format `<statefulset-name>-<ordinal>`. The ordinal is a unique number assigned to each pod. For example, if we have a StatefulSet with 3 replicas, the pod names will be `nginx-with-init-containers-0`, `nginx-with-init-containers-1`, `nginx-with-init-containers-2`, it's not like random hashes in the deployment.
Another great thing about the StatefulSet is that pod naming is predictable. The pod name is in the format `<statefulset-name>-<ordinal>`. The ordinal is a unique number assigned to each pod. So, fo below example, the pod names will be `nginx-statefulset-0`, `nginx-statefulset-1`, `nginx-statefulset-2`.

Also, similar kind of naming convention is follow by PVCs. The PVC name is in the format `<volume-claim-template-name>-<statefulset-name>-<ordinal>`. So, for below example, the PVC names will be `data-nginx-statefulset-0`, `data-nginx-statefulset-1`, `data-nginx-statefulset-2`.

The way the below config is working that the init container will run before the main container. The init container will populate the default HTML file in the volume and then the main container will use that volume to serve the HTML file.

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nginx-statefulset
spec:
serviceName: nginx # Headless service
serviceName: nginxs # Headless service
replicas: 3
selector:
matchLabels:
Expand Down Expand Up @@ -578,7 +581,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
name: nginxs
spec:
clusterIP: None # Headless service
selector:
Expand Down

0 comments on commit e66c97c

Please sign in to comment.