Loading go2scale_devsecops.gitlab-ci.yml +89 −7 Original line number Diff line number Diff line Loading @@ -38,14 +38,96 @@ include: ref: master # TODO: set a tag here file: quality_check.gitlab-ci.yml unit_tests: image: python:3.7-alpine3.10 stage: test container_scanning: stage: review .helm: image: registry.gitlab.com/go2scale/dockerfiles/helm:v0.1.0 variables: CHART_PATH: "./charts/$CI_PROJECT_NAME" VALUES_PATH: "./conf/values" REGISTRY: "${CI_REGISTRY_IMAGE}/$CI_COMMIT_REF_SLUG" before_script: - apk add gcc make musl-dev postgresql-dev git linux-headers libmagic jpeg-dev zlib-dev - pip install pipenv && pipenv --bare install --dev - gpg --import "${PGP_PUBLIC}" && gpg --allow-secret-key-import --import "${PGP_PRIVATE}" - helm repo add stable https://kubernetes-charts.storage.googleapis.com/ - helm repo update script: - make test - helm secrets upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} -f ${VALUES_PATH}/${CI_ENVIRONMENT_NAME}.yaml -f ${VALUES_PATH}/secrets.${CI_ENVIRONMENT_NAME}.yaml --set-string image.tag=${CI_COMMIT_SHA},gitlab.env=${CI_ENVIRONMENT_SLUG},gitlab.app=${CI_PROJECT_PATH_SLUG} --namespace "$KUBE_NAMESPACE" --install container_scanning: deploy_review: extends: .helm stage: review script: - helm upgrade postgres stable/postgresql --namespace ${KUBE_NAMESPACE} --install --set persistence.enabled=false --set postgresqlPassword=${REVIEW_POSTGRES_PASSWORD} --set postgresqlDatabase=grid - helm secrets upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} --namespace "${KUBE_NAMESPACE}" --install -f ${VALUES_PATH}/review.yaml -f ${VALUES_PATH}/secrets.review.yaml --set-string image.registry=${REGISTRY},image.tag=${CI_COMMIT_SHA},ingress.hostPrefix="${CI_ENVIRONMENT_SLUG}.",environment.configmap.DATABASE_HOST=postgres-postgresql,environment.configmap.DATABASE_NAME=grid,environment.configmap.DATABASE_PASSWORD=${REVIEW_POSTGRES_PASSWORD},gitlab.env=${CI_ENVIRONMENT_SLUG},gitlab.app=${CI_PROJECT_PATH_SLUG} environment: name: review/$CI_COMMIT_REF_SLUG url: https://${CI_ENVIRONMENT_SLUG}.api.tictactoe.go2scale.tech/ # TODO: it's harcoded, not really good on_stop: cleanup_review except: refs: - master variables: - $REVIEW_DISABLE cleanup_review: extends: .helm stage: review variables: GIT_STRATEGY: none when: manual script: - helm delete -n $KUBE_NAMESPACE $CI_PROJECT_PATH_SLUG - helm delete -n $KUBE_NAMESPACE postgres # - kubectl delete namespace $KUBE_NAMESPACE # TODO: it's forbidden due tu user RBAC environment: name: review/$CI_COMMIT_REF_SLUG action: stop allow_failure: true except: refs: - master variables: - $REVIEW_DISABLE #test_stage: # extends: deploy_stage # stage: application_level # script: # - helm secrets diff upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} -f ${VALUES_PATH}/${ENV}.yaml -f ${VALUES_PATH}/secrets.${ENV}.yaml --set-string image.tag=${CI_COMMIT_SHORT_SHA} --namespace "$KUBE_NAMESPACE" --allow-unreleased deploy_stage: extends: .helm stage: staging environment: name: staging url: https://${CI_ENVIRONMENT_SLUG}.api.tictactoe.go2scale.tech/ # TODO: it's harcoded, not really good only: - master except: variables: - $STAGE_DISABLE #test_production: # extends: deploy_production # stage: application_level # script: # - helm secrets diff upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} -f ${VALUES_PATH}/${ENV}.yaml -f ${VALUES_PATH}/secrets.${ENV}.yaml --set-string image.tag=${CI_COMMIT_SHORT_SHA} --namespace "$KUBE_NAMESPACE" --allow-unreleased deploy_production: extends: .helm stage: production environment: name: production url: https://api.tictactoe.go2scale.tech/ # TODO: it's harcoded, not really good when: manual only: - master except: variables: - $PRODUCTION_DISABLE # NOTES # # Postgres deployment: # helm upgrade postgres stable/postgresql --namespace grid-api-8782888-staging --install --set persistence.enabled=false --set postgresqlPassword='PASSWORD' --set postgresqlDatabase=grid Loading
go2scale_devsecops.gitlab-ci.yml +89 −7 Original line number Diff line number Diff line Loading @@ -38,14 +38,96 @@ include: ref: master # TODO: set a tag here file: quality_check.gitlab-ci.yml unit_tests: image: python:3.7-alpine3.10 stage: test container_scanning: stage: review .helm: image: registry.gitlab.com/go2scale/dockerfiles/helm:v0.1.0 variables: CHART_PATH: "./charts/$CI_PROJECT_NAME" VALUES_PATH: "./conf/values" REGISTRY: "${CI_REGISTRY_IMAGE}/$CI_COMMIT_REF_SLUG" before_script: - apk add gcc make musl-dev postgresql-dev git linux-headers libmagic jpeg-dev zlib-dev - pip install pipenv && pipenv --bare install --dev - gpg --import "${PGP_PUBLIC}" && gpg --allow-secret-key-import --import "${PGP_PRIVATE}" - helm repo add stable https://kubernetes-charts.storage.googleapis.com/ - helm repo update script: - make test - helm secrets upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} -f ${VALUES_PATH}/${CI_ENVIRONMENT_NAME}.yaml -f ${VALUES_PATH}/secrets.${CI_ENVIRONMENT_NAME}.yaml --set-string image.tag=${CI_COMMIT_SHA},gitlab.env=${CI_ENVIRONMENT_SLUG},gitlab.app=${CI_PROJECT_PATH_SLUG} --namespace "$KUBE_NAMESPACE" --install container_scanning: deploy_review: extends: .helm stage: review script: - helm upgrade postgres stable/postgresql --namespace ${KUBE_NAMESPACE} --install --set persistence.enabled=false --set postgresqlPassword=${REVIEW_POSTGRES_PASSWORD} --set postgresqlDatabase=grid - helm secrets upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} --namespace "${KUBE_NAMESPACE}" --install -f ${VALUES_PATH}/review.yaml -f ${VALUES_PATH}/secrets.review.yaml --set-string image.registry=${REGISTRY},image.tag=${CI_COMMIT_SHA},ingress.hostPrefix="${CI_ENVIRONMENT_SLUG}.",environment.configmap.DATABASE_HOST=postgres-postgresql,environment.configmap.DATABASE_NAME=grid,environment.configmap.DATABASE_PASSWORD=${REVIEW_POSTGRES_PASSWORD},gitlab.env=${CI_ENVIRONMENT_SLUG},gitlab.app=${CI_PROJECT_PATH_SLUG} environment: name: review/$CI_COMMIT_REF_SLUG url: https://${CI_ENVIRONMENT_SLUG}.api.tictactoe.go2scale.tech/ # TODO: it's harcoded, not really good on_stop: cleanup_review except: refs: - master variables: - $REVIEW_DISABLE cleanup_review: extends: .helm stage: review variables: GIT_STRATEGY: none when: manual script: - helm delete -n $KUBE_NAMESPACE $CI_PROJECT_PATH_SLUG - helm delete -n $KUBE_NAMESPACE postgres # - kubectl delete namespace $KUBE_NAMESPACE # TODO: it's forbidden due tu user RBAC environment: name: review/$CI_COMMIT_REF_SLUG action: stop allow_failure: true except: refs: - master variables: - $REVIEW_DISABLE #test_stage: # extends: deploy_stage # stage: application_level # script: # - helm secrets diff upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} -f ${VALUES_PATH}/${ENV}.yaml -f ${VALUES_PATH}/secrets.${ENV}.yaml --set-string image.tag=${CI_COMMIT_SHORT_SHA} --namespace "$KUBE_NAMESPACE" --allow-unreleased deploy_stage: extends: .helm stage: staging environment: name: staging url: https://${CI_ENVIRONMENT_SLUG}.api.tictactoe.go2scale.tech/ # TODO: it's harcoded, not really good only: - master except: variables: - $STAGE_DISABLE #test_production: # extends: deploy_production # stage: application_level # script: # - helm secrets diff upgrade ${CI_PROJECT_PATH_SLUG} ${CHART_PATH} -f ${VALUES_PATH}/${ENV}.yaml -f ${VALUES_PATH}/secrets.${ENV}.yaml --set-string image.tag=${CI_COMMIT_SHORT_SHA} --namespace "$KUBE_NAMESPACE" --allow-unreleased deploy_production: extends: .helm stage: production environment: name: production url: https://api.tictactoe.go2scale.tech/ # TODO: it's harcoded, not really good when: manual only: - master except: variables: - $PRODUCTION_DISABLE # NOTES # # Postgres deployment: # helm upgrade postgres stable/postgresql --namespace grid-api-8782888-staging --install --set persistence.enabled=false --set postgresqlPassword='PASSWORD' --set postgresqlDatabase=grid