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

Support list of "env" variables in the Build spec #224

Closed
sbose78 opened this issue May 21, 2020 · 12 comments
Closed

Support list of "env" variables in the Build spec #224

sbose78 opened this issue May 21, 2020 · 12 comments
Assignees
Labels
beta BETA related issue kind/feature Categorizes issue or PR as related to a new feature.

Comments

@sbose78
Copy link
Member

sbose78 commented May 21, 2020

If the user defines the following,

kind: Build
...
spec:
  env:
    - name: "HTTP_PROXY"
      value: "http://my.enterprise.proxy"
  1. The environment variables should be made available in the BuildStrategy container ( buildStep ) automatically.

  2. These should, of course, not be available in the final deployable image created as a result of Support creation of lean application "runtime" images #183

  3. Also, the BuildStrategy author should be able to refer to it in the container step or arg as $(build.env.HTTP_PROXY).

@sbose78 sbose78 added the kind/feature Categorizes issue or PR as related to a new feature. label May 21, 2020
@qu1queee
Copy link
Contributor

any reasons not to call the params similar to how is used in Tekton?

@sbose78
Copy link
Member Author

sbose78 commented May 28, 2020

It kinda brings us back to the strongly typed Vs lossely typed discussion.

The idea of having env vars for containers have a strong clear meaning in a strategy agnostic way - and hence I wanted to make them first class citizens in the Build CRD.

What do you think?

@qu1queee
Copy link
Contributor

qu1queee commented Jun 2, 2020

@sbose78 make sense, +1. Thanks for explaining

@otaviof
Copy link
Member

otaviof commented Jun 16, 2020

It kinda brings us back to the strongly typed Vs lossely typed discussion.

The idea of having env vars for containers have a strong clear meaning in a strategy agnostic way - and hence I wanted to make them first class citizens in the Build CRD.

What do you think?

I like the idea of reusing common abstractions to represent the environment variables, so +1 on this.

And on supporting core-v1/EnvVar, what should we do with ValueFrom directive?

@sbose78
Copy link
Member Author

sbose78 commented Jun 17, 2020

We could start with it now, and then strip it down to a custom API as we deem fit? ValueFrom might be a handy thing in future anyway?

@adambkaplan
Copy link
Member

ValueFrom is essential if you are passing credentials via an env var, such as AWS secret keys.

In general I'm OK with leaking core Kubernetes APIs into our own. "On top of k8s" is a fundamental assumption, whereas "powered by Tekton" is a current implementation.

@gabemontero
Copy link
Member

gabemontero commented Jun 17, 2020 via email

@qu1queee qu1queee added the buildv1 Items with this label somehow pertain to getting equivalent buildv1 function in buildv2 label Oct 6, 2020
@qu1queee qu1queee added this to the release-v1.0.0 milestone Oct 6, 2020
@qu1queee qu1queee added beta BETA related issue and removed buildv1 Items with this label somehow pertain to getting equivalent buildv1 function in buildv2 labels Oct 6, 2020
@qu1queee qu1queee mentioned this issue Feb 24, 2021
4 tasks
@imjasonh
Copy link
Contributor

I think we're all in agreement so far, but I'd like to amend this:

Also, the BuildStrategy author should be able to refer to it in the container step or arg as $(build.env.HTTP_PROXY).

I think any build.env values should just be appended to any underlying TaskRun steps' envs, overriding any BuildStrategy env values. This makes it easier for BuildStrategy authors to consume envs, since they can just be unaware of them. If they care, they can get env values using a shell, e.g.:

steps:
- image: busybox
  command: sh
  args:
  - -c
  - |
    echo 'user set HTTP_PROXY to "${HTTP_PROXY}"'

Having placeholders like $(build.env.HTTP_PROXY) means our code has to replace those placeholders, and that gets messy. We'll have to do it for parameters (#537) but we can get away without it for envs.

@gabemontero
Copy link
Member

gabemontero commented Apr 7, 2021

ValueFrom is essential if you are passing credentials via an env var, such as AWS secret keys.

In general I'm OK with leaking core Kubernetes APIs into our own. "On top of k8s" is a fundamental assumption, whereas "powered by Tekton" is a current implementation.

@adambkaplan @otaviof @sbose78 - circling back to the ValueFrom discussion from last June/July, for reference just in case anyone was unaware, here is the Tekton example of using ValueFrom: https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#using-a-secret-as-an-environment-source

You'll see in that example they leverage Tekton parameters to allow for a user supplied vs. hard coded secret name.

Correct me if I'm wrong @imjasonh but I believe supporting that pattern lines up with at lease some of your points in #224 (comment), correct ?

@gabemontero
Copy link
Member

Some quick references I'm sure the folks already commenting here are aware of:

(though I still have to refresh my memory on when in Tekton variable substitution occurs on a Task fields vs. a TaskRun.TaskSpec which is what shipwright generates)

(same note as above; also, the defaulting plus override notion seems valuable, but my EP will have to get into if/how to surface the existing Tekton stepTemplate into shipwright API)

(you see a direct use of params to seed the k8s valueFrom there)

@coreydaley
Copy link
Contributor

/assign @coreydaley

@adambkaplan adambkaplan removed this from the release-v1.0.0 milestone Nov 17, 2021
@adambkaplan adambkaplan added this to the release-v0.6.0 milestone Nov 17, 2021
@adambkaplan
Copy link
Member

This work was completed in v0.6.0, under SHIP-0018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta BETA related issue kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

7 participants