gcloud-deploy.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. set -o pipefail
  3. set -o errexit
  4. set -o nounset
  5. # set -o xtrace
  6. # Set magic variables for current FILE & DIR
  7. __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  8. __kube="${__dir}"
  9. __companion="$(dirname "$(dirname "${__kube}")")"
  10. # Install kubectl
  11. curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
  12. chmod +x ./kubectl
  13. mv ./kubectl ${HOME}/.local/bin/
  14. # Store the new image in docker hub
  15. docker build --quiet -t kiloreux/uppy-companion:latest -t kiloreux/uppy-companion:$TRAVIS_COMMIT -f packages/@uppy/companion/Dockerfile packages/@uppy/companion;
  16. docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
  17. docker push kiloreux/uppy-companion:$TRAVIS_COMMIT;
  18. docker push kiloreux/uppy-companion:latest;
  19. echo $KUBECONFIG | base64 --decode -i > ${HOME}/.kube/config
  20. # Should be already removed. Using it temporarily.
  21. rm -f "${__kube}/companion/companion-env.yaml"
  22. echo $COMPANION_ENV | base64 --decode > "${__kube}/companion/companion-env.yaml"
  23. kubectl apply -f "${__kube}/companion/companion-env.yaml"
  24. sleep 10s # This cost me some precious debugging time.
  25. kubectl apply -f "${__kube}/companion/companion-kube.yaml"
  26. kubectl apply -f "${__kube}/companion/companion-redis.yaml"
  27. kubectl set image statefulset companion --namespace=uppy companion=docker.io/kiloreux/uppy-companion:$TRAVIS_COMMIT
  28. sleep 10s
  29. kubectl get pods --namespace=uppy
  30. kubectl get service --namespace=uppy
  31. kubectl get deployment --namespace=uppy
  32. function cleanup {
  33. printf "Cleaning up...\n"
  34. rm -vf "${__kube}/companion/companion-env.yaml"
  35. printf "Cleaning done."
  36. }
  37. trap cleanup EXIT