devfile / devworkspace-operator

Apache License 2.0
67 stars 55 forks source link

[question] Issue with test example: The workspace has not received an IDE URL in the last 20 seconds #1268

Closed yaroslavkasatikov closed 5 months ago

yaroslavkasatikov commented 5 months ago

Hello team,

I have tried to run devworkspace from your example: https://raw.githubusercontent.com/devfile/devworkspace-operator/main/samples/plain.yaml

It has been in Running status, but I can not open IDE because the Error: 'The workspace has not received an IDE URL in the last 20 seconds. Try to re-open the workspace.'

Снимок экрана 2024-05-29 в 09 23 55

What am I doing wrong?

DevWorkspace Operator 0.28.0-dev.8+b49427c

yaroslavkasatikov commented 5 months ago

well I found that we need to use additionally special image which is built with correct nodejs modules for endpoint generation.

Created an example smth like this:

kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: yk-dev-workspace
spec:

  started: true
  # You need to set routingClass - it is set in cheCluster resource and allow you to route  traffic (it creates a side-car with web proxy -- che-gateway )
  routingClass: che
  # Here is the devfile template you have to create
  template:
    # Here is the project for clonnig. it has .vscode/extensions.json for install the extensions.
    projects:
      - name: devfile-project-for-extensions
        git:
          remotes:
            origin: "https://gitlab.com/you/repo/to/clone.git"
    attributes:
        app.kubernetes.io/component: che-code-runtime
        app.kubernetes.io/part-of: che-code.eclipse.org
        # You should set storage type (per-user - one pvc for all, per-workspace - each workspace has its own pvc and ephemeral )
        controller.devfile.io/storage-type: per-workspace
    commands:
      # This block describes commands which should be run. apply adds container, exec - bash script. DId is related to component name
      - id: init-container-command
        apply:
          component: che-code-injector
      - id: init-che-code-command
        exec:
          component: che-code-runtime-description
          commandLine: nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt 2>&1 &
      #List of the events, smth like hoock
    events:
      # Create the init container
      preStart:
        - init-container-command
      #Run postStart script/command
      postStart:
        - init-che-code-command
    # Components list
    components:
      # Here is we added terminal container. It will be run as a sidecar
      - name: web-terminal
        container:
          image: quay.io/wto/web-terminal-tooling:next
          memoryRequest: 256Mi
          memoryLimit: 512Mi
          mountSources: true
          command:
           - "tail"
           - "-f"
           - "/dev/null"
      # This is important part which inject editor. It will be applied in preStart event. This magic will create the container, as I understood
      - name: che-code-injector
        container:
          image: quay.io/che-incubator/che-code@sha256:f7eed8fd36f11ded156d7bbdede3ec7656923df98e09c376165b7139c48e442a
          command:
            - /entrypoint-init-container.sh
          volumeMounts:
            - name: checode
              path: /checode
          memoryLimit: 256Mi
          memoryRequest: 32Mi
          cpuLimit: 500m
          cpuRequest: 30m
      # This is special runtime container. It contains node js module for creating endpoints.
      - name: che-code-runtime-description
        container:
          image: quay.io/devfile/universal-developer-image@sha256:af179305a39c56b11c8851e67a64e7f4e5e269572e05a8de9e62834f9927c31d
          memoryLimit: 1024Mi
          memoryRequest: 256Mi
          cpuLimit: 500m
          cpuRequest: 30m
          volumeMounts:
            - name: checode
              path: /checode
          endpoints:
            - name: che-code
              attributes:
                type: main
                cookiesAuthEnabled: true
                discoverable: false
                urlRewriteSupported: true
              targetPort: 3100
              exposure: public
              secure: true
              protocol: https
            - name: code-redirect-1
              targetPort: 13131
              exposure: public
              protocol: https
              attributes:
                discoverable: false
                urlRewriteSupported: false
            - name: code-redirect-2
              targetPort: 13132
              exposure: public
              protocol: https
              attributes:
                discoverable: false
                urlRewriteSupported: false
            - name: code-redirect-3
              targetPort: 13133
              exposure: public
              protocol: https
              attributes:
                discoverable: false
                urlRewriteSupported: false
      # We define volume here. It will be created according the annotations
      - name: checode
        volume: {}

This example worked with checluster @ OKD 4.14 with more or less default configuration. Probably it may be useful.

AObuchow commented 5 months ago

@yaroslavkasatikov thank you for the report.

The devworkspace samples present in https://github.com/devfile/devworkspace-operator/tree/main/samples are intended for usage with devworkspace operator in isolation, not in Che. Che takes Devfiles (which get converted to DevWorkspaces and passed on to the DevWorkspace Operator) whereas the DevWorkspace Operator takes DevWorkspaces.

I'd recommend checking out the devfile registry stacks which give devfiles that you can try out in Che.

Closing this issue, but feel free to continue the discussion if you have any further questions or comments :)