feat(trainer): add envFrom option for kubernetes backend#477
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
🎉 Welcome to the Kubeflow SDK! 🎉 Thanks for opening your first PR! We're happy to have you as part of our community 🚀 Here's what happens next:
Join the community:
Feel free to ask questions in the comments if you need any help or clarification! |
There was a problem hiding this comment.
Pull request overview
Adds a new Kubernetes-specific trainer option to inject environment variables sourced from Secrets/ConfigMaps into the trainer container, and updates the Kubernetes backend to merge these env overrides with trainer.env.
Changes:
- Introduce
TrainerEnvFromoption (withsecret()/config_map()helpers) to appendvalueFromenv vars to.spec.trainer.env. - Update Kubernetes backend spec generation to append option-provided env vars to those produced from
trainer.env. - Add unit/integration test coverage and expose the option in public imports + docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| kubeflow/trainer/options/kubernetes.py | Adds TrainerEnvFrom option implementation and validation. |
| kubeflow/trainer/options/init.py | Exposes TrainerEnvFrom via the public options import surface. |
| kubeflow/trainer/options/kubernetes_test.py | Extends option validation/application unit tests for TrainerEnvFrom. |
| kubeflow/trainer/backends/kubernetes/backend.py | Appends env overrides to trainer.env when building the TrainJob spec. |
| kubeflow/trainer/backends/kubernetes/backend_test.py | Adds end-to-end backend tests for env override merging behavior. |
| docs/source/train/options.rst | Documents TrainerEnvFrom in the options reference. |
This commit adds a TrainerEnfFrom option for the kubernetes backend that allows users to specify environment variables sourced from ConfigMaps or Secrets. The added variables will be concatenated with the ones added in trainer.env. Signed-off-by: Alexandre Gomez <gomez.a.corneille@gmail.com>
e43f893 to
59ccc58
Compare
|
I still have an open question concerning that PR: for now i limit the usage to CustomTrainer and CustomTrainerContainer types but actually this option could be 100% used with the BuiltinTrainer as well. The thing is, BuiltinTrainer doesn't have the |
remove @DataClass from TrainerEnvFrom class Signed-off-by: Alexandre Gomez <gomez.a.corneille@gmail.com>
What this PR does:
This PR adds a TrainerEnfFrom option for the kubernetes backend that allows users to specify environment variables sourced from ConfigMaps or Secrets. The added variables will be concatenated with the ones added in trainer.env.
Why we need it
As discussed in the slack thread, we need this feature whenever we have to deal with secrets inside the
nodecontainer.One example could be using model_registry s3 upload to log the model after a train, you would need the access key id & secret key available as env var inside the training pod's
nodecontainer.Opinionated changes
Compared to the proposition in the slack thread, I did some opinionated changes:
Which issue(s) this PR fixes (optional, in
Fixes #<issue number>, #<issue number>, ...format, will close the issue(s) when PR gets merged):No Issue was created as we agreed that it was not needed.
Checklist: