Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41758

Add a Declarative Agent extension to the Kubernetes plugin

    XMLWordPrintable

    Details

    • Similar Issues:

      Attachments

        Issue Links

          Activity

          Hide
          abayer Andrew Bayer added a comment -

          Initial very much still work in progress PR up at https://github.com/jenkinsci/kubernetes-plugin/pull/127

          Show
          abayer Andrew Bayer added a comment - Initial very much still work in progress PR up at https://github.com/jenkinsci/kubernetes-plugin/pull/127
          Hide
          abayer Andrew Bayer added a comment -

          PR is, I think, ready to go.

          Show
          abayer Andrew Bayer added a comment - PR is, I think, ready to go.
          Hide
          teju009 Pavan Tej Medapuram added a comment - - edited

          Reopening the issue due to the following reasons:

          • The plugin with this PR is not released
          • When we try to build the plugin from the master branch, received - 
            java.lang.ClassNotFoundException: org.csanchez.jenkins.plugins.kubernetes.pipeline.KubernetesDeclarativeAgentScript
          • After going through the PR comments, figured out a fix on the pom.xml and tried - -  <pluginFirstClassLoader>true</pluginFirstClassLoader>
            + <pluginFirstClassLoader>false</pluginFirstClassLoader>
          • Now we no longer receive that error but receive an error to provide a namespace for the kubernetes section in the agent block.

          So the ask is:

          • Can there be an elaborate documentation on all the parameters available on the Kubernetes block under agent
          • Should we define the entire Kubernetes cloud settings/podTemplate settings as well. Its not clear.

          Here is our Jenkinsfile:

          agent { 
            kubernetes {
              cloud 'kubernetes'
              label 'jenkinsslave'
              containerTemplate {
                name 'maven'
                image 'centos7-jenkins-kube:latest'
                ttyEnabled true
              }
            }
          }
          

           

           

          Show
          teju009 Pavan Tej Medapuram added a comment - - edited Reopening the issue due to the following reasons: The plugin with this PR is not released When we try to build the plugin from the master branch, received -  java.lang.ClassNotFoundException: org.csanchez.jenkins.plugins.kubernetes.pipeline.KubernetesDeclarativeAgentScript After going through the PR comments, figured out a fix on the pom.xml and tried - -  <pluginFirstClassLoader>true</pluginFirstClassLoader> + <pluginFirstClassLoader>false</pluginFirstClassLoader> Now we no longer receive that error but receive an error to provide a namespace for the kubernetes section in the agent block. So the ask is: Can there be an elaborate documentation on all the parameters available on the Kubernetes block under agent Should we define the entire Kubernetes cloud settings/podTemplate settings as well. Its not clear. Here is our Jenkinsfile: agent { kubernetes { cloud 'kubernetes' label 'jenkinsslave' containerTemplate { name 'maven' image 'centos7-jenkins-kube:latest' ttyEnabled true } } }    
          Hide
          teju009 Pavan Tej Medapuram added a comment -

          To add more details into the error:

          java.io.FileNotFoundException: /var/run/secrets/kubernetes.io/serviceaccount/namespace (No such file or directory)
          

           We are trying to use an internal installation of kubernetes with the kubernetes creds on the credential store. Is there anyway we could specify the right url and creds to the cluster with the declarative syntax.

          Show
          teju009 Pavan Tej Medapuram added a comment - To add more details into the error: java.io.FileNotFoundException: / var /run/secrets/kubernetes.io/serviceaccount/namespace (No such file or directory)  We are trying to use an internal installation of kubernetes with the kubernetes creds on the credential store. Is there anyway we could specify the right url and creds to the cluster with the declarative syntax.
          Hide
          teju009 Pavan Tej Medapuram added a comment -

          Not sure if I made progress but now I see a different error with the following agent section on my Jenkinsfile:

            agent { kubernetes {
              cloud 'kubernetes'
              label 'test'
                containerTemplate {
                  name 'jnlp'
                  image 'some_image'
                  ttyEnabled true
                }
            }}
          
          

          The job keeps waiting for the container to be provisioned. On the jenkins logs, I see that it is retrying 100 times, trying to provision the jnlp image from the docker hub. Not sure why it is respecting the image I configured.

          Show
          teju009 Pavan Tej Medapuram added a comment - Not sure if I made progress but now I see a different error with the following agent section on my Jenkinsfile: agent { kubernetes { cloud 'kubernetes' label 'test' containerTemplate { name 'jnlp' image 'some_image' ttyEnabled true } }} The job keeps waiting for the container to be provisioned. On the jenkins logs, I see that it is retrying 100 times, trying to provision the jnlp image from the docker hub. Not sure why it is respecting the image I configured.
          Hide
          csanchez Carlos Sanchez added a comment -

          The declarative extension is not ready yet, that's why it is undocumented. There is a test for minikube, but other than that, not really tested

          Show
          csanchez Carlos Sanchez added a comment - The declarative extension is not ready yet, that's why it is undocumented. There is a test for minikube, but other than that, not really tested
          Hide
          csanchez Carlos Sanchez added a comment -

          I have verified that both the example at https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/declarative.groovy and this one work in a Jenkins 2.66 server with the latest master build of the plugin

            pipeline {
          
            agent { kubernetes {
              cloud 'kubernetes'
              label 'test'
                containerTemplate {
                  name 'jnlp'
                  image 'jenkinsci/jnlp-slave:2.62-alpine'
                  ttyEnabled true
                  args '${computer.jnlpmac} ${computer.name}'
                }
            }}
          
          
            stages {
              stage('Run maven') {
                steps {
                  sh 'hostname'
                }
              }
            }
          }
          
          

          I'm going to close this issue, if you have a specific problem please open a new one

          Show
          csanchez Carlos Sanchez added a comment - I have verified that both the example at https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/declarative.groovy and this one work in a Jenkins 2.66 server with the latest master build of the plugin pipeline { agent { kubernetes { cloud 'kubernetes' label 'test' containerTemplate { name 'jnlp' image 'jenkinsci/jnlp-slave:2.62-alpine' ttyEnabled true args '${computer.jnlpmac} ${computer.name}' } }} stages { stage( 'Run maven' ) { steps { sh 'hostname' } } } } I'm going to close this issue, if you have a specific problem please open a new one
          Hide
          fonsecas72 hugo fonseca added a comment -

          Hi, can someone tell me how can I setup volumes please? 

          Show
          fonsecas72 hugo fonseca added a comment - Hi, can someone tell me how can I setup volumes please? 
          Hide
          bd82 Shahar Soel added a comment - - edited

          I think this may be missing some functionality.

          It seems only one containerTemplate can possibly be defined using the declarative syntax.

          See: https://stackoverflow.com/questions/47470498/how-to-define-multiple-containers-in-declarative-pipeline

          Is this an intended limitation or an oversight?

           

          The default jnlp image is not suitable for my needs which means I have to try to mix up

          declarative and scripted or swap to scripted completely...

           

          Could this be resolved?

          Do I need to open a new ticket for this?

           

          Thanks.

          Shahar.

          Show
          bd82 Shahar Soel added a comment - - edited I think this may be missing some functionality. It seems only one containerTemplate can possibly be defined using the declarative syntax. See: https://stackoverflow.com/questions/47470498/how-to-define-multiple-containers-in-declarative-pipeline Is this an intended limitation or an oversight?   The default jnlp image is not suitable for my needs which means I have to try to mix up declarative and scripted or swap to scripted completely...   Could this be resolved? Do I need to open a new ticket for this?   Thanks. Shahar.

            People

            Assignee:
            abayer Andrew Bayer
            Reporter:
            abayer Andrew Bayer
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: