davidcurrie / index2018

Jenkins/Kube/Helm demo for Index 2018
18 stars 57 forks source link

Timeout Problem #3

Open hitesh1907nayyar opened 5 years ago

hitesh1907nayyar commented 5 years ago

Hi David,

I was running the script beforehand it was working. Now it is giving me timeout when last helm command is executed.

podTemplate(

label: 'mypod', 

inheritFrom: 'default',

containers: [

    containerTemplate(

        name: 'golang', 

        image: 'golang:1.10-alpine',

        ttyEnabled: true,

        command: 'cat'

    ),

    containerTemplate(

        name: 'docker', 

        image: 'docker:18.02',

        ttyEnabled: true,

        command: 'cat'

    ),

    containerTemplate(

        name: 'helm', 

        image: 'ibmcom/k8s-helm:v2.6.0',

        ttyEnabled: true,

        command: 'cat'

    )

],

volumes: [

    hostPathVolume(

        hostPath: '/var/run/docker.sock',

        mountPath: '/var/run/docker.sock'

    )

]

) {

node('mypod') {

    def commitId

    stage ('Extract') {

        checkout scm

        commitId = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()

    }

    stage ('Build') {

        container ('golang') {

            sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .'

            sh 'ls -ltr'

        }

    }

    def repository

    stage ('Docker') {

        container ('docker') {

            withCredentials([[$class: 'UsernamePasswordMultiBinding',

                    credentialsId: '123456',

                    usernameVariable: 'DOCKER_HUB_USER',

                    passwordVariable: 'DOCKER_HUB_PASSWORD']]) {

                sh "docker build -t ${env.DOCKER_HUB_USER}/demo:${env.BUILD_NUMBER} ."

                sh "docker login -u ${env.DOCKER_HUB_USER} -p ${env.DOCKER_HUB_PASSWORD} "

                sh "docker push ${env.DOCKER_HUB_USER}/demo:${env.BUILD_NUMBER} "

            }

        }

    }

    stage ('Deploy') {

        container ('helm') {

            withCredentials([[$class: 'UsernamePasswordMultiBinding',

                    credentialsId: '123456',

                    usernameVariable: 'DOCKER_HUB_USER',

                    passwordVariable: 'DOCKER_HUB_PASSWORD']]){ 

                sh "/helm init --client-only --skip-refresh"

                sh "/helm upgrade --install --wait --set image.repository=${env.DOCKER_HUB_USER}/demo,image.tag=${env.BUILD_NUMBER} demo hello"

            }

        }

    }

}

}

Logs of Jenkins:

hitesh1907nayyar commented 5 years ago

Can you please help as I am getting confused since I did not made any changes in the script

davidcurrie commented 5 years ago

Generally, it means a pod created by the chart didn't reach ready state in the timeout period (5 mins). This could be something as simple as it taking a long time to download a big image or, more often than not, that it failed to pull the image for some reason. Run a kubectl describe on the pod and take a look at the events.