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

Use secret values as parameters of a task #3443

Closed
quant-daddy opened this issue Oct 23, 2020 · 6 comments
Closed

Use secret values as parameters of a task #3443

quant-daddy opened this issue Oct 23, 2020 · 6 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@quant-daddy
Copy link

Feature request

Ability to read secrets in taskRun and use it as parameters for the task.

Use case

I want to use a task like kaniko in the catalog to build image. I also need to use a secret token as a build arg. I should not be using that secret inside the task itself because it is only needed to certain images and defeats the purpose of build args.

@quant-daddy quant-daddy added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 23, 2020
@ghost
Copy link

ghost commented Oct 23, 2020

Thanks for the issue report. We have a Tekton Enhancement Proposal for exactly this kind of scenario: tektoncd/community#225

What I'm proposing in tektoncd/community#225 is to expose Workspaces to individual Steps / Images in a Task. A Secret can then be safely mounted into that Workspace and will only be exposed to the single Step/Image.

At the moment params are not a good channel for secret values because the param values are stored as plain text in the TaskRun YAML after execution. So a possible next step on that could be to introduce a TEP for "sensitive params" or "redacted params" or something similar.

@quant-daddy
Copy link
Author

Thank you. This makes sense and is more secure way to doing things. In my case, I want to build an image using kaniko using secret build args which come from environment variables or passed as string (which is not safe as you mentioned). If I mount a volume/workspace with the secrets in it, I could not find a way to populate the environment variables from a volume. It has to be either a configmap or a secret object to read environment variables from it. What would you recommend?

@ghost
Copy link

ghost commented Oct 26, 2020

@skk2142 are you in control of the Task? If you want to write a Task that accepts a Secret and uses it for an env var in only one Step/Image today you could do it like this:

kind: Task
metadata:
  name: example
spec:
  params:
  - name: tokenSecretName
  - name: tokenSecretKey
  steps:
  - name: cant-access-secret
    image: foo
    command: ["echo"]
    args: ["$SECRET_TOKEN"] # will be empty string
  - name: uses-secret-env
    envVar:
    - name: SECRET_TOKEN
      valueFrom:
        secretKeyRef:
          name: $(params.tokenSecretName)
          key: $(params.tokenSecretKey)

If I mount a volume/workspace with the secrets in it, I could not find a way to populate the environment variables from a volume

The way to do this would be to use file redirection into an env var:

# in a Step:
script: |
  set +x # dont print to shell
  SECRET_TOKEN=$(cat /path/to/workspace/token-file)

@quant-daddy
Copy link
Author

Thank you, this is what I ended up doing.

@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 24, 2021
@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

2 participants