run.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Copyright 2019 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. if ! command -v kind --version &> /dev/null; then
  19. echo "kind is not installed. Use the package manager or visit the official site https://kind.sigs.k8s.io/"
  20. exit 1
  21. fi
  22. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  23. cd $DIR
  24. echo "Kubernetes cluster:"
  25. kubectl get nodes -o wide
  26. echo -e "Granting permissions to e2e service account..."
  27. kubectl create serviceaccount external-secrets-e2e || true
  28. kubectl create clusterrolebinding permissive-binding \
  29. --clusterrole=cluster-admin \
  30. --user=admin \
  31. --user=kubelet \
  32. --serviceaccount=default:external-secrets-e2e || true
  33. echo -e "Waiting service account..."; \
  34. until kubectl get secret | grep -q -e ^external-secrets-e2e-token; do \
  35. echo -e "waiting for api token"; \
  36. sleep 3; \
  37. done
  38. kubectl apply -f ${DIR}/k8s/deploy/crds
  39. echo -e "Starting the e2e test pod"
  40. FOCUS=${FOCUS:-.*}
  41. export FOCUS
  42. kubectl run --rm \
  43. --attach \
  44. --restart=Never \
  45. --env="FOCUS=${FOCUS}" \
  46. --env="GCP_SM_SA_JSON=${GCP_SM_SA_JSON}" \
  47. --overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "external-secrets-e2e"}}' \
  48. e2e --image=local/external-secrets-e2e:test