How to resize Kubernetes volumes (AWS EBS) on versions 1.8 without the alpha feature activated?

3/14/2019

Have anyone managed to resize a k8s volume (AWS EBS) with zero downtime on k8s 1.8 without using the volume expansion alpha feature? I’m trying to find a way to do that in one of my Statefulsets clusters (3 replicas) but don’t know how.

With outage, I can do that by simply:

  1. Scale my Statefulsets to 0 replicas
  2. Create a snapshot of each of my AWS EBS Volumes
  3. Provisioning 3 new bigger EBS volumes by using the snapshots created on step 2
  4. Delete current k8s PVCs and PVs
  5. Recreate my PVs and PVCs by pointing out to the new EBS volumes provisioned on step 3
  6. Scale my Statefulsets up again…

But how to do that preventing outage? I cannot use the k8s alpha features and I cannot upgrade my k8s cluster yet.

Another thing I considered was in step 1, scale it down to 1 replica instead, thus I could expand my volumes of the PODs 1 and 2 while POD 0 was still up and running, but how will I do that on POD 0 later on? There's a way to turn of a specific POD of a Stetfulsets? Eg.: Turn off POD 0 in order I can expand its volume after have done for POD 1 and 2?

-- Bruno Ambrozio
aws-ebs
kubernetes
kubernetes-pvc
persistent-volumes

1 Answer

4/15/2019

I would have skipped step 4 and just created a new statefulset pointing to the new PV

  volumeClaimTemplate:
  spec:
    selector:
      matchLabels:
        app: my-stateful-app
    resources:
      requests:
        storage: 50Gi

Respective PV

apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv-name
  labels:
    app: my-stateful-app
spec:
  capacity:
    storage: 50Gi
  accessModes:
  - ReadWriteOnce
  awsElasticBlockStore:
    volumeID: <volume-id>
    fsType: ext4
-- Bobby Donchev
Source: StackOverflow