Skip to content

Instantly share code, notes, and snippets.

@ju5t
Last active August 31, 2019 10:57
Show Gist options
  • Save ju5t/e8a8bf5dd241ba824fbcfcde5dc6dc82 to your computer and use it in GitHub Desktop.
Save ju5t/e8a8bf5dd241ba824fbcfcde5dc6dc82 to your computer and use it in GitHub Desktop.
variables:
K8S_NAMESPACE: $CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG
stages:
- deploy
deploy-k8s:
image: dtzar/helm-kubectl
stage: deploy
before_script:
- apk add -u gettext
- curl -sL https://github.com/digitalocean/doctl/releases/download/v1.28.0/doctl-1.28.0-linux-amd64.tar.gz | tar -xzv
- mv doctl /usr/local/bin
- doctl auth init -t $DO_API_KEY
- doctl kubernetes cluster kubeconfig save $DO_CLUSTER
- kubectl create namespace $K8S_NAMESPACE --dry-run=true -o yaml | kubectl apply -f -
- kubectl config set-context --current --namespace=$K8S_NAMESPACE
- kubectl create secret docker-registry regcred --docker-server=$CI_REGISTRY --docker-username="$GITLAB_DEPLOY_USER" --docker-password="$GITLAB_DEPLOY_KEY" --docker-email=<YOUR-EMAIL> --dry-run=true -o yaml | kubectl apply -f -
environment:
name: test
url: test.yourapp.com
script:
- VERSION="${CI_COMMIT_TAG:-none}" envsubst < k8s.yml | kubectl apply -f -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment