2

we are currently trying to get our Jenkins to deploy agents in another Kubernetes Cluster (provided via GKE).

We have added the new cluster under /configureClouds and are referencing it in the pipeline script via cloud: 'devkube'

Cloud Configuration

Basic Jenkinsfile:

pipeline {

  agent none

  stages {
    stage('Start manangement container') {
      agent {
        kubernetes {
          cloud 'devkube'
          defaultContainer 'management'
          yaml '''
            apiVersion: v1
            kind: Pod
            spec:
              containers:
              - name: management
                image: eu.gcr.io/dev/management:latest
                command:
                - cat
                tty: true
            '''
        }
      }

      steps {
        sleep 300
      }
    }
  }
}

Problem is that, Jenkins does not deploy the agent to that cloud, but to our first Kubernetes cluster, that has the default name kubernetes.

We have already verified, that the name provided via cloud: ... is checked against the configured clouds; a mismatch results in an immediate error.

Executing "Test Connection" under /configureClouds reports success, but value is limited as it only reports the Cluster version.

Build output recognizes the configured cloud: Created Pod: devkube default/tools-01-test-pipelines-test-9-3xd3b-17c8j-6q6xj, but the pod will be deployed to kubernetes anyhow.

Are we missing anything obvious, or is there a known bug?

Used versions:

  • Jenkins: 2.263.1
  • Kubernetes Plugin: 1.28.5
gunzl1ng3r
  • 21
  • 2

1 Answers1

0

I had a look at the image 'Cloud Configuration', are you sure 'Kubernetes Namespace' should be set to 'default'?

The way we have configured is that the 'Kubernetes Namespace' must have the name of the actual k8s namespace(in our case, an OpenShift project):

Use k8s ns name

Kaliyug Antagonist
  • 3,512
  • 9
  • 51
  • 103