Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
    • All guides
    • Connecting to a node over SSH
    • Connecting to a node via OS Login
    • Updating Kubernetes
    • Configuring autoscaling
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Increasing volume size for the StatefulSet controller
      • Mounting a volume in block mode
      • Integration with Object Storage
    • Connecting external nodes to the cluster
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Create a StatefulSet controller
  • Update controller settings
  1. Step-by-step guides
  2. Working with persistent volumes
  3. Increasing volume size for the StatefulSet controller

Increasing volume size for the StatefulSet controller

Written by
Yandex Cloud
Updated at April 10, 2025
  • Create a StatefulSet controller
  • Update controller settings

To increase volume size for the StatefulSet controller without shutting down the service:

  1. Create a StatefulSet controller.
  2. Update controller settings.

Before you start, install kubectl and configure it to work with the created Managed Service for Kubernetes cluster.

Create a StatefulSet controllerCreate a StatefulSet controller

  1. Create a file named sts.yaml with the controller configuration:

    sts.yaml
    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: ubuntu-test
    spec:
      selector:
        matchLabels:
          app: ubuntu
      serviceName: "ubuntu"
      replicas: 3
      template:
        metadata:
          labels:
            app: ubuntu
        spec:
          terminationGracePeriodSeconds: 10
          containers:
          - name: ubuntu
            image: ubuntu
            command: ["/bin/sh"]
            args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"]
            volumeMounts:
            - mountPath: /data
              name: pvc-dynamic
      volumeClaimTemplates:
      - metadata:
          name: pvc-dynamic
        spec:
          accessModes: [ "ReadWriteOnce" ]
          storageClassName: "yc-network-hdd"
          resources:
            requests:
              storage: 1Gi
    
  2. Create a controller:

    kubectl apply -f sts.yaml
    

    The command will create a StatefulSet controller named ubuntu-test comprising three pods. The size of PersistentVolumeClaim per pod is 1 GB.

  3. Make sure the controller pods changed their status to Running and PersistentVolumeClaim, to Bound:

    kubectl get pods,pvc
    

    Result:

    NAME               READY  STATUS   RESTARTS  AGE
    pod/ubuntu-test-0  1/1    Running  0         90s
    pod/ubuntu-test-1  1/1    Running  0         80s
    pod/ubuntu-test-2  1/1    Running  0         72s
    
    NAME                                             STATUS  VOLUME                                    CAPACITY  ACCESS MODES  STORAGECLASS    AGE
    persistentvolumeclaim/pvc-dynamic-ubuntu-test-0  Bound   pvc-603ac129-fe56-400a-8481-feaa********  1Gi       RWO           yc-network-hdd  91s
    persistentvolumeclaim/pvc-dynamic-ubuntu-test-1  Bound   pvc-a6fb0761-0771-483c-abfb-d4a8********  1Gi       RWO           yc-network-hdd  81s
    persistentvolumeclaim/pvc-dynamic-ubuntu-test-2  Bound   pvc-f479c8aa-426a-4e43-9749-5e0f********  1Gi       RWO           yc-network-hdd  73s
    
  4. Make sure the disks for objects with the k8s-csi prefix changed their status to READY:

    yc compute disk list
    

    Result:

    +----------------------+--------------------------------------------------+------------+-------------------+--------+----------------------+-------------+
    |          ID          |                       NAME                       |    SIZE    |        ZONE       | STATUS |     INSTANCE IDS     | DESCRIPTION |
    +----------------------+--------------------------------------------------+------------+-------------------+--------+----------------------+-------------+
    | ef3b5ln111s3******** | k8s-csi-15319ac44278c2ff23f0df04ebdbe5a8******** | 1073741824 | ru-central1-a     | READY  | ef3nrev9j72t******** |             |
    | ef3e617rmqri******** | k8s-csi-336f16a11f750525075d7c155ad26ae3******** | 1073741824 | ru-central1-a     | READY  | ef3nrev9j72t******** |             |
    | ef3rfleqkit0******** | k8s-csi-ba784ddd49c7aabc63bcbfc45be3cc2e******** | 1073741824 | ru-central1-a     | READY  | ef3nrev9j72t******** |             |
    +----------------------+--------------------------------------------------+------------+-------------------+--------+----------------------+-------------+
    

Update controller settingsUpdate controller settings

  1. Save the current configuration of the ubuntu-test controller to a file named ubuntu-test-sts.yaml:

    kubectl get sts ubuntu-test --output yaml > ubuntu-test-sts.yaml
    
  2. In ubuntu-test-sts.yaml, increase the volumeClaimTemplates.spec.resources.requests.storage value from 1Gi to 2Gi:

    ...
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 2Gi
    

    Note

    You do not have to change the same 1Gi value for the kubectl.kubernetes.io/last-applied-configuration parameter.

  3. Delete the current StatefulSet controller named ubuntu-test:

    kubectl delete statefulset ubuntu-test --cascade=orphan
    
  4. Make sure the StatefulSet controller has been deleted:

    kubectl get sts
    
  5. Delete the first pod named ubuntu-test-0:

    kubectl delete pod ubuntu-test-0
    
  6. Update PersistentVolumeClaim of the ubuntu-test-0 pod you deleted by increasing the storage size to 2 GB:

    kubectl patch pvc pvc-dynamic-ubuntu-test-0 --patch '{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
    
  7. Apply the changes to the ubuntu-test controller:

    kubectl apply -f ubuntu-test-sts.yaml
    
  8. Reduce the number of the ubuntu-test controller pods to 1:

    kubectl scale statefulset ubuntu-test --replicas=1
    
  9. Increase the storage size for the ubuntu-test-1 and ubuntu-test-2 pods to 2 GB:

    kubectl patch pvc pvc-dynamic-ubuntu-test-1 --patch '{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}' && \
    kubectl patch pvc pvc-dynamic-ubuntu-test-2 --patch '{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
    
  10. Set the number of the ubuntu-test controller pods back to 3:

    kubectl scale statefulset ubuntu-test --replicas=3
    
  11. Make sure PersistentVolume for the ubuntu-test controller has been increased to 2 GB for each volume:

    kubectl get pv
    

    Result:

    NAME                                      CAPACITY  ACCESS MODES  RECLAIM POLICY  STATUS  CLAIM                              STORAGECLASS    REASON  AGE
    pvc-603ac129-fe56-400a-8481-feaa********  2Gi       RWO           Delete          Bound   default/pvc-dynamic-ubuntu-test-0  yc-network-hdd          11m
    pvc-a6fb0761-0771-483c-abfb-d4a8********  2Gi       RWO           Delete          Bound   default/pvc-dynamic-ubuntu-test-1  yc-network-hdd          11m
    pvc-f479c8aa-426a-4e43-9749-5e0f********  2Gi       RWO           Delete          Bound   default/pvc-dynamic-ubuntu-test-2  yc-network-hdd          11m
    

Was the article helpful?

Previous
Expanding a pod volume
Next
Mounting a volume in block mode
© 2025 Direct Cursus Technology L.L.C.