在Tekton Pipeline参数中使用Kubernetes秘密价值
我目前正在使用Tekton实施CI管道。我想知道是否有一种方法可以使用某种valuefromenv
用于管道参数。
例如,要使用公司的Sonar主机来验证Sonarqube分析的任务,我需要登录令牌,我宁愿通过引用秘密插入它,而不是直接通过它。
由于我对Tekton是个新手,因此我不确定我是否还没有掌握Tekton的方式。我想到的两种可能性是:
- 一个“预任务”,在其步骤定义中读取ENV并将其发布为一个(然后可以用作下一个任务的参数)
- 将秘密作为任务的文件安装要加载秘密(例如
cat
ting it)
这两个想法都不觉得我应该这样做,但是也许我在这里错了。
任何帮助都将受到赞赏!
I am currently implementing a CI Pipeline using Tekton. I was wondering if there is a way to use some kind of valueFromEnv
for pipeline params.
For example to authenticate a Task for sonarqube analysis with my company's sonar host i need the login token, which I would rather want to insert via reference to a secret than passing it directly.
As I am relatively new to tekton I am unsure if I just haven't grasped the tekton way of doing this. Two possibilities that crossed my mind were:
- A "Pre-Task" which reads the env in it's step definition and publishes it as a result (which then can be used as param to the next Task)
- Mounting the secret as a file for the Task to load the secret (e.g. by
cat
ting it)
Both of those ideas do not feel like I should do it this way, but maybe I am wrong here.
Any help is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第一个想法不是不可能的,而是在我眼中也很丑陋。您可以通过DockerFile在图像中设置所需的ENV,然后在任务中以后使用它:
Docker文件(示例):
之后您可以在脚本任务中使用它:
推荐(适用于OpenShift)
清洁器方法是,将其定义为秘密(键/值),或将其定义为sealeedsecret(不透明),
可以直接在OpenShift-UI上的命名空间或代码中完成。
下一步是在您的任务中“绑定”它:
当意!
set -x
echo
记录下来。现在,我看到您可能无法在OpenShift中工作 - 这是Kubernetes页面: https:// /kubernetes.io/docs/concepts/configuration/secret/ =>使用秘密作为环境变量(与您的第一个想法接近 - 但整个页面看起来不错)
Your first Idea is not impossible, but in my eyes ugly as well. You can set the desired ENV in your image via DockerFile and use it later in the task:
Docker file (example):
afterwards you can just use it in script tasks like:
RECOMMENDED (for Openshift)
The cleaner way is, to define it as Secret (Key/value) or as a SealeedSecret (Opaque)
this can be done directly within the namespace on the openshift-UI or as Code.
Next step is to "bind" it in your task:
BEWARE!!! If you run it that way - nothing should be logged - if you leave out
set +x
before andset -x
after theecho
it is logged.Now I saw you're may not working in openshift - here is the kubernetes page: https://kubernetes.io/docs/concepts/configuration/secret/ => Using Secrets as environment variables (is close to your first idea - but the whole page looks like good cookbook)