3

I have setup a CI/CD pipeline which triggers builds, packages, and deploys tasks that execute on Gitlab online whenever a Spring boot RESTful service app is checked in. The three stages and tasks run successfully but whenever I test the app by navigating to the load balancer URL in a browser, I discover that one load balancer target returns (type=Not Found, status=404) error, while the other target returns the JSON response that is expected. The load balancer defaults to a round-robin algorithm in the distribution of requests to targets.

The infrastructure provider is Digital Ocean.

What am I doing wrong?

Kindly find below the .gitlab-ci.yml file

image: docker:latest
services:
  - docker:dind

variables:
  DOCKER_DRIVER: overlay
  SPRING_PROFILES_ACTIVE: gitlab-ci

stages:
  - build
  - package
  - deploy

maven-build:
  image: maven:3-jdk-8
  stage: build
  script: "mvn package -B"
  artifacts:
    paths:
      - target/*.jar

docker-build:
  stage: package
  script:
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  - docker build -t registry.gitlab.com/username/mta-hosting-optimizer .
  - docker push registry.gitlab.com/username/mta-hosting-optimizer

digitalocean-deploy:
  image: cdrx/rancher-gitlab-deploy
  stage: deploy
  script:
  - upgrade --environment Default --stack mta-hosting-optimizer --service web --new-image registry.gitlab.com/username/mta-hosting-optimizer
  - upgrade --environment Default --stack mta-hosting-optimizer --service web2 --new-image registry.gitlab.com/username/mta-hosting-optimizer

docker-compose.yml

version: '2'
services:
  web:
    image: registry.gitlab.com/username/mta-hosting-optimizer:latest
    ports:
    - 8082:8080/tcp
  mta-hosting-optimizer-lb:
    image: rancher/lb-service-haproxy:v0.9.1
    ports:
    - 80:80/tcp
    labels:
      io.rancher.container.agent.role: environmentAdmin,agent
      io.rancher.container.agent_service.drain_provider: 'true'
      io.rancher.container.create_agent: 'true'
  web2:
    image: registry.gitlab.com/username/mta-hosting-optimizer:latest
    ports:
    - 8082:8080/tcp

rancher-compose.yml

version: '2'
services:
  web:
    scale: 1
    start_on_create: true
  mta-hosting-optimizer-lb:
    scale: 1
    start_on_create: true
    lb_config:
      certs: []
      port_rules:
      - path: ''
        priority: 1
        protocol: http
        service: web
        source_port: 80
        target_port: 8080
      - priority: 2
        protocol: http
        service: web2
        source_port: 80
        target_port: 8080
    health_check:
      response_timeout: 2000
      healthy_threshold: 2
      port: 42
      unhealthy_threshold: 3
      initializing_timeout: 60000
      interval: 2000
      reinitializing_timeout: 60000
  web2:
    scale: 1
    start_on_create: true

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.