go get

by redhat-cop

v0.3.2 (see all)License:Apache-2.0
go get

Volume Expander Operator

The purpose of the volume-expander-operator is to expand volumes when they are running out of space. This is achieved by using the volume expansion feature.

The operator periodically checks the kubelet_volume_stats_used_bytes and kubelet_volume_stats_capacity_bytes published by the kubelets to decide when to expand a volume. Notice that these metrics are generated only when a volume is mounted to a pod. Also the kubelet takes a minute or two to start generating accurate values for these metrics. The operator accounts for that.

This operator works based on the following annotations to PersistentVolumeClaim resources:

AnnotationDefaultDescription set to "true" enables the volume-expander-operator to watch on this PVC"30s"How frequently to poll the volume metrics. Express this value as a valid golang Duration"80"the percentage of used storage after which the volume will be expanded. This must be a positive integer."25"the percentage by which the volume will be expanded, relative to the current size. This must be an integer between 0 and 100 upper bound for this volume to be expanded to. The default value is the largest quantity representable and is intended to be interpreted as infinite. If the default is used it is recommend to ensure the namespace has a quota on the used storage class.

Note that not all of the storage driver implementations support volume expansion. It is a responsibility of the user/platform administrator to ensure that storage class and the persistent volume claim meet all the requirements needed for the volume expansion feature to work properly.

This operator was tested with OCS, but should work with any other storage driver that supports volume expansion.

Deploying the Operator

This is a cluster-level operator that you can deploy in any namespace, volume-expander-operator is recommended.

It is recommended to deploy this operator via OperatorHub, but you can also deploy it using Helm.

Multiarch Support


Deploying from OperatorHub

Note: This operator supports being installed disconnected environments

If you want to utilize the Operator Lifecycle Manager (OLM) to install this operator, you can do so in two ways: from the UI or the CLI.

Deploying from OperatorHub UI

  • If you would like to launch this operator from the UI, you'll need to navigate to the OperatorHub tab in the console.Before starting, make sure you've created the namespace that you want to install this operator to with the following:
oc new-project volume-expander-operator
  • Once there, you can search for this operator by name: volume expander operator. This will then return an item for our operator and you can select it to get started. Once you've arrived here, you'll be presented with an option to install, which will begin the process.
  • After clicking the install button, you can then select the namespace that you would like to install this to as well as the installation strategy you would like to proceed with (Automatic or Manual).
  • Once you've made your selection, you can select Subscribe and the installation will begin. After a few moments you can go ahead and check your namespace and you should see the operator running.

Volume Expander Operator

Deploying from OperatorHub using CLI

If you'd like to launch this operator from the command line, you can use the manifests contained in this repository by running the following:

oc new-project volume-expander-operator

oc apply -f config/operatorhub -n volume-expander-operator

This will create the appropriate OperatorGroup and Subscription and will trigger OLM to launch the operator in the specified namespace.

Deploying with Helm

Here are the instructions to install the latest release with Helm.

oc new-project volume-expander-operator
helm repo add volume-expander-operator
helm repo update
helm install volume-expander-operator volume-expander-operator/volume-expander-operator

This can later be updated with the following commands:

helm repo update
helm upgrade volume-expander-operator volume-expander-operator/volume-expander-operator


Prometheus compatible metrics are exposed by the Operator and can be integrated into OpenShift's default cluster monitoring. To enable OpenShift cluster monitoring, label the namespace the operator is deployed in with the label"true".

oc label namespace <namespace>"true"

Testing metrics

export operatorNamespace=volume-expander-operator-local # or volume-expander-operator
oc label namespace ${operatorNamespace}"true"
oc rsh -n openshift-monitoring -c prometheus prometheus-k8s-0 /bin/bash
export operatorNamespace=volume-expander-operator-local # or volume-expander-operator
curl -v -s -k -H "Authorization: Bearer $(cat /var/run/secrets/" https://volume-expander-operator-controller-manager-metrics.${operatorNamespace}.svc.cluster.local:8443/metrics


Running the operator locally

Note: this operator build process is tested with podman, but some of the build files (Makefile specifically) use docker because they are generated automatically by operator-sdk. It is recommended remap the docker command to the podman command.

export repo=raffaelespazzoli
docker login$repo
oc new-project volume-expander-operator
oc project volume-expander-operator
tilt up

Test helm chart locally

Define an image and tag. For example...

export imageRepository=""
export imageTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3)"

Deploy chart...

make helmchart IMG=${imageRepository} VERSION=${imageTag}
helm upgrade -i volume-expander-operator-local charts/volume-expander-operator -n volume-expander-operator-local --create-namespace


helm delete volume-expander-operator-local -n volume-expander-operator-local

Building/Pushing the operator image

export repo=raffaelespazzoli #replace with yours
docker login$repo
make docker-build$repo/volume-expander-operator:latest
make docker-push$repo/volume-expander-operator:latest

Deploy to OLM via bundle

make manifests
make bundle$repo/volume-expander-operator:latest
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
make bundle-build$repo/volume-expander-operator-controller-bundle:latest
docker push$repo/volume-expander-operator-controller-bundle:latest
operator-sdk bundle validate$repo/volume-expander-operator-controller-bundle:latest --select-optional name=operatorhub
oc new-project volume-expander-operator
oc label namespace volume-expander-operator"true"
operator-sdk cleanup volume-expander-operator -n volume-expander-operator
operator-sdk run bundle --install-mode AllNamespaces -n volume-expander-operator$repo/volume-expander-operator-controller-bundle:latest


Manual tests

oc new-project volume-expander-operator-test
oc apply -f ./test/volume.yaml -n volume-expander-operator-test
oc apply -f ./test/deployment.yaml -n volume-expander-operator-test


git tag -a "<tagname>" -m "<commit message>"
git push upstream <tagname>

If you need to remove a release:

git tag -d <tagname>
git push upstream --delete <tagname>

If you need to "move" a release to the current main

git tag -f <tagname>
git push upstream -f <tagname>

Cleaning up

operator-sdk cleanup volume-expander-operator -n volume-expander-operator
oc delete operatorgroup operator-sdk-og
oc delete catalogsource volume-expander-operator-catalog

GitHub Stars



3mos ago








6mos ago
6mos ago
9mos ago
10mos ago
No alternatives found
No tutorials found
Add a tutorial