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

Add an ability to expose K8s/OS tool container port in Workspace Runtime #12808

Closed
vitaliy-guliy opened this issue Mar 1, 2019 · 12 comments
Closed
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. severity/P2 Has a minor but important impact to the usage or development of the system.

Comments

@vitaliy-guliy
Copy link
Contributor

vitaliy-guliy commented Mar 1, 2019

Show motivation description

With Workspace Config, there is an ability to define that Container exposed some port (with server config entry in machine configuration) and then it is possible to get publicly available URL (powered by Ingress/Route) via Che Server API (it's Workspace#Runtime#Machines[n]#Servers).
And there are two main reasons why users may want to expose their containers ports with Che Server API:

  1. Theia provides UI to get these servers URLs for a user for further using, like their server testing.
  2. Theia itself may need to pick up such exposed port. See Detailed use-case description.

Detailed Theia Dev Use case description

In my use case I need a workspace with Theia editor and two custom containers which I use to launch another instance of Theia and remote plugin. This two containers must have exposed ports. One is for Theia http server, another one is for remote plugin which opens a websocket server.
Theia has to know URI to the plugin server which is taken from workspace runtime.

In the Dockerfile I use kubernetes tool to describe custom containers.
For those containers I need to describe exposes ports 3030 and 10000.
Here are my files from which I create my workspace.

.devfile

specVersion: 0.0.1
name: develop-remote-plugins
projects:
  - name: theia
    source:
      type: git
      location: 'https://github.com/theia-ide/theia.git'
  - name: sample-remote-plugin
    source:
      type: git
      location: 'https://github.com/vitaliy-guliy/sample-remote-plugin.git'
tools:
  - name: theia-editor
    type: cheEditor
    id: org.eclipse.che.editor.theia:1.0.0
  - name: exec-plugin
    type: chePlugin
    id: che-machine-exec-plugin:0.0.1
  - name: dev
    type: kubernetes
    local: dev.yaml
commands:
  - name: build-plugin
    actions:
      - type: exec
        tool: dev-plugin
        command: cd /projects/sample-remote-plugin && yarn
        workdir: /projects/sample-remote-plugin
  - name: build-theia
    actions:
      - type: exec
        tool: dev
        command: cd /projects/theia && yarn
        workdir: /projects/theia

dev.yaml

---
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: Pod
  metadata:
    name: ws
  spec:
    containers:
    - name: dev
      image: eclipse/che-theia-dev:nightly
      resources:
        limits:
          memory: 2048Mi
      volumeMounts:
      - mountPath: /projects
        name: projects
    - name: dev-plugin
      image: eclipse/che-theia-dev:nightly
      resources:
        limits:
          memory: 2048Mi
      volumeMounts:
      - mountPath: /projects
        name: projects
    volumes:
    - name: projects
      persistentVolumeClaim:
        claimName: projects
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: projects
  spec:
    accessModes:
     - ReadWriteOnce
    resources:
      requests:
        storage: 2Gi
@vitaliy-guliy vitaliy-guliy added kind/task Internal things, technical debt, and to-do tasks to be performed. team/platform labels Mar 1, 2019
@sleshchenko
Copy link
Member

sleshchenko commented Mar 1, 2019

@vitaliy-guliy Actually, you already are able to expose containers ports with dockerimage tool type. See https://redhat-developer.github.io/devfile/#tools endpoint field. And then Workspace API will have information about exposed endpoint as a server of the machine in runtime.

But if you need multiple containers, then (for time being) you have to use kubernetes/openshift tool where it is possible. And in this case, you are able to define Kubernetes Services/Ingresses, OpenShift Routes for exposing your containers ports BUT Workspace API server won't expose URLs for such objects. Here is an issue for exposing URLs of such objects #12268.

Anyway, it would be useful to see an example of your use case in the issue description.

@vitaliy-guliy
Copy link
Contributor Author

Also I include a JSON template to create a Factory which covers my case

{
  "v": "4.0",
  "name": "remote_plugin_developer",
  "workspace": {
    "defaultEnv": "default",
    "environments": {
      "default": {
        "machines": {
          "ws/dev-plugin": {
            "attributes": {
              "memoryLimitBytes": "2684354560"
            },
            "servers": {
              "PluginDev": {
                "attributes": {},
                "port": "10000",
                "protocol": "ws"
              }
            },
            "volumes": {
              "projects": {
                "path": "/projects"
              }
            },
            "installers": [],
            "env": {}
          },
          "ws/dev": {
            "attributes": {
              "memoryLimitBytes": "2684354560"
            },
            "servers": {
              "TheiaDev": {
                "attributes": {},
                "port": "3030",
                "protocol": "http"
              }
            },
            "volumes": {
              "projects": {
                "path": "/projects"
              }
            },
            "installers": [],
            "env": {}
          }
        },
        "recipe": {
          "type": "kubernetes",
          "content": "kind: List\nitems:\n - \n  apiVersion: v1\n  kind: Pod\n  metadata:\n   name: ws\n  spec:\n   containers:\n    - \n     image: 'eclipse/che-theia-dev:nightly'\n     name: dev\n     resources:\n      limits:\n       memory: 3072Mi\n    - \n     image: 'eclipse/che-theia-dev:nightly'\n     name: dev-plugin\n     resources:\n      limits:\n       memory: 2560Mi\n",
          "contentType": "application/x-yaml"
        }
      }
    },
    "projects": [
      {
        "links": [],
        "name": "theia",
        "attributes": {},
        "type": "blank",
        "source": {
          "location": "https://github.com/theia-ide/theia.git",
          "type": "git",
          "parameters": {}
        },
        "path": "/theia",
        "description": "",
        "mixins": [],
        "problems": []
      }
    ],
    "name": "remote_plugin_developer",
    "attributes": {
      "editor": "org.eclipse.che.editor.theia:1.0.0",
      "plugins": "che-machine-exec-plugin:0.0.1"
    },
    "commands": [],
    "links": []
  }
}

@skabashnyuk skabashnyuk added severity/P1 Has a major impact to usage or development of the system. severity/P2 Has a minor but important impact to the usage or development of the system. and removed severity/P1 Has a major impact to usage or development of the system. labels Mar 6, 2019
@sunix
Copy link
Contributor

sunix commented Mar 15, 2019

@sleshchenko
Copy link
Member

@sunix Thanks for sharing a way how you solved this issue with dockerimage tool.
I think it makes sense to keep this issue opened since there is no way to make Che Server expose k8s/os tool's container port. I do not know how critical it is, but still, such an issue exists.

@sunix
Copy link
Contributor

sunix commented Mar 15, 2019

OK so maybe rename this issue to be more precise of what is not working :) or create a new issue ? WDYT ?

