如何解决在Jenkins声明式管道中使用imagePullSecrets
这是我用来创建动态广告连播的Jenkinsfile中的代码段
agent {
kubernetes {
label "hello-stage"
cloud "some-cloud"
defaultContainer "jnlp"
idleMinutes 1
containerTemplate {
name 'jnlp'
image 'some-image'
alwaysPullImage true
ttyEnabled true
resourceRequestMemory '1Gi'
resourceLimitMemory '2Gi'
}
imagePullSecrets '["secret-name"]'
} // kubernetes
} // agent
除imagePullSecrets
之外的所有内容均有效。我试图找到没有运气的文档。我是第一次将Jenkins与Kubernetes结合使用。这是我得到的错误
WorkflowScript: 23: Invalid config option "imagePullSecrets" for agent type "kubernetes". Valid config options are [activeDeadlineSeconds,cloud,containerTemplate,containerTemplates,customWorkspace,defaultContainer,idleMinutes,inheritFrom,instanceCap,label,namespace,nodeSelector,podRetention,serviceAccount,slaveConnectTimeout,supplementalGroups,workingDir,yaml,yamlFile,yamlMergeStrategy] @ line 23,column 13.
imagePullSecrets '["quay-operator-updates"]'
有人可以帮我弄清楚如何在Jenkins声明性管道中使用imagePullSecrets吗?
谢谢
解决方法
containerTemplate
现在已被弃用,如前所述 here
使用 yaml 语法传递 imagePullSecrets
如下:
pipeline {
agent {
kubernetes {
yaml """\
apiVersion: v1
kind: Pod
metadata:
name: 'jenkins-slave'
namespace: 'your-namespace'
spec:
containers:
- name: jnlp
image: jenkins/inbound-agent:4.3-9-alpine
tty: true
- name: demo-application
image: some-image
imagePullSecrets:
- name: your-secret
tty: true
""".stripIndent()
}
}
stages {
stage('run app') {
steps {
container('demo-application') {
echo POD_CONTAINER
}
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。