Skip to content

Commit

Permalink
Merge pull request #3 from jobtome-labs/master
Browse files Browse the repository at this point in the history
porting from fork
  • Loading branch information
gadiener authored May 15, 2020
2 parents 3649f25 + f27e508 commit 218bd0a
Show file tree
Hide file tree
Showing 24 changed files with 453 additions and 81 deletions.
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ With Kubernetes:

With Helm:

`lint -> build -> test -> push -> deploy -> notify`
`lint -> build -> test -> push -> deploy -> verify -> rollback -> notify`

Rollback is not necessary thanks to Helm's atomic operations (if the installing fails, Helm cleans up by itself)

Our workflow:
- A commit on master goes to quality
Expand Down Expand Up @@ -181,6 +180,22 @@ See [here](https://github.com/zegl/kube-score/blob/master/README_CHECKS.md) for

NB: The test `label_values` needs to be skipped because of the values `${CI_COMMIT_TAG}` (which will be replaced by `envsubst` later in the pipeline) causing validation fail.

### Linting shell files

```yaml
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/<REF>/lint-shell.yml'
stages:
- lint
variables:
# optional, used to enable reviewdog
ENABLE_REVIEWDOG: 1
REVIEWDOG_GITLAB_API_TOKEN: <personal gitlab token used to call v4 api endpoints>
REVIEWDOG_LEVEL: warning # optional, values: info, warning, error
```

# Unit test stage

```yaml
Expand Down Expand Up @@ -215,6 +230,10 @@ variables:
SKIP_DOCKER_CACHE: "false"
```

All stages in Docker file should be named (e.g. `AS buildes`, `AS prod`...). These need to be added to `STAGES` variable. `IMAGES` variable defines the images that will be built, just delete the variable if a single image will be created. In this case the image will be named as `CI_REGISTRY_IMAGE`, othewise `CI_REGISTRY_IMAGE` will be a folder containing `IMAGES`.
`DOCKERFILES_DIR` is used to specify a different folder containing Dockerfiles instead of the default root directory.


## Kubernetes quality pipeline

```yaml
Expand Down Expand Up @@ -458,6 +477,8 @@ stages:
- build
- push
- deploy
- verify
- rollback

variables:
IMAGES: "app nginx"
Expand Down Expand Up @@ -780,9 +801,15 @@ include:
stages:
- notify
variables:
SENTRY_AUTH_TOKEN: my-sentry-user-token
SENTRY_URL: my-sentry.example.net
SENTRY_PROJECT: my-sentry-project
SENTRY_ORG: my-sentry-org
```

This stage makes an API call to the project-specific sentry webhook, in order to announce a new release [as per the docs](https://docs.sentry.io/workflow/releases/?platform=javascript#using-the-api).
This stage uses `getsentry/sentry-cli:1.52.3`, in order to announce a new release [as per the docs](https://docs.sentry.io/workflow/releases/?platform=javascript#using-the-cli).

# General advices

Expand Down
2 changes: 1 addition & 1 deletion bucket-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/bucket-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/bucket-quality.yml'

deploy:production:
extends: .deploy
Expand Down
2 changes: 1 addition & 1 deletion bucket-quality.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/templates/bucket.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/templates/bucket.yml'

deploy:quality:
extends: .deploy
Expand Down
2 changes: 1 addition & 1 deletion cloudrun-production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/cloudrun-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/cloudrun-quality.yml'

deploy:production:
extends: deploy:quality
Expand Down
4 changes: 2 additions & 2 deletions cloudrun-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/templates/cloudrun.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/templates/cloudrun.yml'

deploy:quality:
extends: .cloudrun:deploy
Expand Down
2 changes: 1 addition & 1 deletion docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/templates/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/templates/docker.yml'

build:
stage: build
Expand Down
137 changes: 136 additions & 1 deletion helm-multiregion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/helm-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/helm-quality.yml'

# EUROPE
deploy:production:europe:helm:
Expand All @@ -24,6 +24,51 @@ deploy:production:europe:helm:
fi
done
verify:production:europe:
extends: .verify
stage: verify
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION_EUROPE}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION_EUROPE}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION_EUROPE}
NAMESPACE: ${NAMESPACE_PRODUCTION_EUROPE}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION_EUROPE" "CLUSTER_NAME_PRODUCTION_EUROPE" "CLUSTER_ZONE_PRODUCTION_EUROPE" "NAMESPACE_PRODUCTION_EUROPE"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
only:
- /^v.+$/i
except:
- branches

rollback:production:europe:
extends: .rollback
stage: rollback
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION_EUROPE}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION_EUROPE}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION_EUROPE}
NAMESPACE: ${NAMESPACE_PRODUCTION_EUROPE}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION_EUROPE" "CLUSTER_NAME_PRODUCTION_EUROPE" "CLUSTER_ZONE_PRODUCTION_EUROPE" "NAMESPACE_PRODUCTION_EUROPE"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
when: on_failure
only:
- /^v.+$/i
except:
- branches

# AMERICA
deploy:production:america:helm:
extends: .deploy:production:helm
Expand All @@ -47,6 +92,51 @@ deploy:production:america:helm:
fi
done
verify:production:america:
extends: .verify
stage: verify
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION_AMERICA}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION_AMERICA}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION_AMERICA}
NAMESPACE: ${NAMESPACE_PRODUCTION_AMERICA}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION_AMERICA" "CLUSTER_NAME_PRODUCTION_AMERICA" "CLUSTER_ZONE_PRODUCTION_AMERICA" "NAMESPACE_PRODUCTION_AMERICA"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
only:
- /^v.+$/i
except:
- branches

