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:
Annotation | Default | Description |
---|---|---|
volume-expander-operator.redhat-cop.io/autoexpand |
N/A | if set to "true" enables the volume-expander-operator to watch on this PVC |
volume-expander-operator.redhat-cop.io/polling-frequency |
"30s" |
How frequently to poll the volume metrics. Express this value as a valid golang Duration |
volume-expander-operator.redhat-cop.io/expand-threshold-percent |
"80" |
the percentage of used storage after which the volume will be expanded. This must be a positive integer. |
volume-expander-operator.redhat-cop.io/expand-by-percent |
"25" |
the percentage by which the volume will be expanded, relative to the current size. This must be an integer between 0 and 100 |
volume-expander-operator.redhat-cop.io/expand-up-to |
MaxInt64 | the 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.
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
.
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.
- 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
orManual
). - 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.
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.
Here are the instructions to install the latest release with Helm.
oc new-project volume-expander-operator
helm repo add volume-expander-operator https://redhat-cop.github.io/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
oc new-project volume-expander-operator-local
oc apply -f config/rbac/role.yaml -n volume-expander-operator-local
oc apply -f config/rbac/role_binding.yaml -n volume-expander-operator-local
export token=export token=$(oc serviceaccounts get-token 'default' -n volume-expander-operator-local)
export base_domain=$(oc get dns cluster -o jsonpath='{.spec.baseDomain}')
export prometheus_route=https://prometheus-k8s-openshift-monitoring.apps.${base_domain}
oc login --token ${token}
make run ENABLE_WEBHOOKS=false PROMETHEUS_URL=${prometheus_route} TOKEN=${token}
export repo=raffaelespazzoli #replace with yours
make docker-build IMG=quay.io/$repo/volume-expander-operator:latest
make docker-push IMG=quay.io/$repo/volume-expander-operator:latest
make manifests
make bundle IMG=quay.io/$repo/volume-expander-operator:latest
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
make bundle-build BUNDLE_IMG=quay.io/$repo/volume-expander-operator-controller-bundle:latest
podman push quay.io/$repo/volume-expander-operator-controller-bundle:latest
operator-sdk bundle validate quay.io/$repo/volume-expander-operator-controller-bundle:latest --select-optional name=operatorhub
oc new-project volume-expander-operator
operator-sdk cleanup volume-expander-operator -n volume-expander-operator
operator-sdk run bundle --install-mode AllNamespaces -n volume-expander-operator quay.io/$repo/volume-expander-operator-controller-bundle:latest
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>
operator-sdk cleanup volume-expander-operator -n volume-expander-operator
oc delete operatorgroup operator-sdk-og
oc delete catalogsource volume-expander-operator-catalog
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