我目前正在努力为Jenkins Pipeline运行的K8s集群设置适当的yaml配置(见下文)。
到目前为止,整个配置都是在Jenkins UI中设置的,定义了云,基本的pod模板和不同的工作pod。所有的工作pod都依赖于一个docker镜像,这是在我开始项目之前就已经定制的。还有一个自定义JNLP容器的镜像,我需要使用它。
我的方法是使用JenkinsPipeline日志的输出pod.yaml(基于GUI配置)作为创建我自己的yaml的基本模板。所以所有必要的参数都应该正确设置。我只是想知道jnlp容器是否缺少一些凭据...Idk,我有点迷路,因为我刚刚开始使用相关技术,非常感谢您的帮助,确实.谢谢:)
我得到的错误消息如下:
Dec 08, 2021 3:23:39 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Protocol JNLP4-connect encountered an unexpected exception
java.util.concurrent.ExecutionException: org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException: Unknown client name: \cloud-work-z8vpq-snct7
在这里查看我的代码:
来自我的Jenkinsfile的片段:
stage ('PC Linux x64') {
agent {
kubernetes {
cloud 'our-cloud'
label 'cloud_work'
idleMinutes 5
defaultContainer 'work-docker-dml'
yamlFile 'pod.yaml'
}
}
我创建的YAML配置(“pod.yaml”):
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
jenkins-work: "k8s-jnlp-agents"
jenkins/label: "cloud_work"
name: "cloud-work"
spec:
containers:
- command:
- "/bin/bash"
- "-ex"
image: "artifactory.company.local:6013/work:ubnt20.04_dml_v2"
imagePullPolicy: "Always"
name: "work-docker-dml"
securityContext:
privileged: false
runAsGroup: 1000
runAsUser: 1000
tty: true
volumeMounts:
- mountPath: "/net/example/examplemount"
name: "volume-3"
readOnly: false
workingDir: "/home/jenkins/agent"
- command:
- "jenkins-agent"
image: "artifactory7.company.local/company-docker/company-focal-jnlp"
imagePullPolicy: "Always"
name: "jnlp"
securityContext:
privileged: false
runAsGroup: 1000
runAsUser: 1000
tty: true
volumeMounts:
- mountPath: "/net/example/examplemount"
name: "volume-3"
readOnly: false
workingDir: "/home/jenkins/agent"
hostNetwork: false
imagePullSecrets:
- name: "secret 1"
- name: "secret 2"
nodeSelector:
kubernetes.io/os: "linux"
restartPolicy: "Never"
volumes:
- emptyDir:
medium: ""
name: "workspace-volume"
- name: "volume-3"
persistentVolumeClaim:
claimName: "example"
readOnly: false
1条答案
按热度按时间pu82cl6c1#
我有同样的问题.我能够通过使用声明式管道修复它. Jenkinsfile是不同的,因为这一点.以下是我的一个例子.没有必要为pod. yml. Pods/容器在podTemplate-Section声明: