Installing Che using 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 two components that require persistent volumes to store data:
-
A PostgreSQL database.
-
A Che workspaces. Che workspaces store source code using volumes, for example
/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 CheCluster Custom Resource definition to define storage classes:
-
Define storage class names
To do so, use one of the following methods:
-
Use arguments for the
server:deploy
command-
Provide the storage class name for the PostgreSQL PVC
Use the
chectl
server:deploy
command with the--postgres-pvc-storage-class-name
flag:$ chectl server:deploy -m -p minikube -a operator --postgres-pvc-storage-class-name=postgress-storage
-
Provide the storage class name for the Che workspaces
Use the
server:deploy
command with the--workspace-pvc-storage-class-name
flag:$ chectl server:deploy -m -p minikube -a operator --workspace-pvc-storage-class-name=workspace-storage
For Che workspaces, the storage class name has different behavior depending on the workspace PVC strategy.
postgres-pvc-storage-class-name=postgress-storage
andworkspace-pvc-storage-class-name
work for the Operator installer and the Helm installer.
-
-
Define storage class names using a Custom Resources YAML file:
-
Create a YAML file with Custom Resources defined for the Che installation.
-
Define fields:
spec#storage#postgresPVCStorageClassName
andspec#storage#workspacePVCStorageClassName
.apiVersion: org.eclipse.che/v1 kind: CheCluster metadata: name: eclipse-che spec: # ... storage: # ... # keep blank unless you need to use a non default storage class for PostgreSQL PVC postgresPVCStorageClassName: 'postgres-storage' # ... # keep blank unless you need to use a non default storage class for workspace PVC(s) workspacePVCStorageClassName: 'workspace-storage' # ...
-
Start the che server with your Custom Resources:
$ chectl server:deploy -m -p minikube -a operator --che-operator-cr-yaml=/path/to/custom/che/resource/org_v1_che_cr.yaml
-
-
-
Configure Che to store workspaces in one persistent volume and a PostreSQL database in the second one:
-
Modify your Custom Resources YAML file:
-
Set
pvcStrategy
ascommon
. -
Configure Che to start workspaces in a single namespace.
-
Define storage class names for
postgresPVCStorageClassName
andworkspacePVCStorageClassName
. -
Example of the YAML file:
apiVersion: org.eclipse.che/v1 kind: CheCluster metadata: name: eclipse-che spec: server: # ... workspaceNamespaceDefault: 'che' # ... storage: # ... # Defaults to common pvcStrategy: 'common' # ... # keep blank unless you need to use a non default storage class for PostgreSQL PVC postgresPVCStorageClassName: 'postgres-storage' # ... # keep blank unless you need to use a non default storage class for workspace PVC(s) workspacePVCStorageClassName: 'workspace-storage' # ...
-
-
Start the che server with your Custom Resources:
$ chectl server:deploy -m -p minikube -a operator --che-operator-cr-yaml=/path/to/custom/che/resource/org_v1_che_cr.yaml
-
-
Bind static provisioned volumes using class names:
-
Define the persistent volume for a PostgreSQL database:
# che-postgres-pv.yaml apiVersion: v1 kind: PersistentVolume metadata: name: postgres-pv-volume labels: type: local spec: storageClassName: postgres-storage capacity: storage: 1Gi accessModes: - ReadWriteOnce hostPath: path: "/data/che/postgres"
-
Define the persistent volume for a Che workspace:
# che-workspace-pv.yaml apiVersion: 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 two persistent volumes:
-
$ kubectl apply -f che-workspace-pv.yaml -f che-postgres-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 |