-
-
Save kvaps/ebfd82c2f5b6894e3cf8a89698b063a2 to your computer and use it in GitHub Desktop.
using service account
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
stages: | |
- deploy | |
deploy_app: | |
image: bitnami/kubectl:latest | |
stage: deploy | |
environment: production | |
script: | |
- USER_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) | |
- CERTIFICATE_AUTHORITY_DATA=$(cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt | base64 -i -w0 -) | |
- kubectl config set-cluster k8s --server="https://kubernetes.default.svc" | |
- kubectl config set clusters.k8s.certificate-authority-data ${CERTIFICATE_AUTHORITY_DATA} | |
- kubectl config set-credentials gitlab --token="${USER_TOKEN}" | |
- kubectl config set-context default --cluster=k8s --user=gitlab | |
- kubectl config use-context default | |
- kubectl set image deployment my-app web=${CI_REGISTRY}/user/repo/${CI_PROJECT_PATH_SLUG}:${CI_COMMIT_SHORT_SHA} --kubeconfig ./config --namespace default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment