【发布时间】:2020-04-23 18:16:56
【问题描述】:
我正在使用来自stable/jenkins helm chart 的 Jenkins - 一切都很好我将带有 id_rsa/.pub 密钥的秘密作为卷附加到 jenkins master(在/opt/sshkeys/ 中,为什么会有?因为创建的文件是777权限的软链接所以不能直接去$HOME/.ssh)
root@agent-pod:/opt/config# ls -alh
total 12K
drwxrwxrwx 3 root root 4.0K Apr 20 13:00 .
drwxr-xr-x 1 root root 4.0K Apr 20 13:02 ..
drwxr-xr-x 2 root root 4.0K Apr 20 13:00 ..2020_04_20_13_00_29.601158101
lrwxrwxrwx 1 root root 31 Apr 20 13:00 ..data -> ..2020_04_20_13_00_29.601158101
lrwxrwxrwx 1 root root 13 Apr 20 13:00 id_rsa -> ..data/id_rsa
然后运行几个脚本(cp、chmod)将它们作为正确的文件移动到/home/jenkins/.ssh/id_rsa - jenkins 代理的问题是 - 由于 777 原因,我不能简单地附加卷,我不能使用代理上的任何命令作为主要 ENTRYPOINT 命令都是使其成为代理的命令
command:
args: "${computer.jnlpmac} ${computer.name}"
- 尝试对
mkdir /home/jenkins/.ssh && chmod ... && <above args>或;进行任意组合会使pod 进入0/1 Completed状态而不是1/1 Running
有谁知道如何将两个 priv 和 pub 键放入 jenkins 代理?这是主要问题。我刚才说的都是我的解决方法。
Jenkins 的部分 Kubernetes 插件(在 Kubernetes 上运行 Jenkins 时需要)显示:
Constraints
Multiple containers can be defined in a pod. One of them is automatically created with name
jnlp, and runs the Jenkins JNLP agent service, with args ${computer.jnlpmac} ${computer.name},
and will be the container acting as Jenkins agent.
Other containers must run a long running process, so the container does not exit. If the default
entrypoint or command just runs something and exit then it should be overridden with something
like cat with ttyEnabled: true.
WARNING If you want to provide your own Docker image for the JNLP slave, you must name the
container jnlp so it overrides the default one. Failing to do so will result in two slaves
trying to concurrently connect to the master.
PS:我在https://kubernetes.io/docs/concepts/configuration/secret/#use-cases (ctrl+f Use-Case: Pod with ssh keys) 看到了描述如何将密钥附加到 pod 的官方文档,但我在 777 中遇到了上述问题
PS:要查看部署和值文件的外观和测试,您可以安装 helm3 和 helm3 show values stable/jenkins > jenkins.yaml
【问题讨论】:
-
我认为这个媒体上的tutorial 可以回答你的问题。你能检查一下,如果它解决了你的问题,请告诉我?
-
我通过创建 nfs 服务器并将其作为卷附加到代理并手动将密钥放在那里解决了这个问题
标签: docker jenkins kubernetes