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

Specify Params in Pipeline #263

Closed
bkuschel opened this issue Nov 23, 2018 · 14 comments
Closed

Specify Params in Pipeline #263

bkuschel opened this issue Nov 23, 2018 · 14 comments
Labels
design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given

Comments

@bkuschel
Copy link

bkuschel commented Nov 23, 2018

Expected Behavior

We want to be able to provide Pipeline wide parameters which can be used in templating across Tasks.

For example, I should be able to create something like this (spec for params can be different!)

kind: Pipeline

...
spec:
  params:
    - name: 'namespace'
      value: 'test'
      type: 'string' # this is assuming we go ahead with something like #207 and add some types
- name: deploy-bundle-test
  taskRef:
    name: deploy-with-kubectl
  inputSourceBindings:
  - name: workspace
    resourceRef:
        name: guestbook    
  params:
  - name: namespace
    value: "${params.namespace}" # this should come from the global params

Actual Behavior

PipelineRun only accepts Resources, not parameters. We can specify templating within a Pipeline, but it only references Resources within the Task that uses the templating, there is no concept of global templating.

Additional Info

For example, have a pipeline with a helm deployment step that has a parameter that specifies the namespace to install into (for isolation.)

Strongly related to: #254

Note that one strange thing here is that:

  • At the Task level, we express parameters we want in Tasks, and we specify the params we're actually using within the `TaskRun
  • At the Pipeline level, the params exist within the Pipeline only, and are never provided in the PipelineRun

In the future we may want to consider moving more params into PipelineRuns??? Maybe!

@bkuschel bkuschel changed the title Specify Params at PipelineRun Level Specify Params in PipelineRun Nov 23, 2018
@bobcatfish
Copy link
Collaborator

Hey @bkuschel ! Thanks for opening this issue :D

I think we may have this functionality already, though let me know if this isn't what you're looking for.

You could have a helm task like this:

kind: Task
metadata:
  name: deploy-with-helm
  namespace: default
spec:
  inputs:
    resources:
    - name: workspace
      type: git
...
    params:
    - name: namespace
...
  steps:
  - name: deploy
    image: kubernetes-helm
    command: ['helm']
    args:
      - 'install'
      - '--namespace'
      - '${inputs.params.namespace}'

Then you could use templating in the Pipeline to provide the value of the namespace parameter:

kind: Pipeline
...
- name: deploy-bundle-test
  taskRef:
    name: deploy-with-kubectl
  inputSourceBindings:
  - name: workspace
    resourceRef:
        name: guestbook    
  params:
  - name: namespace
    value: "${inputs.resources.workspace.revision}"

(From #64)

But you can only use inputs and outputs from the Task in the templating - I'm thinking what you want is some kind of "global" parameter (like in #254) that you can use for the namespace and pass into Tasks throughout the Pipeline?

@bobcatfish
Copy link
Collaborator

(Note: if we do want a "pipeline wide variable" I'm thinking that evolving PipelineParams like you suggested in slack is probably the way to go @bkuschel !)

@abayer
Copy link
Contributor

abayer commented Nov 27, 2018

Yeah, I know my first example in #254 was based on the idea of Pipeline parameters that can be referenced by all the Tasks contained in the Pipeline, so we don't have to duplicate setting Task parameters multiple times.

@bkuschel
Copy link
Author

But you can only use inputs and outputs from the Task in the templating - I'm thinking what you want is some kind of "global" parameter

@bobcatfish right, something that is PipelineRun specific (ie, pertains only to a particular run of the pipeline).

@bobcatfish
Copy link
Collaborator

Cool, sounds good to me! Anyone have any other ideas besides extending PipelineParams to contain arbitrary key/values? (might tie in well with #121!!)

@bobcatfish
Copy link
Collaborator

Another idea would be to have a field in the Pipeline itself (I guess we don't have to use PipelineParams just because it exists XD)

@bobcatfish
Copy link
Collaborator

Another idea would be to have a field in the Pipeline itself (I guess we don't have to use PipelineParams just because it exists XD)

In #282 we are getting rid of PipelineParams (as we know it) so adding these global vars to Pipelines probably makes the most sense atm :D

@bobcatfish bobcatfish added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Nov 30, 2018
@bobcatfish bobcatfish changed the title Specify Params in PipelineRun Specify Params in Pipeline ~Run~ Nov 30, 2018
@bobcatfish bobcatfish changed the title Specify Params in Pipeline ~Run~ Specify Params in Pipeline Nov 30, 2018
@bobcatfish
Copy link
Collaborator

@bkuschel I updated the description pretty significantly, let me know (or update it!) if this no longer expresses what you're looking for

@bobcatfish bobcatfish added meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given design This task is about creating and discussing a design labels Nov 30, 2018
@bkuschel
Copy link
Author

yes, pipeline is good but I was thinking of being able to provide this through PipelineRun as well. Here's the specific scenario..

  1. I create a common pipeline with tasks for the basic logic of deploying some composition of microservices that constitutes some app that is be to deployed to several environments (ie. clusters/namespaces). Environments are distinct in terms of back-end connections, domains, secrets, etc.
  2. The pipeline has tasks with steps that have been generalized so that theses environment configurations can be supplied through code.
  3. One option is to provide this configuration as part of github repo resources input into the task but as some steps are configured to use pre-fab docker images ("builders") from other providers, some configurations need to be passed in as environment variables to the pods

So at this point, if I am to fire off a pipelinerun for a particular environment i'd need to pass in the unique repositories for the environment as well as the parameters that eventually make their way down to the steps as environmental variables. If this is only provided through pipeline, i'd need to redefine the pipeline for every run which makes it difficult to separate out the commonality between environments.

One idea i had was to create a resource that is just a bag of properties that's passed around.

I hope that makes sense.

@bobcatfish
Copy link
Collaborator

(sorry for the super delayed reply @bkuschel , this shouldn't be the norm!)

One idea i had was to create a resource that is just a bag of properties that's passed around.

Interesting suggestion - in earlier iterations of the Pipeline we had something called PipelineParams which I think would have satisfied the use case you're describing here.

It'd be interesting to see if we can find a design for something similar that works with our latest CRDs.

I'm planning to create an issue in the near future talking about how event triggering systems would create new PipelineRuns - in the current design they end up needing to make a lot of PipelineResources as well, but if we had some kind of "parameters" type, it could be possible to provide overrides instead 🤔

@abayer
Copy link
Contributor

abayer commented Jan 31, 2019

So my initial thinking on this is that we probably need to have the ability to specify parameters themselves (with options for a default value for the parameter or if a value for the parameter is required, perhaps) in Pipeline, and values for those parameters in PipelineRun. Then the parameter values would be used at runtime via PipelineTask to pass to the actual task execution, and would also be available for use in Pipeline itself for values in things like Timeout and any future Pipeline configuration fields (like Pipeline-wide environment variables, i.e., #254). I'll start work on a PR shortly.

@abayer
Copy link
Contributor

abayer commented Feb 3, 2019

/assign abayer

@bobcatfish
Copy link
Collaborator

Thanks @abayer !! 🎉

@abayer
Copy link
Contributor

abayer commented Feb 7, 2019

I'm still wondering if there's anything else we want to allow parameter values to be used in, but for now, it really seemed like PipelineTask parameters were the only one that made sense. Of course, once we tackle #254, there'll be something else. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design This task is about creating and discussing a design help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given
Projects
None yet
Development

No branches or pull requests

3 participants