Did you manage to solve the issue? I'm actually having the same problem but 
I do use the CasC plugin as Carlos suggested. Everything looks ok in the UI 
but only starts working if I hit "Save".

I copied away the whole JENKINS_HOME before and after hitting "Save". As 
expected, the diff doesn't show any changes. I tried triggering a reload of 
the config via CLI and via Groovy init script. Nothing helped but manually 
saving in the UI.

Here's the relevant part from the jenkins.yaml:

jenkins:
  clouds:
    - kubernetes:
        name: kubernetes
        serverUrl: https://kubernetes.default
        namespace: default
        jenkinsUrl: http://jenkins-master:8080
        jenkinsTunnel: jenkins-agent:50000
        templates:
          - name: k8s-agent
            idleMinutes: 30
            containers:
              - name: jnlp
                image: jenkinsci/jnlp-slave:3.27-1-alpine
                command: ""
                args: ""


Jenkins version: 2.150.1 LTS

Installed plugins:

configuration-as-code:1.4
workflow-aggregator:2.6
kubernetes:1.14.2
kubernetes-credentials-provider:0.10
timestamper:1.8.10
locale:1.4

I'd appreciate any help.

--Reinhard


On Monday, August 20, 2018 at 4:39:57 PM UTC+2, Carlos Sanchez wrote:
>
> Have you tried configuration as code plugin?
>
> On Mon, Aug 20, 2018, 15:54 Alex <[email protected] <javascript:>> 
> wrote:
>
>> I am trying to configure the kubernetes plugin by using groovy at 
>> startup. 
>>
>> The problem that I have is that I can see the configuration in the 
>> "Configure System" menu, but it's not working unless i click on "Save"
>>
>> This is my groovy:
>>
>> import org.csanchez.jenkins.plugins.kubernetes.*
>> import jenkins.model.*
>>
>> def jenkins_instance = Jenkins.instance
>> def kubernetes = new KubernetesCloud('Kubernetes')
>>
>> // Configure Kubernetes Cloud
>> kubernetes.setNamespace('jenkins')
>> kubernetes.setJenkinsUrl(jenkins_instance.getRootUrl())
>> kubernetes.setMaxRequestsPerHostStr('30')
>> kubernetes.setConnectTimeout(30)
>> kubernetes.setReadTimeout(30)
>> kubernetes.setUsageRestricted(false)
>>
>> // Configure Jenkins Slave Container
>> jenkins_slave_image = System.getenv('JENKINS_SLAVE_IMAGE').toString()
>> def jenkins_container = new ContainerTemplate('jenkins-slave', 
>> jenkins_slave_image)
>> jenkins_container.setTtyEnabled(true)
>> jenkins_container.setName('jeknins-slave')
>>
>> // Configure Jenkins Slave Pods
>> def jenkins_slave_pod = new PodTemplate()
>> jenkins_slave_pod.setNamespace('jenkins')
>> jenkins_slave_pod.setName('jenkins-slave')
>> jenkins_slave_pod.setContainers([jenkins_container])
>> jenkins_slave_pod.save()
>>
>> // Save Changes
>> kubernetes.addTemplate(jenkins_slave_pod)
>> jenkins_instance.clouds.removeAll(KubernetesCloud)
>> jenkins_instance.clouds.addAll(kubernetes)
>> jenkins_instance.save()
>>
>> Any thoughts on this?
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/85bd4d52-5083-4536-ae26-61370ac984a4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/85bd4d52-5083-4536-ae26-61370ac984a4%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3cbc1fcf-cb2c-4045-a7e0-2b7530f8c667%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to