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.

Persistent volume claims facts:
  • 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.

Procedure

Use CheCluster custom resource definition to define storage classes:

  1. Define storage class names

    To do so, use one of the following methods:

    • Use arguments for the server:start command

      1. Provide the storage class name for the 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
      2. Provide the storage class name for the 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 Che workspaces, the storage class name has different behavior depending on the 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.

    • Define storage class names using a custom resources YAML file:

      1. Create a YAML file with custom resources defined for the 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
  2. Configure Che to store workspaces in one persistent volume and a PostreSQL database in the second one:

    1. Modify your custom resources YAML file:

      • Set pvcStrategy as common.

      • Configure Che to start workspaces in a 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
  3. Bind static provisioned volumes using class names:

    1. 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"
    2. 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"
    3. 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 storageClass#mountOptions uid and gid. PostgreSQL volume requires uid=26 and gid=26.

Tags: