How to expand a PVC on CloudBees CI

Article ID:360051771151
2 minute readKnowledge base

Issue

  • I want to be able to extend the size of the PVC associated with my managed controller in CloudBees CI.

  • The field Jenkins controller Disk Space in GB is disabled.

Resolution

First of all, you need to determine if the storage class that the PVC is using is properly configured so that it allows volume expansion.

We can verify the value of the property by following one of the options shown below:

Option 1

  1. We need to gather the PVC name:

    kubectl describe pod <your_pod_name_here> -n <your_namespace> | grep ClaimName
  2. After that, using the output from step 1, we can get the storage class that you are using:

    kubectl describe pvc <claim_name_from_previous_step> -n <your_namespace> | grep StorageClass
  3. Finally, using the output from step 2, we can check if the property is set:

    kubectl describe storageclass <your_storage_class> -n <your_namespace> | grep AllowVolumeExpansion

Option 2

Use the script shown below:

#!/bin/bash

NAMESPACE=<your_namespace>
POD=<your_pod_name_here>

PVC=$(kubectl -n $NAMESPACE get pod $POD -o jsonpath='{.spec.volumes[?(@.name=="jenkins-home")].persistentVolumeClaim.claimName}')
STORAGE=$(kubectl -n $NAMESPACE get pvc $PVC -o jsonpath='{.spec.storageClassName}')
kubectl get storageclass $STORAGE -o jsonpath='{.allowVolumeExpansion}'

If the property is set to true, then we are good to continue. Otherwise, we will get something like:

AllowVolumeExpansion:  <unset>

If that’s the case, then we will need to edit the storage class and set the property to true. We need to add the property allowVolumeExpansion: true to the storage class:

kubectl edit storageclass <your_storage_class> -n <your_namespace>

The code property has to have the same indentation as shown below:

 apiVersion: storage.k8s.io/v1
 kind: StorageClass
 allowVolumeExpansion: true

Once you have confirmed that the property value is set to true, the next steps would be:

  1. In your operations center, edit the managed controller configuration and set the new volume size under Jenkins controller Disk Space in GB.

  2. Restart the managed controller, and observe the new volume size.

Volumes cannot be made smaller.