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

Allow DevWorkspace CR to specify pod spec overrides #860

Closed
amisevsk opened this issue Jun 3, 2022 · 5 comments · Fixed by #872
Closed

Allow DevWorkspace CR to specify pod spec overrides #860

amisevsk opened this issue Jun 3, 2022 · 5 comments · Fixed by #872
Assignees
Labels
area/devworkspace Improvent or additions to the DevWorkspaces CRD
Milestone

Comments

@amisevsk
Copy link
Contributor

amisevsk commented Jun 3, 2022

Which area this feature is related to?

/area devworkspace

Which functionality do you think we should add?

Add a field to the DevWorkspace CR spec that allows overriding fields in the k8s Deployment's pod template, e.g.

 kind: DevWorkspace
 apiVersion: workspace.devfile.io/v1alpha2
 metadata:
   name: myspacework
 spec:
   started: true
+  pods:
+    metadata:
+      annotations:
+        io.openshift.userns: "true"
+        io.kubernetes.cri-o.userns-mode: "auto:size=65536;map-to-root=true"  # <-- user namespace
+        openshift.io/scc: container-build
+    spec:
+      runtimeClassName: kata
+      schedulerName: stork      
   template:
   (...)

This field would not be included in the Devfile API

Why is this needed? Is your feature request related to a problem?

There are a variety of cases where overriding specific Pod fields is required by end-users. For example, a user may want to

  • Apply specific annotations to configure how their DevWorkspace runs
  • Override specific pod fields such as runtimeClassName and schedulerName

In general, there's a wide variety of potential things someone may need to override to make DevWorkspaces work for them, but each individual case is not common enough that it fits as part of the dedicated API. Up until now, we generally add special-case handling for individual fields (e.g. SCCs), but this is not flexible enough to cover all use cases, and complicates set up significantly.

Describe the solution you'd like

As above, add field pods to the DevWorkspace API. The contents of the pods field would be corev1.PodSpec. Any value there would be strategic-merged into the resulting Pod spec generated from the DevWorkspace's spec.

Describe alternatives you've considered

This could also be implemented using free-form attributes, but this would mean

  • It's harder to use when writing/editing a DevWorkspace by hand
  • There is no validation or documentation on the field
  • It's potentially more error-prone

Additional context

DevWorkspaceOperator issue: devfile/devworkspace-operator#852

@openshift-ci openshift-ci bot added the area/devworkspace Improvent or additions to the DevWorkspaces CRD label Jun 3, 2022
amisevsk added a commit to amisevsk/devworkspace-api that referenced this issue Jun 3, 2022
Add field `pods` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-api that referenced this issue Jun 3, 2022
Add field `pods` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-api that referenced this issue Jun 13, 2022
Add field `pods` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-api that referenced this issue Jun 14, 2022
Add field `pods` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk amisevsk self-assigned this Jun 23, 2022
@elsony
Copy link
Contributor

elsony commented Jun 28, 2022

If someone specifies the kubernetes component and provides an inline or link to kubernetes yaml file, the pod settings may conflict with these metadata. How are we planning to resolve that?

@amisevsk
Copy link
Contributor Author

amisevsk commented Jun 28, 2022

If someone specifies the kubernetes component and provides an inline or link to kubernetes yaml file, the pod settings may conflict with these metadata. How are we planning to resolve that?

To clarify, the new pods field is intended to only apply to the deployment/pod that is created to store components of the container type, not anything else. Perhaps it is better to name it pod?

Any specified Kubernetes component is implicitly not a part of the core devworkspace deployment. If e.g. a devfile specifies a k8s pod in a Kubernetes component, that will generally have to be provisioned as a standalone ("dedicated") pod rather than merged into the other container components. The podSpec field only overrides settings for the components that cannot be configured directly (the deployment/pod that contains container components only).

The documentation for Kubernetes components states their purpose is

Allows importing into the devworkspace the Kubernetes resources defined in a given manifest. For example this allows reusing the Kubernetes definitions used to deploy some runtime components in production.

If we do some processing (e.g. to include something defined in a k8s component in the same deployment as container components) then we would be prone to breaking that use case. Examples of this would be

  • Conflicting configuration between what's needed for container components and the explicit pod
  • Port/volume collisions between the k8s and container components.

@l0rd
Copy link
Contributor

l0rd commented Jun 30, 2022

@amisevsk I named it pods in devfile/devworkspace-operator#852 because I initially thought that we should apply the spec to every deployment/pod, not just the main one. I am thinking in particular about annotations, labels, schedulers: if the DevWorkspace includes more than one pod, it makes sense to apply it to all of them. But to be honest we don't have any real use case for it, those are just my speculation and I am perfectly fine to just override the main podSpec. But yes, we should probably rename it pod, mainPod or devPod to avoid confusions.

@amisevsk
Copy link
Contributor Author

@l0rd I suppose it would make sense to apply the spec to both the main deployment's pods and also any dedicated pods specified -- in that sense this field would apply to all container components in the spec. To my knowledge, dedicatedPod isn't used currently, which is why I didn't think of it. This would mean keeping the pods name rather than pod.

Other pods, started as e.g. part of kubernetes components, could specify their full specs in the inlined/referenced yaml so I don't think the override is necessary there.

I'm still not entirely sure on naming though -- I prefer pods to pod/mainPod/devPod, but maybe something like podSpecOverride is better for the sake of being explicit?

@l0rd
Copy link
Contributor

l0rd commented Jul 27, 2022

I like podSpecOverride more and I would override kubernetes components too but that can be discussed later as that's just a philosophical exercise at the moment.

amisevsk added a commit to amisevsk/devworkspace-api that referenced this issue Jul 27, 2022
Add field `podSpecOverride` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@l0rd l0rd added this to the 2.2 milestone Sep 12, 2022
amisevsk added a commit to amisevsk/devworkspace-api that referenced this issue Sep 19, 2022
Add field `podSpecOverride` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
amisevsk added a commit that referenced this issue Sep 19, 2022
Add field `podSpecOverride` to the DevWorkspace spec (but not Devfile or
DevWorkspaceTemplate) that allows specifying arbitrary fields on any
pods created for the DevWorkspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devworkspace Improvent or additions to the DevWorkspaces CRD
Projects
None yet
3 participants