From a015f8f9b1dfb998635380ff9ba7e465915c01c8 Mon Sep 17 00:00:00 2001 From: kandrusyak Date: Tue, 4 Jul 2023 00:37:35 +0300 Subject: [PATCH] add universal pipeline --- .gitlab-ci.yml | 97 +++++++++++++++---------------------- deploy/.env | 2 + deploy/values.template.yaml | 16 ++++++ 3 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 deploy/.env create mode 100644 deploy/values.template.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b9d303..bc9e39a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,57 +1,40 @@ -image: docker:20.10.16 - -variables: - # When using dind service, you must instruct Docker to talk with - # the daemon started inside of the service. The daemon is available - # with a network connection instead of the default - # /var/run/docker.sock socket. - DOCKER_HOST: tcp://docker:2376 - # - # The 'docker' hostname is the alias of the service container as described at - # https://docs.gitlab.com/ee/ci/services/#accessing-the-services. - # If you're using GitLab Runner 12.7 or earlier with the Kubernetes executor and Kubernetes 1.6 or earlier, - # the variable must be set to tcp://localhost:2376 because of how the - # Kubernetes executor connects services to the job container - # DOCKER_HOST: tcp://localhost:2376 - # - # Specify to Docker where to create the certificates. Docker - # creates them automatically on boot, and creates - # `/certs/client` to share between the service and job - # container, thanks to volume mount from config.toml - DOCKER_TLS_CERTDIR: "/certs" - # These are usually specified by the entrypoint, however the - # Kubernetes executor doesn't run entrypoints - # https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4125 - DOCKER_TLS_VERIFY: 1 - DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" - -services: - - docker:20.10.16-dind - -stages: - - build - - deploy - -build-job: - stage: build - tags: - - docker - only: - - master - script: - - docker info - - docker build -t docker-registry.dopcore.com/andrusyakka/astra-file-storage . - - echo "$DOCKER_PASSWORD" | docker login docker-registry.dopcore.com -u "$DOCKER_USER" --password-stdin - - docker push docker-registry.dopcore.com/andrusyakka/astra-file-storage - -deploy-job: - stage: deploy - image: dtzar/helm-kubectl:latest - tags: - - docker - only: - - master - script: - - kubectl version - - helm upgrade --install astra-file-storage deploy - - kubectl rollout restart deploy/astra-file-storage +image: docker:20.10.16 + +variables: + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + DOCKER_TLS_VERIFY: 1 + DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" + +services: + - docker:20.10.16-dind + +stages: + - build + - deploy + +build-job: + stage: build + tags: + - docker + only: + - master + script: + - docker info + - docker build -t docker-registry.dopcore.com/$CI_PROJECT_PATH . + - echo "$CI_REGISTRY_PASSWORD" | docker login docker-registry.dopcore.com -u "$CI_REGISTRY_USER" --password-stdin + - docker push docker-registry.dopcore.com/$CI_PROJECT_PATH + +deploy-job: + stage: deploy + image: dtzar/helm-kubectl:latest + tags: + - docker + only: + - master + script: + - export $(xargs < deploy/.env) + - envsubst < deploy/values.template.yaml > deploy/values.yaml + - kubectl version + - helm upgrade --install $CI_PROJECT_TITLE deploy + - kubectl rollout restart deploy/$CI_PROJECT_TITLE diff --git a/deploy/.env b/deploy/.env new file mode 100644 index 0000000..2f9f9ec --- /dev/null +++ b/deploy/.env @@ -0,0 +1,2 @@ +SERVICE_REPLICAS=3 +SERVICE_PORT=8080 \ No newline at end of file diff --git a/deploy/values.template.yaml b/deploy/values.template.yaml new file mode 100644 index 0000000..6d3674f --- /dev/null +++ b/deploy/values.template.yaml @@ -0,0 +1,16 @@ +app: + fullName: ${CI_PROJECT_TITLE} + image: docker-registry.dopcore.com/${CI_PROJECT_PATH} + server: + port: ${SERVICE_PORT} + +replicas: ${SERVICE_REPLICAS} + +images: + pullSecret: regcred + +ingress: + enabled: false + +autoscaling: + enabled: false \ No newline at end of file