sigs.k8s.io/cluster-api-provider-azure@v1.17.0/scripts/ci-e2e.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2019 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  ###############################################################################
    18  
    19  # This script is executed by presubmit `pull-cluster-api-provider-azure-e2e`
    20  # To run locally, set AZURE_CLIENT_ID, AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID
    21  
    22  set -o errexit
    23  set -o nounset
    24  set -o pipefail
    25  
    26  # Install kubectl
    27  REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
    28  KUBECTL="${REPO_ROOT}/hack/tools/bin/kubectl"
    29  KIND="${REPO_ROOT}/hack/tools/bin/kind"
    30  make --directory="${REPO_ROOT}" "${KUBECTL##*/}" "${KIND##*/}"
    31  
    32  # shellcheck source=hack/ensure-go.sh
    33  source "${REPO_ROOT}/hack/ensure-go.sh"
    34  # shellcheck source=hack/ensure-tags.sh
    35  source "${REPO_ROOT}/hack/ensure-tags.sh"
    36  # shellcheck source=hack/util.sh
    37  source "${REPO_ROOT}/hack/util.sh"
    38  
    39  # Verify the required Environment Variables are present.
    40  capz::util::ensure_azure_envs
    41  
    42  export USE_LOCAL_KIND_REGISTRY=${USE_LOCAL_KIND_REGISTRY:-"true"}
    43  export BUILD_MANAGER_IMAGE=${BUILD_MANAGER_IMAGE:-"true"}
    44  
    45  if [[ "${USE_LOCAL_KIND_REGISTRY}" == "false" ]]; then
    46    : "${REGISTRY:?Environment variable empty or not defined.}"
    47    "${REPO_ROOT}/hack/ensure-acr-login.sh"
    48  else
    49    export REGISTRY="localhost:5000/ci-e2e"
    50  fi
    51  
    52  if [[ "${BUILD_MANAGER_IMAGE}" == "true" ]]; then
    53    defaultTag=$(date -u '+%Y%m%d%H%M%S')
    54    export TAG="${defaultTag:-dev}"
    55  fi
    56  
    57  if [[ "$(capz::util::should_build_ccm)" == "true" ]]; then
    58    # shellcheck source=scripts/ci-build-azure-ccm.sh
    59    source "${REPO_ROOT}/scripts/ci-build-azure-ccm.sh"
    60    echo "Will use the ${IMAGE_REGISTRY}/${CCM_IMAGE_NAME}:${IMAGE_TAG_CCM} cloud-controller-manager image for external cloud-provider-cluster"
    61    echo "Will use the ${IMAGE_REGISTRY}/${CNM_IMAGE_NAME}:${IMAGE_TAG_CNM} cloud-node-manager image for external cloud-provider-azure cluster"
    62  fi
    63  
    64  export GINKGO_NODES=10
    65  
    66  export AZURE_LOCATION="${AZURE_LOCATION:-$(capz::util::get_random_region)}"
    67  export AZURE_LOCATION_GPU="${AZURE_LOCATION_GPU:-$(capz::util::get_random_region_gpu)}"
    68  export AZURE_LOCATION_EDGEZONE="${AZURE_LOCATION_EDGEZONE:-$(capz::util::get_random_region_edgezone)}"
    69  export AZURE_CONTROL_PLANE_MACHINE_TYPE="${AZURE_CONTROL_PLANE_MACHINE_TYPE:-"Standard_B2s"}"
    70  export AZURE_NODE_MACHINE_TYPE="${AZURE_NODE_MACHINE_TYPE:-"Standard_B2s"}"
    71  CALICO_VERSION=$(make get-calico-version)
    72  export CALICO_VERSION
    73  
    74  
    75  capz::util::generate_ssh_key
    76  
    77  capz::ci-e2e::cleanup() {
    78      "${REPO_ROOT}/hack/log/redact.sh" || true
    79  }
    80  
    81  trap capz::ci-e2e::cleanup EXIT
    82  # Image is configured as `${CONTROLLER_IMG}-${ARCH}:${TAG}` where `CONTROLLER_IMG` is defaulted to `${REGISTRY}/${IMAGE_NAME}`.
    83  if [[ "${BUILD_MANAGER_IMAGE}" == "false" ]]; then
    84    # Load an existing image, skip docker-build and docker-push.
    85    make test-e2e-skip-build-and-push
    86  elif [[ "${USE_LOCAL_KIND_REGISTRY}" == "true" ]]; then
    87    # Build an image with kind local registry, skip docker-push. REGISTRY is set to `localhost:5000/ci-e2e`. TAG is set to `$(date -u '+%Y%m%d%H%M%S')`.
    88    make test-e2e-skip-push
    89  else
    90    # Build an image and push to the registry. TAG is set to `$(date -u '+%Y%m%d%H%M%S')`.
    91    make test-e2e
    92  fi