Example of a working pod with the kubernetes-ci plugin

663 views
Skip to first unread message

Sébastien Douche

unread,
Nov 21, 2016, 3:43:08 AM11/21/16
to Jenkins Users
Hi folks,
I try with the kubernetes-ci to create a pod with a container to do some
work (get source code, compile it, etc) and a jnlp container (only used
to connect to the Jenkins server). The goal is to avoid the adding of
the jnlp binary into all my containers. So I tried this:

----------------------------------------
apiVersion: "v1"
kind: "Pod"
metadata:
name: "k8s-slave"
labels:
name: "k8s-slave"
spec:
containers:
- name: "jenkins-slave"
image: "jenkinsci/jnlp-slave"
volumeMounts:
- mountPath: /home/jenkins
name: workspace-volume
env:
- name: "JENKINS_URL"
value: "https://XXX"
- name: "golang"
image: "golang:1.6.3-alpine"
volumeMounts:
- mountPath: /home/jenkins
name: workspace-volume
volumes:
- emptyDir: {}
name: workspace-volume
----------------------------------------

And a trivial job which try to access on the golang container:

----------------------------------------
git clone https://github.com/hashicorp/terraform.git
mkdir -p /go/src/github.com/hashicorp
ln -s `pwd` /go/src/github.com/hashicorp/terraform
cd /go/src/github.com/hashicorp/terraform && make core-dev
----------------------------------------

It doesn't work 'cause the job have access on the jnlp fs and not the
golang one. What is missing to access on the golang container?



Thanks.


--
Sébastien Douche <s...@nmeos.net>
Twitter: @sdouche
http://douche.name

Carlos Sanchez

unread,
Nov 23, 2016, 4:12:24 PM11/23/16
to Jenkins Users
You can't just jump from a container to another, can only share through network or shared filesystem.
http://kubernetes.io/docs/user-guide/pods/

I suggest using the Kubernetes Jenkins plugin that can do exactly what you want using pipeline
https://github.com/jenkinsci/kubernetes-plugin/blob/master/README.md#pipeline-support

Sébastien Douche

unread,
Nov 24, 2016, 10:40:00 AM11/24/16
to jenkins...@googlegroups.com
On Wed, Nov 23, 2016, at 22:12, Carlos Sanchez wrote:

Hi Carlos

> I suggest using the Kubernetes Jenkins plugin that can do exactly what
> you want using pipeline
> https://github.com/jenkinsci/kubernetes-plugin/blob/master/README.md#pipeline-support

Doesn't work for me:
https://issues.jenkins-ci.org/browse/JENKINS-39695

Daniel Serodio

unread,
Dec 6, 2016, 4:37:49 PM12/6/16
to Jenkins Users
Hi Carlos,

I'm trying to understand how composing multiple containers (one with the JNLP slave, another with Maven) in a Pod Template but I can't get the example pipeline to work. The Jenkins logs show that it's "Waiting for slave to connect", and after 100 tries it gives up, deletes the Pod and creates a new one ad infinitum.

Using "kubectl get pods" I can see that the 2 containers have been created and the Pod is running, but it won't connect to the Jenkins master.

The example pipeline uses a maven and a golang images, but none of them knows how to connect to Jenkins using JNLP. The README says that "The jnlp agent image used can be customized by adding it to the template", but it seems that I need to include a JNLP image in the pod template so that it can talk to Jenkins.

Carlos Sanchez

unread,
Dec 19, 2016, 2:44:43 AM12/19/16
to jenkins...@googlegroups.com


On Tue, Dec 6, 2016, 22:37 Daniel Serodio <dser...@gmail.com> wrote:
Hi Carlos,

I'm trying to understand how composing multiple containers (one with the JNLP slave, another with Maven) in a Pod Template but I can't get the example pipeline to work. The Jenkins logs show that it's "Waiting for slave to connect", and after 100 tries it gives up, deletes the Pod and creates a new one ad infinitum.

Using "kubectl get pods" I can see that the 2 containers have been created and the Pod is running, but it won't connect to the Jenkins master.

You need to get the pod logs to see why it is not connecting. kubectl logs pods/... jnlp


The example pipeline uses a maven and a golang images, but none of them knows how to connect to Jenkins using JNLP. The README says that "The jnlp agent image used can be customized by adding it to the template", but it seems that I need to include a JNLP image in the pod template so that it can talk to Jenkins.


On Wednesday, November 23, 2016 at 7:12:24 PM UTC-2, Carlos Sanchez wrote:
You can't just jump from a container to another,  can only share through network or shared filesystem.
http://kubernetes.io/docs/user-guide/pods/

I suggest using the Kubernetes Jenkins plugin that can do exactly what you want using pipeline
https://github.com/jenkinsci/kubernetes-plugin/blob/master/README.md#pipeline-support

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/khpG2-6NBNI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9ff5076f-b06e-428f-a43e-5c9d2e4b0094%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joe Rhaman

unread,
Jan 28, 2017, 12:36:55 PM1/28/17
to Jenkins Users
Carlos,

This Plugin clearly doesn't work.... Please provide a detailed how to at least rather on how this works.

This is turning out to be a complete waste of time. 

Joe

Carlos Sanchez

unread,
Feb 10, 2017, 3:40:41 AM2/10/17
to Jenkins Users


On Saturday, January 28, 2017 at 6:36:55 PM UTC+1, Joe Rhaman wrote:
Carlos,

This Plugin clearly doesn't work.... Please provide a detailed how to at least rather on how this works.

This is turning out to be a complete waste of time. 


Considering that are over 1200 installations, I think it is safe to assume that it does work for most people.

As I mentioned in the previous mail, in order to see why pods can't connect to jenkins you need to get the pod logs in Kubernetes side: kubectl logs pods/{your pod id} jnlp

Vamsi krishna

unread,
Dec 28, 2017, 4:17:56 PM12/28/17
to Jenkins Users
@carlos   
i checked the logs but there is nothing showing in the logs.... jenkins is running outside of the cluster.. so i cant use the jenkins if i run outside the cluster.
Message has been deleted

Carlos Sanchez

unread,
Mar 20, 2018, 6:31:54 PM3/20/18
to jenkins...@googlegroups.com
Yes it totally does. You need to open the ports from agent to master


On Tue, Mar 20, 2018, 21:19 Fadi Al-Farah <fara...@gmail.com> wrote:
I'm also interested in this.. Does this plugin support having a Jenkins master running somewhere else and the slaves in the k8s cluster?
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/khpG2-6NBNI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages