-
Notifications
You must be signed in to change notification settings - Fork 64
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
Extend deployByDefault to other components, drop the implicit apply command rule #852
Comments
I would love to work on this issue. @l0rd |
Hey @l0rd , Ohh, I am bit late to know about this project. Hey, Myself vivek !! Currently a student, looking for new project to contribute. And it seems to me an interesting project. I have bit of experience of past one year in open source world. Contributed to Kyverno project. Looking forward to know more about this project. Any useful resources ?? |
Hi @l0rd , this is Anurag Bhat , a student looking to contribute to this project under the LFX mentorship program . I feel this project is a great entry point for me into cloud native development, after contributing to couple of GSoC orgs in the past year. I had submitted my application 3-4 days ago and believe the admission process is in progress now ! |
I'm not a big fan of the "apply rule" so it would be great to have something more explicit. I'm a bit afraid of creating too many rules like "If this is enabled then you can't enable something else" it might make writing devfiles too complex as it createss too many invalid scenarios. I would avoid adding validation like this unless it creates situation that are ambiguous or completely invalid.
Doing this might look weird, but essentially it is not creating an invalid scenario. You will be applying something that already exists, so it will only result in "noop".
Similar in as above scenario
I can actually see a valid scenario where I would want to build image with name Could we maybe name this field I will try to create a few examples to verify how it would work. |
@kadel setting I am ok to call it |
@rajibmitra is going to work on this issue as part of the LXF mentorship program. |
I got a little bit carried away 😇 . You are right this might not be a good idea right now as it would be incompatible with current Devfile behaviors, but it would simplify a lot of things :-)
I'm afraid that if we want to keep default behaviors as |
During the Devfile Cabal of the 20th of June we have discussed a couple of proposal as mentioned in another issue to use the field
|
# Controlling component creation Devfile has 4 types of components:
Current situationBy default, there is an "apply" rule: If a component is not referenced by an On top of that there is also If
|
deployByDefault: true |
deployByDefault: false |
deployByDefault not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created only when the command is invoked | created only when the command is invoked |
not referenced in apply command | automatically created on startup | never started ??? | automatically created on startup |
image
component
autoBuild: true |
autoBuild: false |
autoBuild not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created only when the command is invoked | created only when the command is invoked |
not referenced in apply command | automatically created on startup | never started ??? | automatically created on startup |
Originally Proposed change
Introduce new field deployStrategy
with options atStartup
, onDemand
deployStrategy: atStartup |
deployStrategy: onDemand |
deployStrategy not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created only when the command is invoked | created only when the command is invoked |
not referenced in apply command | automatically created on startup | never created | automatically created on startup |
For backward compatibility can't remove deployByDefault
and autoBuild
fields.
They should be marked as deprecated in the docs. But we will have to keep supporting them.
Setting both deployByDefault
/autoBuild
and deployStrategy
should be considered invalid. The validator or tools should error out if Devfile uses the old and new fields at the same time in the same component.
container
components
For the container
component, the exec
command should create the onDemand
container the same way apply
does.
Problems
There is one big problem with container
component and onDemand
behavior.
It is not possible to add containers to the existing Pod without restarting Pod.
Let's say that exec
creates onDemand
controller the same way apply
would.
example
components:
- name: runtime
container:
image: registry.access.redhat.com/ubi8/nodejs-16:latest
endpoints:
- name: http-3000
targetPort: 3000
- name: test
container:
image: registry.access.redhat.com/ubi8/nodejs-16:test
deployStrategy: onDemand
endpoints:
- name: http-3000
targetPort: 3000
commands:
- id: install
exec:
component: runtime
commandLine: npm install
workingDir: ${PROJECT_SOURCE}
group:
kind: build
isDefault: true
- id: run
exec:
component: runtime
commandLine: npm start
workingDir: ${PROJECT_SOURCE}
group:
kind: run
isDefault: true
- id: test
exec:
component: test
commandLine: npm run test
workingDir: ${PROJECT_SOURCE}
group:
kind: test
isDefault: true
deployStrategy
could be problematic for container
as onDemand
will properly work only if the main Pod gets restarted.
The solution could be that we define that onDemand
automatically means dedicatedPod: true
, or we make onDemand
only possible if dedicatedPod: true
, but at that point, we are creating a lot of rules that are not directly expressed in the file.
kubernetes
/openshift
components
Create kubernetes
/openshift
means simply "apply" the inlined or uri referenced definition.
There is no problem in doing it at the startup or on demand later on.
image
components
Create image
/ means build the container image and push it to the registry.
There is no problem in doing it at the startup or on demand later on.
Devfile author just needs to make sure that if container
or kubernetes
component uses that image the build is executed first.
volume
components
Creating volume on demand might be problematic. In most cases, volume
will be represented as PersistentVolumeClaim
resource on the cluster.
Creating PVC
without using it in the container doesn't make much sense.
There is no benefit in controlling when the volume
will be created. Better would be to simply define that the volume
will be created when the container
that uses it first is created.
deployStrategy
doesn't make sense for volume
Proposal v2
Each component, where makes sense, will get its own field to control "deployStrategy".
Mario's runOnDemand
makes sense for container
component.
container
components
option 1: runOnDemand: true/false
- When
runOnDemand: true
, the container is always created in a separate pod. - By default, containers are started in one pod at startup.
exec
command should behave likeapply
command forcontainer
component (container "onDemand" will be just beforeexec
command is executed
runOnDemand: true |
runOnDemand: false |
runOnDemand not set |
|
---|---|---|---|
referenced in apply command | created when apply command is invoked | automatically created on startup | created when apply command is invoked |
not referenced in apply command | never started ??? | automatically created on startup | automatically created on startup |
dedicatedPod:true
& runOnDemand:true
: OK
dedicatedPod:true
& runOnDemand:false
: OK
dedicatedPod:true
&
: OK
dedicatedPod:false
& runOnDemand:true
: NOTVALID
dedicatedPod:false
& runOnDemand:false
: OK
dedicatedPod:false
&
: OK
kubernetes
/openshift
components
deployByDefault: true/false
deployByDefault: true |
deployByDefault: false |
deployByDefault not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created when apply command is invoked | created when apply command is invoked |
not referenced in apply command | automatically created on startup | never started ??? | automatically created on startup |
image
components
autoBuild: true/false
autoBuild: true |
autoBuild: false |
autoBuild not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created when apply command is invoked | created when apply command is invoked |
not referenced in apply command | automatically created on startup | never started ??? | automatically created on startup |
volume
components
no field to control the creation; it gets created automatically when it is used in the container definition.
Just copying the final proposal to the comment to make it easier to link to. To see how I got to this point check previous comment #852 (comment) Proposal v2Each component, where makes sense, will get its own field to control "deployStrategy". Mario's
|
runOnDemand: true |
runOnDemand: false |
runOnDemand not set |
|
---|---|---|---|
referenced in apply command | created when apply command is invoked | automatically created on startup | created when apply command is invoked |
not referenced in apply command | never started ??? | automatically created on startup | automatically created on startup |
dedicatedPod:true
& runOnDemand:true
: OK
dedicatedPod:true
& runOnDemand:false
: OK
dedicatedPod:true
&
: OK
dedicatedPod:false
& runOnDemand:true
: NOTVALID
dedicatedPod:false
& runOnDemand:false
: OK
dedicatedPod:false
&
: OK
kubernetes
/openshift
components
deployByDefault: true/false
deployByDefault: true |
deployByDefault: false |
deployByDefault not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created when apply command is invoked | created when apply command is invoked |
not referenced in apply command | automatically created on startup | never started ??? | automatically created on startup |
image
components
autoBuild: true/false
autoBuild: true |
autoBuild: false |
autoBuild not set |
|
---|---|---|---|
referenced in apply command | automatically created on startup | created when apply command is invoked | created when apply command is invoked |
not referenced in apply command | automatically created on startup | never started ??? | automatically created on startup |
volume
components
no field to control the creation; it gets created automatically when it is used in the container definition.
Community call discussion: |
…t of image components to auto-create See devfile/api#852 (comment) for more context.
…t of image components to auto-create See devfile/api#852 (comment) for more context.
…t of image components to auto-create See devfile/api#852 (comment) for more context.
…t of image components to auto-create See devfile/api#852 (comment) for more context.
…t of image components to auto-create See devfile/api#852 (comment) for more context.
…t of image components to auto-create See devfile/api#852 (comment) for more context.
…nShift components (#6654) * Add sample Devfile with multiple autoBuild/deployByDefault combinations It will be used for integration tests. * Add helper function to update a given Devfile Command Group This will allow supporting cases where we need to run a custom command, but this is not implemented yet on odo (cases with 'odo dev --debug' and 'odo deploy'). In this case, this helper will allow updating the Devfile for example to unmark the current default command as non-default, and mark the custom one as default. * Add test cases for 'odo dev' * Add test cases for 'odo deploy' * Add test cases for 'odo build-images' 'odo build-images' should build all images regardless of the 'autoBuild' property. * Display the spinner when creating or updating Kubernetes resources This helps understand what resources are being patched. * Handle deployByDefault on K8s and OpenShift components * Add 'devfile.GetImageComponentsToPush' functions that returns the list of image components to auto-create See devfile/api#852 (comment) for more context. * Handle automatic image component creation for 'odo dev' on Kubernetes * Handle automatic image component creation for 'odo dev' on Podman * Handle automatic image and K8s/OpenShift component creation for 'odo deploy' * Bump Devfile library to the latest commit at this time (c1b23d2) This includes the fix for [1], which provides a way not to set default values automatically [1] devfile/api#1067 * Do not set default values when parsing a Devfile See [1] for the rationale [1] https://github.com/redhat-developer/odo/issues/5694\#issuecomment-1465778398 * Add documentation in the Devfile reference page * Revert "Display the spinner when creating or updating Kubernetes resources" This reverts commit 6ad073e63cb0e685f165eed767619a90997393a3. * Avoid re-applying Image components multiple times 'adapter#Push' might get called several times when there are state transitions (either on the Deployment in the cluster, or from 'odo'). It might be confusing to apply Image components over and over again (and also it can be slower if we need to push images to remote registries). * Move GetK8sAndOcComponentsToPush and GetImageComponentsToPush to libdevfile package As suggested in review, this should be the responsibility of the devfile library Co-authored-by: Philippe Martin <phmartin@redhat.com> * fixup! Handle automatic image and K8s/OpenShift component creation for 'odo deploy' * fixup! Handle automatic image component creation for 'odo dev' on Podman * fixup! Avoid re-applying Image components multiple times * Apply suggestions from code review Co-authored-by: Parthvi Vala <pvala@redhat.com> * fixup! Do not set default values when parsing a Devfile * Fix devfile-deploy-functional-pods.yaml (used in 'odo logs' tests) Set deployByDefault to false on innerloop-pod component. Otherwise, since it is not referenced by any apply command, it will be automatically created by *both* 'odo dev' and 'odo deploy'. --------- Co-authored-by: Philippe Martin <phmartin@redhat.com> Co-authored-by: Parthvi Vala <pvala@redhat.com>
This issue is stale because it has been open for 90 days with no activity. Remove stale label or comment or this will be closed in 60 days. |
Which area this feature is related to?
/area api
/area library
/area devworkspace
Which functionality do you think we should add?
Why is this needed? Is your feature request related to a problem?
Devfile adopters struggle to understand what components will be started when a workspace is provisioned.
Detailed description:
Understanding which components are started automatically (or builded in the case of an image) and which are not is currently complicated.
There is an implicit rule to start only components that are NOT referenced by a command of type
apply
. That's a hidden rule that is hard to understand and remember.The new
deployByDefault
andautoBuild
fields have improved the situation but only apply to kubernetes/openshift and image components respectively.Describe the solution you'd like
Add a
runOnDemand
boolean field for components of type containers (false
by default).Do not rely on the
apply
rule anymore, but forbid the following configurations (document in the spec, raise an error in the library):runOnDemand: false
is referenced by an apply a commanddeployByDefault: true
is referenced by an apply commandautobuild: true
is referenced by an apply commandDescribe alternatives you've considered
We should add a new command of type
delete
that would be the complement ofapply
.Related issues
#204
#693
The text was updated successfully, but these errors were encountered: