Skip to content

Instantly share code, notes, and snippets.

@sdowsland
Created November 19, 2019 13:44
Show Gist options
  • Save sdowsland/53f8fe58227aaa1d968eaa33397dea0c to your computer and use it in GitHub Desktop.
Save sdowsland/53f8fe58227aaa1d968eaa33397dea0c to your computer and use it in GitHub Desktop.
Set env in kube config
#! /bin/bash
# exit script when any command ran here returns with non-zero exit code
set -e
COMMIT_SHA1=$CIRCLE_SHA1
# We must export it so it's available for envsubst
export COMMIT_SHA1=$COMMIT_SHA1
# since the only way for envsubst to work on files is using input/output redirection,
# it's not possible to do in-place substitution, so we need to save the output to another file
# and overwrite the original with that one.
envsubst <./kube/do-sample-deployment.yml >./kube/do-sample-deployment.yml.out
mv ./kube/do-sample-deployment.yml.out ./kube/do-sample-deployment.yml
echo "$KUBERNETES_CLUSTER_CERTIFICATE" | base64 --decode > cert.crt
./kubectl \
--kubeconfig=/dev/null \
--server=$KUBERNETES_SERVER \
--certificate-authority=cert.crt \
--token=$KUBERNETES_TOKEN \
apply -f ./kube/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment