How does the Jenkins Kubernetes plugin provision agents?

AdvancedConceptJenkins
Answer

When a build needs an agent matching a pod template, the plugin calls the Kubernetes API to create a pod. The pod contains a jnlp container (the inbound agent that connects back to the controller) plus any extra containers you define (maven, docker/kaniko, kubectl). Steps run in a chosen container using container('name') { ... }, sharing the workspace volume. When the build finishes, the pod is deleted.

agent {
  kubernetes {
    yaml '''
    spec:
      containers:
      - name: maven
        image: maven:3.9-eclipse-temurin-21
        command: [sleep]
        args: [infinity]
    '''
  }
}
// steps { container('maven') { sh 'mvn -B verify' } }
All CI/CD questions

More on Jenkins