Perform actual hardware tests using jenkins pipeline and kubernetes

44 views
Skip to first unread message

touseef

unread,
Jan 20, 2020, 1:19:00 AM1/20/20
to Jenkins Users
Can anyone point me in right direction,

I have a use case as follow:

Kubernetes master running the jenkins and i have n number of physical machine connected with different hardwares,So what i want to achieve is when a specific job is triggered in jenkins to execute a test on hardware , k8's(kubernetes master) should route and connect to that machine in a pool which has requiste hardware and execute the tests.

Any pointer how to achieve is appreciated

Björn Pedersen

unread,
Jan 20, 2020, 2:45:23 AM1/20/20
to Jenkins Users
Hi,

configure each HW-machine as an agent with appropirate labels and the request these labels in your job.
I recommend to use the modern pipeline jobs as there you only need to request all the wanted labels in a node().
Otherwise you probably need the multi-job plugin.

Björn

Andrey Babushkin

unread,
Jan 20, 2020, 11:37:31 AM1/20/20
to Jenkins Users

Hi,
As far as I understood you're using Jenkins Kubernetes plugin and you have your own Kubernetes cluster with a few physical nodes connected to it.
In that case you should label your Kubernetes nodes like this (assuming you have working kubectl setup):
kubectl label node node1.example.com hw_type=type1

kubectl label node node2.example.com hw_type=type2

Then you should specify label you need in podTemplate section of your Jenkins pipeline (I slightly changed code from examples folder in Kubernetes plugin repo - https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/maven.groovy)

podTemplate(nodeSelector: 'hw_type=type1', containers: [
    containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine',
                      ttyEnabled: true, command: 'cat',

    )
  ]) {

  node(POD_LABEL) {
    stage('Tests on hardware type 1') {
      git 'https://github.com/jenkinsci/kubernetes-plugin.git'
      container('maven') {
          sh 'mvn -B clean package'
      }
    }
  }
}


touseef

unread,
Jan 26, 2020, 11:38:43 PM1/26/20
to Jenkins Users
Thanks for the reply .It would work fine if the master and the nodes are on the same cluster under the same network.
However my use case is my nodes can be in different network and it will not work with kubernetes.
is there any other way without using kubernets perhaps

JonathanRRogers

unread,
Jan 27, 2020, 4:26:59 PM1/27/20
to Jenkins Users
Jenkins has several methods of running and connecting to agents. The fact that Jenkins master is running in a Kubernetes cluster doesn't limit how it connects to agents. For example, you can use the SSH slaves plugin to connect to any machine running SSH and visible to the Jenkins master. https://plugins.jenkins.io/ssh-slaves
Reply all
Reply to author
Forward
0 new messages