Switching a component to a different storage class
When deployed, Stackland assigns a default storage class, the one specified in StacklandClusterConfig.spec.storage.defaultStorageClass. This class is annotated with storageclass.kubernetes.io/is-default-class: "true" and used for all PVCs where the storage class is not explicitly specified.
For databases, the preferred choice is usually SSD or NVMe, and for object storage, HDD. If a component requires a storage class different from the one specified during installation, specify it explicitly in the component configuration.
Warning
Data is not transferred automatically when changing the storage class.
Changing the storage class results in PVC re-creation and data loss. Perform the operation before writing user data, ideally during initial deployment.
Getting started
-
Make sure the required storage class exists in the cluster:
kubectl get storageclasses -
Make sure the nodes have disks of the appropriate type:
kubectl get volumegroups -A -o wide
For more information about the available storage classes, see the Disk subsystem section.
Changing the default storage class
You can specify a default storage class for all or individual components.
Changing the storage class for all components
The default storage class is defined by the storageclass.kubernetes.io/is-default-class: "true" annotation of the StorageClass resource. You can move this annotation to another storage class. After this, all new PVCs that do not explicitly specify a storage class will use the new default class.
To change the default storage class:
-
Remove the annotation from the current default class:
kubectl annotate storageclass <current_class> storageclass.kubernetes.io/is-default-class- -
Set an annotation on the new class:
kubectl annotate storageclass <new_class> storageclass.kubernetes.io/is-default-class=true
Warning
Changing the default class only affects new PVCs. Existing PVCs retain their previous storage class.
Changing the storage class for an individual component
To change the storage class for a specific platform component, specify the appropriate field in the component configuration.
Managed databases
PostgreSQL, ClickHouse®, and Apache Kafka® do not require configuring the storage class at the component level. Clusters use the default storage class. To specify a storage class other than the default, specify it in the manifest when creating the cluster.
Object Storage
apiVersion: stackland.yandex.cloud/v1alpha1
kind: StorageConfig
metadata:
name: main
spec:
enabled: false
settings:
storage:
diskType: HDD
servers: 3
size: 154Gi
storageClass: "stackland-hdd"
Changing the storage class for custom DB clusters
Database clusters use the default storage class if the storageClass attribute is not specified in the cluster specification. To set a storage class for a specific cluster, specify it in the manifest when creating it.
You cannot change the storage class for already created PostgreSQL, ClickHouse®, and Apache Kafka® clusters.
PostgreSQL
Specify the spec.storage.storageClass field in the PostgresqlCluster resource:
apiVersion: postgresql.stackland.yandex.cloud/v1alpha1
kind: PostgresqlCluster
metadata:
name: <cluster_name>
spec:
storage:
size: 10Gi
storageClass: "stackland-ssd"
# ...
To learn more, see Creating a PostgreSQL cluster.
ClickHouse®
Specify the spec.clickhouse.storage.storageClass and spec.keeper.storage.storageClass fields in the ClickhouseCluster resource:
apiVersion: clickhouse.stackland.yandex.cloud/v1alpha1
kind: ClickhouseCluster
metadata:
name: <cluster_name>
spec:
clickhouse:
storage:
size: 10Gi
storageClass: "stackland-ssd"
# ...
keeper:
storage:
size: 5Gi
storageClass: "stackland-ssd"
To learn more, see Creating a Managed Service for ClickHouse® cluster.
Apache Kafka®
Specify the spec.controller.storage.storageClass and spec.broker.storage.storageClass fields in the KafkaCluster resource:
apiVersion: kafka.stackland.yandex.cloud/v1alpha1
kind: KafkaCluster
metadata:
name: <cluster_name>
spec:
controller:
storage:
size: 5Gi
storageClass: "stackland-ssd"
broker:
storage:
size: 20Gi
storageClass: "stackland-ssd"
# ...
For more information on creating a cluster, see this section.
Switching the storage class for system components
For system components, specify the storage class in the component's configuration file. If the component is already running, follow the procedure in the Changing the storage class for an existing data component section.
Logging (Loki)
Specify the spec.settings.logStorage.storage.storageClass field in the LoggingConfig resource:
apiVersion: stackland.yandex.cloud/v1alpha1
kind: LoggingConfig
metadata:
name: main
spec:
enabled: true
settings:
logStorage:
storage:
enabled: true
storageClass: "stackland-hdd"
size: 50Gi
Secrets Store (OpenBao)
Specify the spec.settings.server.dataStorage.storageClass field in the SecretsStoreConfig resource:
apiVersion: stackland.yandex.cloud/v1alpha1
kind: SecretsStoreConfig
metadata:
name: main
spec:
enabled: true
settings:
server:
dataStorage:
size: 2Gi
storageClass: "stackland-ssd"
DataLens
Specify the spec.settings.database.storageClass field in the DataLensConfig resource:
apiVersion: stackland.yandex.cloud/v1alpha1
kind: DataLensConfig
metadata:
name: main
spec:
enabled: true
settings:
database:
storageSize: "2Gi"
storageClass: "stackland-ssd"
Object Storage
Specify the spec.settings.storage.storageClass field in the StorageConfig resource:
apiVersion: stackland.yandex.cloud/v1alpha1
kind: StorageConfig
metadata:
name: main
spec:
enabled: false
settings:
storage:
diskType: HDD
servers: 3
size: 154Gi
storageClass: "stackland-hdd"
Changing the storage class for an existing data component
Changing the storage class requires disabling and re-enabling the component.
Alert
This operation results in complete loss of data on the affected PVCs. Make sure you have a backup you can restore your data from.
To change the storage class for an already running component:
-
Create a backup of your data.
-
Disable the component. For system components, install
spec.enabled: falseand apply the manifest:kubectl apply -f <configuration_file>.yamlFor custom DB clusters, delete the cluster resource:
kubectl delete <resource_type> <cluster_name> -n <project_name> -
Delete the component PVCs:
kubectl delete pvc <pvc_name> -n <namespace>To get a list of component PVCs:
kubectl get pvc -n <namespace> -
In the manifest, specify the new storage class and re-enable the component (
spec.enabled: true). -
Apply the manifest:
kubectl apply -f <configuration_file>.yaml -
Restore data from the backup.