Increase Replica With Volume of Arbitrary Size With K8s Stateful Set

Photo by patricia serna on Unsplash

Introduction

Once Statefulset is deployed, volumeClaimTemplates etc. cannot be changed. However, there is a way to change the Volume.

As a result, the volume size in volumeClaimTemplates on the code and the size actually used are different. In that state, if you try to Scale, the volume and size that have already been expanded will be different, and the balance will be lost.

Solution

  • Create PVC according to the naming convention of pvc generated by Volume size + statefulset
  • Scale out

Create PVC

The pvc created from VolumeClaimTemplate is, <volumeClaimTemplateName>-<pod_name>so in this case it was test-storage-4-testing.

...
volumeClaimTemplates:
- metadata:
name: test-storage
annotations:
volume.beta.kubernetes.io/storage-class: gp2-topology-aware
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Gi
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.beta.kubernetes.io/storage-class: gp2-topology-aware
name: test-storage-4-testing
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi

At this time, if volumeBindingMode: WaitForFirstConsumer you are using it, wait until the pod claims and the following message appears

Normal WaitForFirstConsumer 11s (x3 over 20s) persistentvolume-controller waiting for first consumer to be created before binding

 by the author.

--

--

--

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Feather vs Parquet vs CSV vs Jay

Building an API on open data

Handling Conflicts Using Tortoise

images/10-tortoise-update-conflicted.png

Guide on Java Architecture & Components for Beginners

How To Undo Last Git Commit

AMA (#AskMeAnything) with CEO Michael Ein Chaybeh of StreamCoin (STRM) Session 3

How Delete All the Queues From RabbitMQ?

problem statement : root the tree (from codechef lunchtime september 2020)(https://www.codechef.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maciej

Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

More from Medium

Deploy and use ArgoCD with Portainer (part 2)

Prune Container Images from Rancher using Kubernetes CronJob and Binaries

Improve your productivity with Kubernetes using aliases

How to Build a Kubernetes Environment & Scale Production