Created
January 24, 2020 08:28
-
-
Save pepijnblom/96f61f4323a9d311c9e9933c49638bf9 to your computer and use it in GitHub Desktop.
magento2 kubernetes blog example gitlab-ci deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.deploy: | |
image: git.gracious.nl:4567/docker/kubectl | |
before_script: | |
- gcloud config set project $GC_PROJECT | |
- gcloud auth activate-service-account --key-file $SA_GOOGLE_KUBERNETES | |
- gcloud --quiet container clusters get-credentials $GKE_CLUSTER --zone=$GKE_ZONE | |
- kubectl config set-context --current --namespace=$GKE_NAMESPACE | |
- kubectl delete job magento-upgrade --ignore-not-found | |
script: | |
- kubectl set image deployment $DEPLOYMENT_MAGENTO magento=$GCR_ZONE/$GC_PROJECT/$CI_PROJECT_NAME:$CI_COMMIT_SHA | |
- kubectl set image cronjob $DEPLOYMENT_CRON magento-cron=$GCR_ZONE/$GC_PROJECT/$CI_PROJECT_NAME:$CI_COMMIT_SHA | |
- kubectl set image cronjob $DEPLOYMENT_REINDEX magento-reindex=$GCR_ZONE/$GC_PROJECT/$CI_PROJECT_NAME:$CI_COMMIT_SHA | |
- kubectl rollout status deployment/$DEPLOYMENT_MAGENTO | |
- kubectl set image cronjob magento-upgrade magento=$GCR_ZONE/$GC_PROJECT/$CI_PROJECT_NAME:$CI_COMMIT_SHA | |
- kubectl create job magento-upgrade --from=cronjob/magento-upgrade | |
- kubectl exec -i $(kubectl get pod --selector='app=redis,role=master'|tail -1|awk '{print $1}') redis-cli flushall | |
deploy:production: | |
stage: deploy | |
environment: | |
name: production | |
url: https://url.to/some/admin/section | |
variables: | |
GKE_NAMESPACE: production | |
DEPLOYMENT_MAGENTO: magento-backend-prod | |
DEPLOYMENT_CRON: magento-cron | |
DEPLOYMENT_REINDEX: magento-reindex | |
only: | |
- tags | |
after_script: | |
- | | |
curl $SENTRY_WEBHOOK_URL \ | |
-X POST \ | |
-H 'Content-Type: application/json' \ | |
-d '{"version": "$CI_COMMIT_TAG"}' | |
- | | |
curl -X POST 'https://api.newrelic.com/v2/applications/$NEWRELIC_APP_ID/deployments.json' \ | |
-H 'X-Api-Key:$NEWRELIC_APIKEY' -i \ | |
-H 'Content-Type: application/json' \ | |
-d '{ "deployment": { "revision": "$CI_COMMIT_TAG" } }' | |
extends: .deploy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment