Eclipse Che has two components which require Persistent Volumes to store data: * a PostgreSQL database. * an Eclipse Che workspaces. Eclipse Che workspaces store source code using volumes, for example /projects volume.

Source code is stored in the Persistent Volume only if workspace is not ephemeral.

Eclipse Che does not create Persisted Volumes in the infrastructure. Eclipse Che uses Persisted Volume Claims (PVC) to mount Persisted Volumes. Eclipse Che server creates Persisted Volume Claims. You can define storage class name in the Eclipse Che configuration to use storage classes feature in the Eclipse Che PVC. With storage classes, you can configure infrastructure storage in a flexible way with a lot of storage parameters. You can also bind static provisioned Persisted Volumes to Eclipse Che PVC using class name.

Defining storage class names with the server:start command

Procedure
  • To provide storage class name for PostgreSQL PVC, use the chectl server:start command with the --postgres-pvc-storage-class-name flag:

    $ chectl server:start -m -p minikube -a operator --postgres-pvc-storage-class-name=postgress-storage
  • To provide storage class name for Che workspaces, use the server:start command with the --workspace-pvc-storage-class-name flag:

    $ chectl server:start -m -p minikube -a operator --workspace-pvc-storage-class-name=workspace-storage

For Eclipse Che workspaces, storage class name has different behavior depending on a workspace PVC strategy.

postgres-pvc-storage-class-name=postgress-storage and workspace-pvc-storage-class-name work for the Operator installer and the Helm installer.

Defining storage class names using a custom resources YAML file

You can define storage classes names using Eclipse Che custom resources definition YAML.

Procedure
  1. Create a YAML file with custom resources defined for the Eclipse Che installation.

  2. Define fields: spec#storage#postgresPVCStorageClassName and spec#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'
        # ...
  3. Start the che server with your custom resources:

    $ chectl server:start -m -p minikube -a operator --che-operator-cr-yaml=/path/to/custom/che/resource/org_v1_che_cr.yaml

Binding static provisioned volumes

Administrators can provision Persisted Volumes using class names.

Procedure
  1. Define 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"
  2. Define 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"
  3. Bind the two Persisted 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 permission, define storageClass#mountOptions uid and gid. PostgreSQL volume requires uid=26 and gid=26.

Configuring Eclipse Che to store workspaces in one Persisted Volume

Procedure

To configure Eclipse Che to store all workspaces in one Persisted Volume:

  1. Modify your custom resources YAML file:

    • Set pvcStrategy as common.

    • Configure Che to start workspaces in the single namespace.

    • Define storage class names for postgresPVCStorageClassName and workspacePVCStorageClassName.

    • 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'
          # ...
  2. Start the che server with your custom resources:

    $ chectl server:start -m -p minikube -a operator --che-operator-cr-yaml=/path/to/custom/che/resource/org_v1_che_cr.yaml