0

I'm trying to deploy my buffalo golang app to Kubernetes over Jenkins.

When I deploy the app it passes all phase but the pod isn't ready.

I get the following error when I describe the pod:

Readiness probe failed: Get http://10.8.0.36:80/: dial tcp 10.8.0.36:80: getsockopt: connection refused

The docker file I use looks like this:

 # This is a multi-stage Dockerfile and requires >= Docker 17.05
    FROM gobuffalo/buffalo:v0.13.12 as builder

    RUN mkdir -p $GOPATH/src/github.com/swapper_ai
    WORKDIR $GOPATH/src/github.com/swapper_ai

    ADD . .
    RUN go get $(go list ./... | grep -v /vendor/)
    RUN buffalo build --static -o /bin/app

    FROM alpine
    RUN apk add --no-cache bash
    RUN apk add --no-cache ca-certificates

    WORKDIR /bin/

    COPY --from=builder /bin/app .

    # Uncomment to run the binary in "production" mode:
    ENV GO_ENV=production

    EXPOSE 80

    # Uncomment to run the migrations before running the binary:
    # CMD /bin/app migrate; /bin/app
    CMD /bin/app

Here is the Jenkins file in case it helps:

    def project = 'summer--'
    def  appName = 'swapper-ai'
    def  imageTag = "gcr.io/${project}/${appName}.${env.BUILD_NUMBER}"
    def  feSvcName = "swapper-ai-backend-service"

    pipeline {
      agent {
        kubernetes {
          label 'swapper-ai-label'
          defaultContainer 'jnlp'
          yamlFile 'k8s/pod/pod.yaml'
      }
      }
      stages {
        // Deploy Image and push with image container builder
        stage('Build and push image with Container Builder') {
          when { branch 'master' }
          steps {
            container('gcloud') {
              sh "PYTHONUNBUFFERED=1 gcloud builds submit -t ${imageTag} ."
            }
          }
        }
        // Deploy to production
        stage('Deploy Production') {
          when { branch 'master' }
          // Production branch
          steps{
            container('kubectl') {
            // Change deployed image in canary to the one we just built
              sh("sed -i.bak 's#gcr.io/cloud-solutions-images/swapper-ai-backend:1.0.0#${imageTag}#' ./k8s/production/*.yaml")
              sh("kubectl apply -f k8s/services/")
              sh("kubectl apply -f k8s/production/")
              sh("kubectl apply -f k8s/ingress/");
            }
          }
        }
      }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.