Comments (3)
after this has been updated, remember to update the doc: #1578
from api.
@yangcao77 👋🏼
How do we plan to implement this? Would it be through Kubernetes postStart and preStop lifecycle?
In which case, would it be beneficial to have a side-effect as described in their documentation - https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#discussion
Kubernetes sends the postStart event immediately after the Container is created. There is no guarantee, however, that the postStart handler is called before the Container's entrypoint is called. The postStart handler runs asynchronously relative to the Container's code, but Kubernetes' management of the container blocks until the postStart handler completes. The Container's status is not set to RUNNING until the postStart handler completes.
Kubernetes sends the preStop event immediately before the Container is terminated. Kubernetes' management of the Container blocks until the preStop handler completes, unless the Pod's grace period expires.
My use case is as follows -
- When my pod is available, I want to execute certain commands to make it ready for my use e.g. npm install, bundle install, etc. These commands can take quite some time and depends significantly on the project.
- I want these commands to be executed as soon as my pod is ready.
- It should not be dependent on any IDE i.e. execute some commands when the IDE opens up.
If devfile has the option to specify postStart
, I would be tempted to run npm install
is a postStart command. However, as described from the Kubernetes docs, there is no guarantee that it would run before the container's entrypoint and that it would block the readiness status of the pod until those command successfully execute. npm install
can take some amount of time depending on the project.
How do we reconcile these things? This makes me think is it a bad idea to use Kubernetes lifecycle hooks here? Curious to know what the team thinks about this problem and the potential solutions.
Thanks
from api.
Hi @vishaltak .
Devfile library will use the container lifecycle as described here: https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/, and generate a proper pod definition.
Devfile library does not handle the reconcile of any Kube resources. So I can give suggestions as what I would try, but not from Devfile's perspective.
If you want your npm install
always run after the entrypoint, I would try overwrite the container entrypoint and set pod spec.container.command
to npm install && <ENTRYPOINT_COMMAND>
, or even set the npm install
command in the container's Dockerfile.
Another way is to have a initContainer and volumeMount, to run npm install
to get all your dependencies.
Regarding on the pod readiness, since your container would rely on the npm or bundle installation, I do not have any good suggestions.
from api.
Related Issues (20)
- Add test devfile registry deployment to index generator testing workflow
- Fix external references in test sample entries
- devfile special envs cannot be defined last in the env list HOT 5
- Devfile Registry nightly run fails for `ollama` stack HOT 3
- for a single minor version, library should support all previous patches with latest schema
- Copy odo-devfile starter projects to devfile-samples org HOT 2
- Publish `0.3.0` release for registry-operator HOT 3
- Spike: Enable Konflux build pipeline
- Update lastModified For Stacks/Samples Without Versions HOT 3
- Implement Multi Arch Support For Devfile Repositories
- [Spike] Investigate documentation updates for pod - container overrides
- Community Registry Showing Default Date for lastModified
- Error logged with Quarkus stacks related to telemetry usage HOT 1
- Error logged with Quarkus stacks related to LogManager
- Update `odo` to `v3.16.1`
- Add DCO to docker plugin repo
- Bump up `github.com/docker/docker` to `v25.0.6` version. HOT 4
- Release `devfile/api` new `v2.3.1` version HOT 1
- [Spike] Investigate root-component based language weights for alizer analyze command
- Update CodeQL GitHub Action to v3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api.