k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/images/kubekins-e2e/kops-e2e-runner.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2016 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 16 # Download the latest version of kops, then run the e2e tests using e2e.sh. 17 18 set -o errexit 19 set -o nounset 20 set -o pipefail 21 set -o xtrace 22 23 for i in {1..10}; do 24 echo 'WARNING: kops-e2e-runner.sh is deprecated, migrate logic to kubetest' 25 done 26 27 if [[ -z "${KOPS_BASE_URL:-}" ]]; then 28 readonly KOPS_LATEST=${KOPS_LATEST:-"latest-ci.txt"} 29 readonly LATEST_URL="https://storage.googleapis.com/kops-ci/bin/${KOPS_LATEST}" 30 export KOPS_BASE_URL=$(curl -fsS --retry 3 "${LATEST_URL}") 31 if [[ -z "${KOPS_BASE_URL}" ]]; then 32 echo "Can't fetch kops latest URL" >&2 33 exit 1 34 fi 35 fi 36 37 curl -fsS --retry 3 -o "/workspace/kops" "${KOPS_BASE_URL}/linux/amd64/kops" 38 chmod +x "/workspace/kops" 39 40 # Get kubectl on the path (works after e2e-runner.sh:unpack_binaries) 41 export PRIORITY_PATH="${WORKSPACE}/kubernetes/platforms/linux/amd64" 42 43 e2e_args=( \ 44 --deployment=kops \ 45 --kops=/workspace/kops \ 46 ) 47 48 # TODO(zmerlynn): This is duplicating some logic in e2e-runner.sh, but 49 # I'd rather keep it isolated for now. 50 if [[ "${KOPS_DEPLOY_LATEST_KUBE:-}" =~ ^[yY]$ ]]; then 51 readonly KOPS_KUBE_LATEST_URL=${KOPS_DEPLOY_LATEST_URL:-"https://storage.googleapis.com/k8s-release-dev/ci/latest.txt"} 52 readonly KOPS_KUBE_LATEST=$(curl -fsS --retry 3 "${KOPS_KUBE_LATEST_URL}") 53 if [[ -z "${KOPS_KUBE_LATEST}" ]]; then 54 echo "Can't fetch kube latest URL" >&2 55 exit 1 56 fi 57 readonly KOPS_KUBE_RELEASE_URL=${KOPS_KUBE_RELEASE_URL:-"https://storage.googleapis.com/k8s-release-dev/ci"} 58 59 e2e_args+=(--kops-kubernetes-version="${KOPS_KUBE_RELEASE_URL}/${KOPS_KUBE_LATEST}") 60 fi 61 62 # Define a custom instance lister for cluster/log-dump/log-dump.sh. 63 function log_dump_custom_get_instances() { 64 local -r role=$1 65 local kops_regions 66 IFS=', ' read -r -a kops_regions <<< "${KOPS_REGIONS:-us-west-2}" 67 for region in "${kops_regions[@]}"; do 68 aws ec2 describe-instances \ 69 --region "${region}" \ 70 --filter \ 71 "Name=tag:KubernetesCluster,Values=$(kubectl config current-context)" \ 72 "Name=tag:k8s.io/role/${role},Values=1" \ 73 "Name=instance-state-name,Values=running" \ 74 --query "Reservations[].Instances[].PublicDnsName" \ 75 --output text 76 done 77 } 78 pip install awscli # Only needed for log_dump_custom_get_instances 79 export -f log_dump_custom_get_instances # Export to cluster/log-dump/log-dump.sh 80 81 kubetest "${e2e_args[@]}" "${@}" 82 83 if [[ -n "${KOPS_PUBLISH_GREEN_PATH:-}" ]]; then 84 85 if ! which gsutil; then 86 export PATH=/google-cloud-sdk/bin:${PATH} 87 if ! which gsutil; then 88 echo "Can't find gsutil" >&2 89 exit 1 90 fi 91 fi 92 93 # TODO(krzyzacy) - debugging 94 gcloud config list 95 gcloud auth list 96 97 echo "Publish version to ${KOPS_PUBLISH_GREEN_PATH}: ${KOPS_BASE_URL}" 98 echo "${KOPS_BASE_URL}" | gsutil -h "Cache-Control:private, max-age=0, no-transform" cp - "${KOPS_PUBLISH_GREEN_PATH}" 99 fi