Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Allow to set ENV vars for build docker and deploy kubernetes #648

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

aguschin
Copy link
Contributor

@aguschin aguschin commented Mar 28, 2023

this is for #647 (comment)

This work similarly to #645:

mlem build docker works the same, but I'll provide an example for k8s deploy here:

$ mlem declare deployment kubernetes deployer \
  --image_name myimage --service_type loadbalancer --registry remote \
  --env docker --env.registry remote --registry.host localhost --namespace myns \
  --set_env.0 VAR1 --set_env.1 VAR2=aguschin
💾 Saving deployment to deployer.mlem
# deployer.mlem
env:
  object_type: env
  registry:
    type: remote
  type: kubernetes
image_name: myimage
namespace: myns
object_type: deployment
registry:
  host: localhost
  type: remote
service_type:
  type: loadbalancer
set_env:
- VAR1
- VAR2=aguschin
type: kubernetes

Then in Dockerfile for your image you'll get:

...
ENV VAR1=VALUE1
ENV VAR2=aguschin

VALUE1 will be taken from shell/env vars with os.getenv("VAR1"). If it's not set, an Exception will be raised by MLEM.

@aguschin aguschin requested a review from a team as a code owner March 28, 2023 11:10
@aguschin aguschin self-assigned this Mar 28, 2023
@aguschin aguschin temporarily deployed to internal March 28, 2023 11:10 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Patch coverage: 51.85% and project coverage change: -0.07 ⚠️

Comparison is base (4c5be67) 85.77% compared to head (d0bf40a) 85.70%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #648      +/-   ##
==========================================
- Coverage   85.77%   85.70%   -0.07%     
==========================================
  Files         109      109              
  Lines        9904     9921      +17     
==========================================
+ Hits         8495     8503       +8     
- Misses       1409     1418       +9     
Impacted Files Coverage Δ
mlem/contrib/docker/base.py 85.00% <ø> (ø)
mlem/contrib/flyio/meta.py 46.08% <0.00%> (-1.67%) ⬇️
mlem/contrib/kubernetes/build.py 100.00% <ø> (ø)
mlem/core/errors.py 83.33% <50.00%> (-1.67%) ⬇️
mlem/contrib/docker/context.py 80.41% <56.25%> (-0.59%) ⬇️
mlem/contrib/kubernetes/base.py 85.84% <100.00%> (+0.27%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@aguschin aguschin merged commit 90f1f7d into main Mar 31, 2023
@aguschin aguschin deleted the feature/set-env branch March 31, 2023 07:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant