Configuration-as-code-plugin: Configuring cloud results in a duplicate

Created on 15 Sep 2020  路  7Comments  路  Source: jenkinsci/configuration-as-code-plugin

Your checklist for this issue

馃毃 Please review the guidelines for contributing to this repository.

  • [x] Jenkins version - 2.255

  • [x] Plugin version - 1.43

  • [x] OS - linux docker image

Description

Using the following configuration:

      cloud: |
        jenkins:
          clouds:
          - kubernetes:
              containerCap: 2
              containerCapStr: "2"
              jenkinsTunnel: "jenkins-agent:50000"
              jenkinsUrl: "http://jenkins:8080"
              name: "kubernetes"
              namespace: "prod-app-001-jenkins"
              serverUrl: "https://kubernetes.default"
              templates:
              - containers:
                - args: "^${computer.jnlpmac} ^${computer.name}"
                  command: "/bin/sh -c"
                  envVars:
                  - containerEnvVar:
                      key: "JENKINS_URL"
                      value: "http://jenkins.default.svc.cluster.local:8080"
                  image: "jenkins/jnlp-slave:3.27-1"
                  livenessProbe:
                    failureThreshold: 0
                    initialDelaySeconds: 0
                    periodSeconds: 0
                    successThreshold: 0
                    timeoutSeconds: 0
                  name: "jnlp"
                  resourceLimitCpu: "2"
                  resourceLimitMemory: "2Gi"
                  resourceRequestCpu: "500m"
                  resourceRequestMemory: "256Mi"
                  workingDir: "/home/jenkins"
                label: "cd-jenkins-slave "
                name: "default"
                nodeUsageMode: "NORMAL"
                serviceAccount: "default"
                yamlMergeStrategy: "override"

Results in two clouds configurations named "kubernetes" instead of altering the existing one:

clouds:
  - kubernetes:
      containerCap: 2
      containerCapStr: "2"
      jenkinsTunnel: "jenkins-agent:50000"
      jenkinsUrl: "http://jenkins:8080"
      name: "kubernetes"
      namespace: "prod-app-001-jenkins"
      serverUrl: "https://kubernetes.default"
      templates:
      - containers:
        - args: "^${computer.jnlpmac} ^${computer.name}"
          command: "/bin/sh -c"
          envVars:
          - containerEnvVar:
              key: "JENKINS_URL"
              value: "http://jenkins.default.svc.cluster.local:8080"
          image: "jenkins/jnlp-slave:3.27-1"
          livenessProbe:
            failureThreshold: 0
            initialDelaySeconds: 0
            periodSeconds: 0
            successThreshold: 0
            timeoutSeconds: 0
          name: "jnlp"
          resourceLimitCpu: "2"
          resourceLimitMemory: "2Gi"
          resourceRequestCpu: "500m"
          resourceRequestMemory: "256Mi"
          workingDir: "/home/jenkins"
        label: "cd-jenkins-slave "
        name: "default"
        nodeUsageMode: "NORMAL"
        serviceAccount: "default"
        yamlMergeStrategy: "override"
  - kubernetes:
      containerCap: 10
      containerCapStr: "10"
      jenkinsTunnel: "jenkins-agent:50000"
      jenkinsUrl: "http://jenkins:8080"
      name: "kubernetes"
      namespace: "prod-app-001-jenkins"
      podLabels:
      - key: "jenkins/jenkins-jenkins-slave"
        value: "true"
      serverUrl: "https://kubernetes.default"
      templates:
      - containers:
        - args: "^${computer.jnlpmac} ^${computer.name}"
          envVars:
          - envVar:
              key: "JENKINS_URL"
              value: "http://jenkins.prod-app-001-jenkins.svc.cluster.local:8080"
          image: "jenkins/inbound-agent:4.3-4"
          name: "jnlp"
          resourceLimitCpu: "1"
          resourceLimitMemory: "512Mi"
          resourceRequestCpu: "500m"
          resourceRequestMemory: "256Mi"
          workingDir: "/home/jenkins"
        label: "jenkins-jenkins-slave "
        name: "default"
        nodeUsageMode: "NORMAL"
        podRetention: "never"
        serviceAccount: "default"
        yamlMergeStrategy: "override"

I'm not sure if this is a JCasC issue or kubernetes issue. I believe (not too sure) that a few months ago on older jenkins and plugin versions this did not occur.

bug

All 7 comments

Sounds like a plugin issue and not a jcasc issue.

Okay, reported here.

Seeing the same issue

Seeing the same issue

Might be best to vote on the jenkins issue then.

Thanks

This turned out to be a Helm issue in our case. I fixed it by adding the following to our values.yaml:

JCasC:
defaultConfig: false

Without this it defaults to 'true' and creates the duplicate config. The default used to be 'false' in chart versions prior to 2.0.0.

This turned out to be a Helm issue in our case. I fixed it by adding the following to our values.yaml:

JCasC:
defaultConfig: false

Without this it defaults to 'true' and creates the duplicate config. The default used to be 'false' in chart versions prior to 2.0.0.

Oh interesting, I will look at that. Thank you!

That was it, thanks @doncraig!

Was this page helpful?
0 / 5 - 0 ratings