Skip to content

Instantly share code, notes, and snippets.

@dfang
Forked from tvvignesh/.gitlab-ci.yml
Created November 2, 2020 04:10
Show Gist options
  • Save dfang/4c002947ffeb546997cc029ecdf2d500 to your computer and use it in GitHub Desktop.
Save dfang/4c002947ffeb546997cc029ecdf2d500 to your computer and use it in GitHub Desktop.
Example on running Skaffold with GITLAB CI for Kubernetes in GKE (Make sure you modify it appropriately and set GCP_SERVICE_KEY and GCP_PROD_SERVICE_KEY variable in Gitlab with the service account json value)
services:
- docker:dind
stages:
- development
- production
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
DOCKER_HOST: tcp://docker:2375
development:
image:
name: gcr.io/k8s-skaffold/skaffold:latest
stage: development
script:
- echo "$GCP_SERVICE_KEY" > gcloud-service-key.json
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- gcloud config set project project-dev
- gcloud config set compute/zone asia-south1-a
- gcloud container clusters get-credentials cluster-dev
- kubectl config get-contexts
- skaffold run
only:
- master
production:
image:
name: gcr.io/k8s-skaffold/skaffold:latest
stage: production
script:
- echo "$GCP_PROD_SERVICE_KEY" > gcloud-service-key.json
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- gcloud config set project project-prod
- gcloud config set compute/zone asia-south1-a
- gcloud container clusters get-credentials cluster-prod
- kubectl config get-contexts
- skaffold run -p production
only:
- production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment