devfile / devworkspace-operator

Apache License 2.0
67 stars 55 forks source link

Support running a DevWorkspace container components as ephemeral containers of an existing Pod #1328

Open l0rd opened 1 month ago

l0rd commented 1 month ago

Description

In the same vein as the command kubectl debug <mypod> --image <myimage>, that adds a new debug container to the existing pod mypod, we would like to support the use case of starting the CDE containers in an existing Pod.

image

Initially we could should use an attribute to rapidly have the functionality and iterate if there are other things to add (i.e. Pod selector). Pod overrides, init containers etc...should be ignored as the Pod spec should not be changed. Specifying the target-pod-container is critical to support the process namespace sharing that allows attaching the IDE debugger to a process running in that container (this is the parameter --target of kubectl debug).

kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: 
spec:
  routingClass: che
  started: true
  template:
    attributes:
+     controller.devfile.io/target-pod: <podname>
+     controller.devfile.io/target-pod-container: <containername>
    projects:
      - name: outyet
        git:
          remotes:
            origin: https://github.com/l0rd/outyet.git
    components:
      - name: dev-tooling
        container:
          image: ghcr.io/l0rd/outyet-dev:latest
          memoryRequest: 2G
          memoryLimit: 10G
          cpuRequest: '1'
          cpuLimit: '4'
  contributions:
    - name: che-code
      uri: https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/che-incubator/che-code/latest/devfile.yaml
      components:
        - name: che-code-runtime-description
          container:
            env:
              - name: CODE_HOST
                value: 0.0.0.0

Additional context

KCD Austria presentation slides

ibuziuk commented 1 month ago

@l0rd great slides I feel like this feature can shine on the OpenShift Topology view (extra "Debug" ConsoleLink for running pods)

Screenshot 2024-10-17 at 12 34 10