@sleshchenko
Copy link
Member

@sunix I'll modify the current issue.

@sleshchenko sleshchenko changed the title Make it possible to add exposed ports for container in Devfile Add an ability to expose K8s/OS tool container port via Che API Mar 15, 2019
@sleshchenko
Copy link
Member

Issue description is updated. Hope everything is clear enough. Everybody - feel free to modify issue description or ask me missing details.

@sunix
Copy link
Contributor

sunix commented Mar 18, 2019

Thanks @sleshchenko i am not sure to understand the via Che API.

@sleshchenko
Copy link
Member

@sunix Here I mean propagating server URL via Workspace API, like we do with Theia (or any other servers) URL
Screenshot_20190319_133725

@sunix
Copy link
Contributor

sunix commented Mar 19, 2019

@sleshchenko via Che API -> in Che workspace config or just remove via Che API WDYT ?

@sleshchenko sleshchenko changed the title Add an ability to expose K8s/OS tool container port via Che API Add an ability to expose K8s/OS tool container port in Workspace Runtime Mar 20, 2019
@che-bot
Copy link
Contributor

che-bot commented Sep 17, 2019

Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.

Mark the issue as fresh with /remove-lifecycle stale in a new comment.

If this issue is safe to close now please do so.

Moderators: Add lifecycle/frozen label to avoid stale mode.

@che-bot che-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 17, 2019
@vitaliy-guliy
Copy link
Contributor Author

Outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. severity/P2 Has a minor but important impact to the usage or development of the system.
Projects
None yet
Development

No branches or pull requests

5 participants