Skip to content

Instantly share code, notes, and snippets.

@dapseen
Created July 13, 2020 21:24
Show Gist options
  • Save dapseen/f85e975c0426c4c96f7a817bd46f8f4d to your computer and use it in GitHub Desktop.
Save dapseen/f85e975c0426c4c96f7a817bd46f8f4d to your computer and use it in GitHub Desktop.
kubernetes single file CI/CD
apk add gettext #install gettext
echo $KUBE_TOKEN | base64 -d > ./kube_token
echo $KUBE_CA | base64 -d > ./kube_ca
kubectl config set-cluster $CLUSTER_NAME --server=$SERVER_URL --certificate-authority="$(pwd)/kube_ca"
kubectl config set-credentials $K8S_SA --token="$(cat ./kube_token)"
kubectl config set-context $K8S_SA --namespace=$NAMESPACE --cluster=$CLUSTER_NAME --user=$K8S_SA
kubectl config use-context $K8S_SA
#deploy image to AWS ECR
docker build -t ${BITBUCKET_REPO_OWNER}/${REPO_NAME} .
docker tag ${BITBUCKET_REPO_OWNER}/${REPO_NAME} $AWS_REGISTRY_URL/sample-image
docker push ${AWS_REGISTRY_URL}/${REPO_NAME}-$ENV > digests.txt
sed -n '$'p digests.txt > last_line.txt #get the last line of docker output
export HASH_RESULT=$(cat last_line.txt | awk '{print $3}') #extract digest using awk utility
cat k8s/wallet-deployments.yaml | envsubst | kubectl apply -f - #apply k8s yaml config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment