'Docker build pipeline fails after a Kuernetes/Docker configuration is added to the 'Configure Cloud' section

I have a weird issue here. I was able to successfully execute the below pipeline.

pipeline {
  agent any
  
  environment {
        DOCKERHUB_CREDENTIALS = credentials('DOCKERHUB_LOGIN')
  }
  
  tools {nodejs "nodejs"}

  parameters {
    gitParameter branchFilter: 'origin/(.*)', defaultValue: 'main', name: 'BRANCH', type: 'PT_BRANCH'
  }
  
  stages {
    stage('Clone Code Repository') {
      steps {
        git branch: "${params.BRANCH}", url: 'https://github.com/dkelim1/nodejs-app.git'
      }
    }
    
    stage('Install NPM application') {
      steps {
        sh 'npm install'
      }
    }
    
    
    stage('Download docker binary') {
        steps{
            script {
                    def dockerHome = tool 'docker'
                    env.PATH = "${dockerHome}/bin:${env.PATH}"           
            }
        }
    }    
    

    stage('Docker Build and Tag') {
        steps {
            script {
                docker.withServer('tcp://192.168.59.102:2376', 'DOCKERHOST_CRED'){
                sh 'docker build -t dkelim1/nodejs-app .' 
                }
            }
        }
    }
    
    stage('DockerHub Login') {
        steps {
            script {
                docker.withServer('tcp://192.168.59.102:2376', 'DOCKERHOST_CRED'){
                sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'     
                }
            }    
        }
    }

    stage('Push Image to DockerHub') {
        steps {
            script {
                docker.withServer('tcp://192.168.59.102:2376', 'DOCKERHOST_CRED'){
                sh 'docker push dkelim1/nodejs-app:latest' 
                }
            }    
        }
    }


    stage('Logout from DockerHub') {
        steps {
            script {
                docker.withServer('tcp://192.168.59.102:2376', 'DOCKERHOST_CRED'){
                sh 'docker logout' 
                }
            }    
        }
    }
    
/*    stage('Publish image to Docker Hub') {
        steps {

                    withDockerRegistry([ credentialsId: "DOCKERHUB_LOGIN", url: "" ]) {
                    sh  'docker push dkelim1/nodejs-app:latest'
                    }
 
        }
    }*/
  }    
}

However, after I go to Manage Jenkins -> Manage Nodes and Clouds and create a new Kubernetes Cloud (see screenshot), the build for the above pipeline stopped working.
After I re-triggered the pipeline, the Console Output just shows the below messages.

Still waiting to schedule task Waiting for next available executor

After waiting for a few minutes, there is still no progress.

When I do a ‘kubectl get pod -A’, I see that the agent pod gets created but ends up in ‘Error’ state and gets Terminated.

[jenkins                default-kqwlm                               0/1     Error               0              2s
jenkins                default-kqwlm                               0/1     Terminating         0              2s
jenkins                default-kqwlm                               0/1     Terminating         0              2s
jenkins                default-lkp86                               0/1     Pending             0              0s
jenkins                default-lkp86                               0/1     Pending             0              0s
jenkins                default-lkp86                               0/1     ContainerCreating   0              0s
jenkins                default-lkp86                               0/1     Error               0              2s
jenkins                default-lkp86                               0/1     Terminating         0              2s
jenkins                default-lkp86                               0/1     Terminating         0              2s
jenkins                default-svwt3                               0/1     Pending             0              0s
jenkins                default-svwt3                               0/1     Pending             0              0s
jenkins                default-svwt3                               0/1     ContainerCreating   0              0s
jenkins                default-svwt3                               0/1     Error               0              2s
jenkins                default-svwt3                               0/1     Terminating         0              2s
jenkins                default-svwt3                               0/1     Terminating         0              2s
jenkins                default-db2k9                               0/1     Pending             0              0s
jenkins                default-db2k9                               0/1     Pending             0              0s
jenkins                default-db2k9                               0/1     ContainerCreating   0              0s
jenkins                default-db2k9                               0/1     Error               0              2s
jenkins                default-db2k9                               0/1     Terminating         0              2s
jenkins                default-db2k9                               0/1     Terminating         0              2s
jenkins                default-29d69                               0/1     Pending             0              0s
jenkins                default-29d69                               0/1     Pending             0              0s
jenkins                default-29d69                               0/1     ContainerCreating   0              0s
jenkins                default-29d69                               0/1     Error               0              2s
jenkins                default-29d69                               0/1     Terminating         0              2s
jenkins                default-29d69                               0/1     Terminating         0              2s
jenkins                default-d9rs1                               0/1     Pending             0              0s
jenkins                default-d9rs1                               0/1     Pending             0              0s
jenkins                default-d9rs1                               0/1     ContainerCreating   0              0s
jenkins                default-d9rs1                               0/1     Error               0              2s
jenkins                default-d9rs1                               0/1     Terminating         0              2s
jenkins                default-d9rs1                               0/1     Terminating         0              2s
jenkins                default-rnxtn                               0/1     Pending             0              0s
jenkins                default-rnxtn                               0/1     Pending             0              0s
jenkins                default-rnxtn                               0/1     ContainerCreating   0              0s
jenkins                default-rnxtn                               0/1     Error               0              2s
jenkins                default-rnxtn                               0/1     Terminating         0              2s
jenkins                default-rnxtn                               0/1     Terminating         0              2s][1]

The only way for the above pipeline to work again is to restart the Minikube cluster(minikube stop, then minikube start).

When I go back to the cloud section to check, I see that there is only one default cloud ‘Kubernetes’ (state before I add a second Kubernetes cloud) there. After I trigger the pipeline again, the build is able to complete successfully.

Am I doing anything wrong here or is this a bug?

Thanks.

[ Additional cloud configuration for Kubernetes ] [1]: https://i.stack.imgur.com/7Ek4f.jpg

[Pipeline is running for a very long time without any progress ] [2]: https://i.stack.imgur.com/wFot1.jpg

[Agent pod started with Error and gets terminated] [3]: https://i.stack.imgur.com/5XEn6.jpg



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source