rollback:production:america:
extends: .rollback
stage: rollback
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION_AMERICA}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION_AMERICA}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION_AMERICA}
NAMESPACE: ${NAMESPACE_PRODUCTION_AMERICA}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION_AMERICA" "CLUSTER_NAME_PRODUCTION_AMERICA" "CLUSTER_ZONE_PRODUCTION_AMERICA" "NAMESPACE_PRODUCTION_AMERICA"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
when: on_failure
only:
- /^v.+$/i
except:
- branches

# ASIA
deploy:production:asia:helm:
extends: .deploy:production:helm
Expand All @@ -69,3 +159,48 @@ deploy:production:asia:helm:
exit 1
fi
done
verify:production:asia:
extends: .verify
stage: verify
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION_ASIA}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION_ASIA}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION_ASIA}
NAMESPACE: ${NAMESPACE_PRODUCTION_ASIA}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION_ASIA" "CLUSTER_NAME_PRODUCTION_ASIA" "CLUSTER_ZONE_PRODUCTION_ASIA" "NAMESPACE_PRODUCTION_ASIA"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
only:
- /^v.+$/i
except:
- branches

rollback:production:asia:
extends: .rollback
stage: rollback
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION_ASIA}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION_ASIA}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION_ASIA}
NAMESPACE: ${NAMESPACE_PRODUCTION_ASIA}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION_ASIA" "CLUSTER_NAME_PRODUCTION_ASIA" "CLUSTER_ZONE_PRODUCTION_ASIA" "NAMESPACE_PRODUCTION_ASIA"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
when: on_failure
only:
- /^v.+$/i
except:
- branches
49 changes: 46 additions & 3 deletions helm-quality.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/templates/helm.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/docker.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/templates/helm.yml'

deploy:quality:helm:
variables:
Expand All @@ -16,9 +16,52 @@ deploy:quality:helm:
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_QUALITY" "CLUSTER_NAME_QUALITY" "CLUSTER_ZONE_QUALITY"; do
for var in "GOOGLE_KEY_QUALITY" "CLUSTER_NAME_QUALITY" "CLUSTER_ZONE_QUALITY" "NAMESPACE_QUALITY" "DOMAIN_QUALITY"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
only:
- master

verify:quality:
extends: .verify
stage: verify
variables:
GOOGLE_KEY: ${GOOGLE_KEY_QUALITY}
CLUSTER_NAME: ${CLUSTER_NAME_QUALITY}
CLUSTER_ZONE: ${CLUSTER_ZONE_QUALITY}
NAMESPACE: ${NAMESPACE_QUALITY}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_QUALITY" "CLUSTER_NAME_QUALITY" "CLUSTER_ZONE_QUALITY" "NAMESPACE_QUALITY"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
only:
- master

rollback:quality:
extends: .rollback
stage: rollback
variables:
GOOGLE_KEY: ${GOOGLE_KEY_QUALITY}
CLUSTER_NAME: ${CLUSTER_NAME_QUALITY}
CLUSTER_ZONE: ${CLUSTER_ZONE_QUALITY}
NAMESPACE: ${NAMESPACE_QUALITY}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_QUALITY" "CLUSTER_NAME_QUALITY" "CLUSTER_ZONE_QUALITY" "NAMESPACE_QUALITY"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
when: on_failure
only:
- master
49 changes: 47 additions & 2 deletions helm-regional.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include:
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.8.0/helm-quality.yml'
- remote: 'https://raw.githubusercontent.com/jobtome-labs/ci-templates/v2.12.0/helm-quality.yml'

deploy:production:helm:
extends: .deploy:production:helm
Expand All @@ -15,9 +15,54 @@ deploy:production:helm:
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION" "CLUSTER_NAME_PRODUCTION" "CLUSTER_ZONE_PRODUCTION"; do
for var in "GOOGLE_KEY_PRODUCTION" "CLUSTER_NAME_PRODUCTION" "CLUSTER_ZONE_PRODUCTION" "NAMESPACE_PRODUCTION" "DOMAIN_PRODUCTION"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
verify:production:
extends: .verify
stage: verify
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION}
NAMESPACE: ${NAMESPACE_PRODUCTION}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION" "CLUSTER_NAME_PRODUCTION" "CLUSTER_ZONE_PRODUCTION" "NAMESPACE_PRODUCTION"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
only:
- /^v.+$/i
except:
- branches

rollback:production:
extends: .rollback
stage: rollback
variables:
GOOGLE_KEY: ${GOOGLE_KEY_PRODUCTION}
CLUSTER_NAME: ${CLUSTER_NAME_PRODUCTION}
CLUSTER_ZONE: ${CLUSTER_ZONE_PRODUCTION}
NAMESPACE: ${NAMESPACE_PRODUCTION}
before_script:
- |
# CHECK VARIABLES PHASE
for var in "GOOGLE_KEY_PRODUCTION" "CLUSTER_NAME_PRODUCTION" "CLUSTER_ZONE_PRODUCTION" "NAMESPACE_PRODUCTION"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
when: on_failure
only:
- /^v.+$/i
except:
- branches
Loading

0 comments on commit 218bd0a

Please sign in to comment.