Issue
I configured a local cluster of K8s with an instance of Jenkins and the idea is that it will run the slaves within that cluster. I configured the K8s plugin inside Jenkins and put a pod/container for testing with the default Jenkins slave, however, K8s seems to kill the pod before even running the pipeline. Has anyone gone through this to help?
May 21, 2022 3:18:05 PM INFO hudson.slaves.NodeProvisioner update
kube-agent-px18m provisioning successfully completed. We have now 2 computer(s)
May 21, 2022 3:18:05 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher launch
Created Pod: kubernetes jenkins/kube-agent-px18m
May 21, 2022 3:18:07 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher launch
Pod is running: kubernetes jenkins/kube-agent-px18m
May 21, 2022 3:18:17 PM INFO org.csanchez.jenkins.plugins.kubernetes.pod.retention.Reaper$TerminateAgentOnContainerTerminated lambda$onEvent$1
jenkins/kube-agent-px18m Container jnlp was just terminated, so removing the corresponding Jenkins agent
May 21, 2022 3:18:17 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave _terminate
Terminating Kubernetes instance for agent kube-agent-px18m
May 21, 2022 3:18:17 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave deleteSlavePod
Terminated Kubernetes instance for agent jenkins/kube-agent-px18m
May 21, 2022 3:18:17 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave _terminate
Disconnected computer kube-agent-px18m
May 21, 2022 3:18:17 PM WARNING org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher launch
Error in provisioning; agent=KubernetesSlave name: kube-agent-px18m, template=PodTemplate{id='d3170ee8-ea06-474e-8e52-a2275d90346a', name='kube-agent', namespace='jenkins', idleMinutes=5, label='kubeagent', containers=[ContainerTemplate{name='jnlp', image='jenkins/jnlp-slave', workingDir='/home/jenkins', command='', args='', resourceRequestCpu='', resourceRequestMemory='', resourceRequestEphemeralStorage='', resourceLimitCpu='', resourceLimitMemory='', resourceLimitEphemeralStorage='', livenessProbe=ContainerLivenessProbe{execArgs='', timeoutSeconds=0, initialDelaySeconds=0, failureThreshold=0, periodSeconds=0, successThreshold=0}}]}
java.lang.IllegalStateException: Node was deleted, computer is null
at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.launch(KubernetesLauncher.java:193)
at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:298)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
The job is waiting for the executor and K8s is in a loop creating the new slave pod and terminating it.
Solution
The problem was solved. I had forgotten to open port 50000 in Kubernetes so that the master and slave could communicate.
Answered By - Alan de Almeida
Answer Checked By - Terry (JavaFixing Volunteer)