Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generated DevWorkspaceTemplates from the devfile registry to create workspaces #20829

Closed
Tracked by #20830
svor opened this issue Nov 25, 2021 · 2 comments · Fixed by eclipse-che/che-dashboard#429
Assignees
Labels
area/dashboard engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system. sprint/current

Comments

@svor
Copy link
Contributor

svor commented Nov 25, 2021

Is your task related to a problem? Please describe

Since Pre-build DevWorkspace templates for devfile v2 of devfile registry #19718 was fixed, devfile registry generates and provides DevWorkspaceTemplate+DevWorkspace for each devfile v2.

In devfile registry it could be recognized in index.json, for example for Go devfile it looks like:

{
  "displayName": "Go",
  "description": "Stack with Go 1.14",
  "tags": [
    "Debian",
    "Go"
  ],
  "icon": "/images/go.svg",
  "links": {
    "v2": "https://github.com/che-samples/golang-echo-example/tree/devfile2",
    "devWorkspaces": {
       "eclipse/che-theia/latest": "/devfiles/go/devworkspace-che-theia-latest.yaml"
       "eclipse/che-theia/next": "/devfiles/go/devworkspace-che-theia-next.yaml"
    },
    "self": "/devfiles/go/devfile.yaml"
  }
}

It means that each stack which provides devfile version 2 should contain 2 files:

  • devworkspace-che-theia-latest.yaml
  • devworkspace-che-theia-next.yaml

The content of such file should be like:

devworkspace

apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspaceTemplate
metadata:
  name: theia-ide-spring-petclinic
spec:
  commands:
    - id: init-container-command
      apply:
        component: remote-runtime-injector
  events:
    preStart:
      - init-container-command
  components:
    - name: theia-ide
      container:
        image: quay.io/eclipse/che-theia:next
        env:
          - name: THEIA_PLUGINS
            value: local-dir:///plugins
          - name: HOSTED_PLUGIN_HOSTNAME
            value: 0.0.0.0
          - name: HOSTED_PLUGIN_PORT
            value: '3130'
          - name: THEIA_HOST
            value: 127.0.0.1
        volumeMounts:
          - name: plugins
            path: /plugins
          - name: theia-local
            path: /home/theia/.theia
        mountSources: true
        memoryLimit: 512M
        cpuLimit: 1500m
        cpuRequest: 100m
        endpoints:
          - name: theia
            attributes:
              type: main
              cookiesAuthEnabled: true
              discoverable: false
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            secure: false
            protocol: https
          - name: webviews
            attributes:
              type: webview
              cookiesAuthEnabled: true
              discoverable: false
              unique: true
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            secure: false
            protocol: https
          - name: mini-browser
            attributes:
              type: mini-browser
              cookiesAuthEnabled: true
              discoverable: false
              unique: true
              urlRewriteSupported: true
            targetPort: 3100
            exposure: public
            secure: false
            protocol: https
          - name: theia-dev
            attributes:
              type: ide-dev
              discoverable: false
              urlRewriteSupported: true
            targetPort: 3130
            exposure: public
            protocol: http
          - name: theia-redirect-1
            attributes:
              discoverable: false
              urlRewriteSupported: true
            targetPort: 13131
            exposure: public
            protocol: http
          - name: theia-redirect-2
            attributes:
              discoverable: false
              urlRewriteSupported: true
            targetPort: 13132
            exposure: public
            protocol: http
          - name: theia-redirect-3
            attributes:
              discoverable: false
              urlRewriteSupported: true
            targetPort: 13133
            exposure: public
            protocol: http
          - name: terminal
            attributes:
              type: collocated-terminal
              discoverable: false
              cookiesAuthEnabled: true
              urlRewriteSupported: true
            targetPort: 3333
            exposure: public
            secure: false
            protocol: wss
      attributes:
        app.kubernetes.io/component: che-theia
        app.kubernetes.io/part-of: che-theia.eclipse.org
        che-theia.eclipse.org/vscode-extensions:
          - >-
            https://github.com/che-incubator/che-theia-openshift-auth/releases/download/0.0.3/che-openshift-authentication-plugin-0.0.3.vsix
    - name: plugins
      volume: {}
    - name: theia-local
      volume: {}
    - name: che-machine-exec
      container:
        image: quay.io/eclipse/che-machine-exec:next
        command:
          - /go/bin/che-machine-exec
          - '--url'
          - 127.0.0.1:3333
          - '--idle-timeout'
          - 15m
        memoryLimit: 128Mi
        memoryRequest: 32Mi
        cpuLimit: 500m
        cpuRequest: 30m
      attributes:
        app.kubernetes.io/component: machine-exec
        app.kubernetes.io/part-of: che-theia.eclipse.org
    - name: remote-runtime-injector
      container:
        image: quay.io/eclipse/che-theia-endpoint-runtime-binary:next
        env:
          - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
            value: /remote-endpoint/plugin-remote-endpoint
          - name: REMOTE_ENDPOINT_VOLUME_NAME
            value: remote-endpoint
        volumeMounts:
          - name: plugins
            path: /plugins
          - name: remote-endpoint
            path: /remote-endpoint
        memoryLimit: 128Mi
        memoryRequest: 32Mi
        cpuLimit: 500m
        cpuRequest: 30m
      attributes:
        app.kubernetes.io/component: remote-runtime-injector
        app.kubernetes.io/part-of: che-theia.eclipse.org
    - name: remote-endpoint
      volume:
        ephemeral: true
