Configuring storage classes
To configure Che to use a configured infrastructure storage, install Che using storage classes. This is especially useful when a user wants to bind a persistent volume provided by a non-default provisioner. To do so, a user binds this storage for the Che data saving and sets the parameters for that storage. These parameters can determine the following:
-
A special host path
-
A storage capacity
-
A volume mod
-
Mount options
-
A file system
-
An access mode
-
A storage type
-
And many others
Che has one component that requires persistent volumes to store data: A Che workspace. Che workspaces store source code using volumes, for example the /projects
volume.
Che workspaces source code is stored in the persistent volume only if a workspace is not ephemeral. |
-
Che does not create persistent volumes in the infrastructure.
-
Che uses persistent volume claims (PVC) to mount persistent volumes.
-
The Che server creates persistent volume claims.
A user defines a storage class name in the Che configuration to use the storage classes feature in the Che PVC. With storage classes, a user configures infrastructure storage in a flexible way with additional storage parameters. It is also possible to bind a static provisioned persistent volumes to the Che PVC using the class name.
Use the CheCluster
Custom Resource definition to define storage classes:
-
Define storage class names: configure the
CheCluster
Custom Resource, and install Che. See Using chectl to configure theCheCluster
Custom Resource during installation.spec: devEnvironments: storage: pvc: # keep blank unless you need to use a non default storage class for workspace PVC(s) storageClass: 'workspace-storage'
-
Define the persistent volume for a Che workspace in a
che-workspace-pv.yaml
file:che-workspace-pv.yaml
fileapiVersion: v1 kind: PersistentVolume metadata: name: workspace-pv-volume labels: type: local spec: storageClassName: workspace-storage capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "/data/che/workspace"
-
Bind the persistent volume:
$ kubectl apply -f che-workspace-pv.yaml
You must provide valid file permissions for volumes. You can do it using storage class configuration or manually. To manually define permissions, define |