Creating and configuring a new Che 7.23 workspace

Creating a new workspace from the dashboard

This procedure describes how to create and edit a new Che devfile using the Dashboard.

Prerequisites
  • A running instance of Eclipse Che. To install an instance of Eclipse Che, see Installing Che.

Procedure

To edit the devfile:

  1. In the Workspaces window, click the Add Workspace button. The Custom Workspace page should be opened.

  2. Scroll down to the Devfile section and edit the devfile using Devfile editor.

    Devfile editor with the minimal devfile

    See an example below:

    Example - Adding a .git project into a workspace using a devfile

    In the following instance, the project che acts as the example of a user’s project. A user specifies this project using the name attribute of a devfile. The location attribute defines the source repository represented by an URL to a Git repository or ZIP archive.

    To add a project into the workspace, add or edit the following section:

    projects:
      - name: <che>
        source:
          type: git
          location: 'https://github.com/<github-organization>/<che>.git'

    For additional information, see the Devfile reference section.

Adding projects to your workspace

Prerequisites
Procedure

To add a project to your workspace:

  1. Navigate to Workspaces page and click the workspace you want to update.

    Here you have two ways to add a project to your workspace:

  2. From the Projects tab.

    1. Open the Projects tab, and then click the Add Project button.

    2. Choose if you want to import the project by Git URL or from your GitHub account.

      Add Git Project
  3. From the Devfile tab.

    1. Open the Devfile tab.

    2. In the Devfile editor, add projects section with desired project.

      Edit Devfile Content

      For demonstration example, see below:

      Example - Adding a .git project into a workspace using a devfile

      In the following instance, the project che acts as the example of a user’s project. A user specifies this project using the name attribute of a devfile. The location attribute defines the source repository represented by an URL to a Git repository or ZIP archive.

      To add a project into the workspace, add or edit the following section:

      projects:
        - name: <che>
          source:
            type: git
            location: 'https://github.com/<github-organization>/<che>.git'

      For additional information, see the Devfile reference section.

  1. Once the project is added, click Save button to save this workspace configuration, or click Apply button to apply changes to the running workspace.

    Save Workspace Configuration

Configuring the workspace and adding tools

Adding plug-ins

Prerequisites
Procedure

To add plug-ins to your workspace:

  1. Click the Plugins tab.

  2. Enable the plug-in that you want to add and click the Save button.

Defining the workspace editor

Prerequisites
Procedure

To define the editor to use with the workspace:

  1. Click the Editors tab.

    The recommended editor for Che 7.23 is Che-Theia.
  2. Enable the editor to add and click the Save button.

  3. Click the Devfile tab to view the changes.

    workspace devfile

Defining specific container images

Prerequisites
Procedure

To add a new container image:

  1. In the Devfile tab, add the following section under the components property:

    components:
      - mountSources: true
        command:
          - sleep
        args:
          - infinity
        memoryLimit: 1Gi
        alias: maven3-jdk11
        type: dockerimage
        endpoints:
          - name: 8080/tcp
            port: 8080
        volumes:
          - name: projects
            containerPath: /projects
        image: 'maven:3.6.0-jdk-11'
  2. When using type: kubernetes or type: openshift:

    • Use separate recipe files.

      To use separate recipe files, specify relative or absolute paths:

      Example
      ...
          type: kubernetes
          reference: deploy_k8s.yaml
      ...
      ...
          type: openshift
          reference: deploy_openshift.yaml
      ...
  3. Add a Che 7.22 recipe content to the Che 7.23 devfile as referenceContent:

    component as a referenceContent
    1. Set the type from the original Che 7.22 configuration. The following is an example of the resulting file:

        type: kubernetes
        referenceContent: |
          apiVersion: v1
          kind: Pod
          metadata:
           name: ws
          spec:
           containers:
            -
             image: 'rhche/centos_jdk8:latest'
             name: dev
             resources:
             limits:
               memory: 512Mi
  4. Copy the required fields, such as image, volumes, and endpoints from the old workspace. See below:

    workspace devfile che 7
  5. If needed, change the memoryLimit and alias variables. The field alias is used to set a name for the component and if not manually set, it is generated from the values of the image attribute field.

      image: 'maven:3.6.0-jdk-11'
      alias: maven3-jdk11
  6. To specify the RAM component requirements, set the memoryLimit, memoryRequest, or both.

      alias: maven3-jdk11
      memoryLimit: 256M
      memoryRequest: 128M
  7. Repeat the steps to add additional container images.

Adding commands to your workspace

The following image is a demonstration of workspace configuration commands in Che 7.23:

workspace devfile
Figure 1. An example of the Workspace configuration commands in Che 7.23
Prerequisites
Procedure

To define commands to your workspace, edit the workspace devfile:

  1. Add or edit the command section with the first command. Change the name and the command fields from the original workspace configuration (see the preceding equivalence table).

    commands:
      - name: build
        actions:
          - type: exec
            command: mvn clean install
  2. To add a new command or edit command from other devfile, copy the following YAML code into the command section and define the a command.

    1. Change the name and the command fields from the original workspace configuration, as shown in the introduction screenshot of this chapter.

        - name: build and run
          actions:
            - type: exec
              command: mvn clean install && java -jar
  3. Optionally, add the component field into actions. This indicates the component alias where the command will be performed.

  4. Repeat step 2 to add more commands to the devfile.

  5. Click the Devfile tab to view the changes.

    workspace devfile changes
  6. Save changes and start the new Che 7.23 workspace.

    save and start the new che workspace