March 25, 2023
Kubernetes StatefulSets are used to deploy stateful applications inside your cluster. Each Pod in the StatefulSet can access local persistent volumes that stick to it even after it’s rescheduled. This allows Pods to maintain individual state that’s separate from their neighbors in the set. Unfortunately these volumes come with a big limitation: Kubernetes doesn’t provide…

Kubernetes StatefulSets are used to deploy stateful applications inside your cluster. Each Pod in the StatefulSet can access local persistent volumes that stick to it even after it’s rescheduled. This allows Pods to maintain individual state that’s separate from their neighbors in the set.

Unfortunately these volumes come with a big limitation: Kubernetes doesn’t provide a way to resize them from the StatefulSet object. The spec.resources.requests.storage property of the StatefulSet’s volumeClaimTemplates field is immutable, preventing you from applying any capacity increases you require. This article will show you how to workaround the problem.

Creating a StatefulSet

Copy this YAML and save it to ss.yaml:

apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: selector: app: nginx ports: – name: nginx port: 80 clusterIP: None — apiVersion: apps/v1 kind: StatefulSet metadata: name: nginx spec: selector: matchLabels: app: nginx replicas: 3 serviceName: nginx template: metadata: labels: app: nginx spec: containers: – name: nginx image: nginx:latest ports: – name: web containerPort: 80 volumeMounts: – name: data mountPath: /usr/share/nginx/html volumeClaimTemplates: – metadata: name: data spec: accessModes: [“ReadWriteOnce”] resources: requests: storage: 1Gi

Apply the YAML to your cluster with Kubectl:

$…

Read Full Article Source