I am currently struggling setting up a proper yaml configuration for the K8s Cluster our Jenkins Pipeline is running in (see below) .
Until now the whole configuration was set in the Jenkins UI, defining the cloud, the basic pod template and the different working pods. All of the working pods rely on a docker image, which were already custom made before I started working on the project. There is also an image for a custom JNLP container, which I need to use.
My approach was to use the use the output pod.yaml from the Jenkins Pipeline log (based on the GUI configuration) as a basic template for creating my own yaml. So all necessary parameters should be set correctly. I'm just wondering if the jnlp container is missing some credentials...Idk, I'm a bit lost as I'm just getting started with the relevant technologies and would very much appreciate your help, indeed. Thanks :)
The Error message I get is the following:
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
View my code here:
Snippet from my Jenkinsfile:
stage ('PC Linux x64') {
agent {
kubernetes {
cloud 'our-cloud'
label 'cloud_work'
idleMinutes 5
defaultContainer 'work-docker-dml'
yamlFile 'pod.yaml'
}
}
YAML Configuration I created ("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