---
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspace
metadata:
  name: spring-petclinic
spec:
  started: true
  template:
    attributes:
      che-theia.eclipse.org/sidecar-policy: USE_DEV_CONTAINER
    components:
      - name: tools
        container:
          image: quay.io/devfile/universal-developer-image:ubi8-d433ed6
          endpoints:
            - exposure: none
              name: debug
              protocol: tcp
              targetPort: 5005
            - exposure: public
              name: 8080-tcp
              protocol: http
              targetPort: 8080
          volumeMounts:
            - name: m2
              path: /home/user/.m2
            - name: kube
              path: /home/theia/.kube
            - path: /remote-endpoint
              name: remote-endpoint
            - path: /plugins
              name: plugins
          memoryLimit: 3Gi
          env:
            - name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
              value: /remote-endpoint/plugin-remote-endpoint
            - name: THEIA_PLUGINS
              value: local-dir:///plugins/sidecars/tools
          args:
            - sh
            - '-c'
            - ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}
        attributes:
          che-theia.eclipse.org/vscode-extensions:
            - >-
              https://download.jboss.org/jbosstools/static/jdt.ls/stable/java-0.75.0-60.vsix
            - >-
              https://open-vsx.org/api/redhat/vscode-openshift-connector/0.2.9/file/redhat.vscode-openshift-connector-0.2.9.vsix
            - >-
              https://download.jboss.org/jbosstools/vscode/3rdparty/vscode-java-debug/vscode-java-debug-0.26.0.vsix
            - >-
              https://open-vsx.org/api/vscjava/vscode-java-test/0.28.1/file/vscjava.vscode-java-test-0.28.1.vsix
            - >-
              https://download.jboss.org/jbosstools/vscode/3rdparty/vscode-kubernetes-tools/vscode-kubernetes-tools-1.2.1.vsix
            - >-
              https://open-vsx.org/api/redhat/vscode-yaml/0.14.0/file/redhat.vscode-yaml-0.14.0.vsix
          che-theia.eclipse.org/vscode-preferences:
            java.server.launchMode: Standard
          app.kubernetes.io/name: tools
      - name: m2
        volume:
          size: 1G
      - name: theia-ide-spring-petclinic
        plugin:
          kubernetes:
            name: theia-ide-spring-petclinic
      - name: kube
        volume: {}
    commands:
      - id: build
        exec:
          component: tools
          workingDir: ${PROJECTS_ROOT}/java-spring-petclinic
          commandLine: mvn clean install
          group:
            kind: build
            isDefault: true
      - id: run
        exec:
          component: tools
          workingDir: ${PROJECTS_ROOT}/java-spring-petclinic
          commandLine: java -jar target/*.jar
          group:
            kind: run
            isDefault: true
      - id: run-debug
        exec:
          component: tools
          workingDir: ${PROJECTS_ROOT}/java-spring-petclinic
          commandLine: >-
            java -jar -Xdebug
            -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
            target/*.jar
          group:
            kind: run
            isDefault: true

So, now dashboard can analyze index.json file and create a devWorkspace by using already generated files.

Describe the solution you'd like

Use generated DevWorkspace+DevWorkspaceTemplate from the devfile registry to create a workspace

@svor svor added kind/task Internal things, technical debt, and to-do tasks to be performed. area/dashboard engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. labels Nov 25, 2021
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Nov 25, 2021
@svor
Copy link
Contributor Author

svor commented Nov 25, 2021

we still need to add projects section into devWorkspace objects, so, it depends on Devfile registry support for Devfile v2 zip files #20720

@amisevsk amisevsk added severity/P2 Has a minor but important impact to the usage or development of the system. and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Nov 26, 2021
@l0rd l0rd added severity/P1 Has a major impact to usage or development of the system. and removed severity/P2 Has a minor but important impact to the usage or development of the system. labels Dec 2, 2021
@benoitf
Copy link
Contributor

benoitf commented Dec 2, 2021

The key to use for devWorkspaces is based on
https://github.com/eclipse-che/che-dashboard/blob/e16fb06277b4522d1ca4d4b7960fe2775882a664/packages/dashboard-frontend/src/store/Plugins/devWorkspacePlugins/index.ts#L192

if settings['che.factory.default_editor'] === 'eclipse-che/theia/next'

pickup devWorkspaces."eclipse/che-theia/next" content and create objects on kubernetes from the linked file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard engine/devworkspace Issues related to Che configured to use the devworkspace controller as workspace engine. kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system. sprint/current
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants