StatefulSet resources – Managing Advanced Kubernetes Resources

StatefulSet resources help manage stateful applications. They are similar to Deployment resources, but unlike a Deployment resource, they also keep track of state and require Volume and Service resources to operate. StatefulSet resources maintain a sticky identity for each pod. This means that the volume mounted on one pod cannot be used by the other. In aStatefulSet resource, Kubernetes orders pods by numbering them instead of generating a random hash. Pods within a StatefulSet resource are also rolled out and scaled-in in order. If a particular pod goes down and is recreated, the same volume is mounted to the pod.

The following diagram illustrates a StatefulSet resource:

Figure 6.8 – StatefulSet resource

A StatefulSet resource has a stable and unique network identifier, therefore, it requires a headless Service resource. Headless Services are Service resources that do not have a cluster IP. Instead, the Kubernetes DNS resolves the Service resource’s FQDN directly to the pods.

As a StatefulSet resource is supposed to persist data, it requires Persistent Volumes to operate.

Therefore, let’s look at how to manage volumes using Kubernetes.

Managing Persistent Volumes

Persistent Volumes are Kubernetes resources that deal with storage. They can help you manage and mount hard disks, SSDs, filestores, and other block and network storage entities. You can provision Persistent Volumes manually or use dynamic provisioning within Kubernetes. When you use dynamic provisioning, Kubernetes will request the cloud provider via the cloud controller manager to provide the required storage. Let’s look at both methods to understand how they work.

Related Posts

Static provisioning – Managing Advanced Kubernetes Resources-2

As the Service resource is created, we can create a StatefulSet resource that uses the created PersistentVolume and Service resources. The StatefulSet resource manifest, nginx-manual-statefulset.yaml, looks like…

Static provisioning – Managing Advanced Kubernetes Resources-1

Static provisioning is the traditional method of provisioning volumes. It requires someone (typically an administrator) to manually provision a disk and create a PersistentVolume resource using the…

Managing stateful applications – Managing Advanced Kubernetes Resources

Imagine you’re a librarian in a magical library. You have a bunch of enchanted books that store valuable knowledge. Each book has a unique story and is…

Horizontal Pod autoscaling – Managing Advanced Kubernetes Resources-2

Now, let’s autoscale this deployment. The Deployment resource needs at least 1 pod replica and can have a maximum of 5 pod replicas while maintaining an average…

Horizontal Pod autoscaling – Managing Advanced Kubernetes Resources-1

Imagine you’re the manager of a snack bar at a park. On a sunny day, lots of people come to enjoy the park, and they all want…

Name-based routing – Managing Advanced Kubernetes Resources

Name-based or FQDN-based routing relies on the host header we pass while making an HTTP request. The Ingress resource can route based on the header. For example,…

Leave a Reply

Your email address will not be published. Required fields are marked *