sigs.k8s.io/cluster-api-provider-azure@v1.17.0/hack/create-dev-cluster.sh (about)

     1  #!/bin/bash
     2  # Copyright 2020 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  set -o errexit
    17  set -o nounset
    18  set -o pipefail
    19  
    20  REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
    21  # shellcheck source=hack/util.sh
    22  source "${REPO_ROOT}/hack/util.sh"
    23  
    24  # Verify the required Environment Variables are present.
    25  capz::util::ensure_azure_envs
    26  
    27  make envsubst
    28  
    29  export REGISTRY="${REGISTRY:-registry.local/fake}"
    30  
    31  export CLUSTER_CREATE_ATTEMPTS="${CLUSTER_CREATE_ATTEMPTS:-3}"
    32  
    33  # Cluster settings.
    34  export CLUSTER_NAME="${CLUSTER_NAME:-capz-test}"
    35  export AZURE_VNET_NAME=${CLUSTER_NAME}-vnet
    36  
    37  # Azure settings.
    38  export AZURE_LOCATION="${AZURE_LOCATION:-southcentralus}"
    39  export AZURE_RESOURCE_GROUP=${CLUSTER_NAME}
    40  
    41  AZURE_SUBSCRIPTION_ID="${AZURE_SUBSCRIPTION_ID:=}"
    42  AZURE_TENANT_ID="${AZURE_TENANT_ID:=}"
    43  AZURE_CLIENT_ID="${AZURE_CLIENT_ID:=}"
    44  
    45  AZURE_SUBSCRIPTION_ID_B64="$(echo -n "$AZURE_SUBSCRIPTION_ID" | base64 | tr -d '\n')"
    46  AZURE_TENANT_ID_B64="$(echo -n "$AZURE_TENANT_ID" | base64 | tr -d '\n')"
    47  AZURE_CLIENT_ID_B64="$(echo -n "$AZURE_CLIENT_ID" | base64 | tr -d '\n')"
    48  
    49  export AZURE_SUBSCRIPTION_ID_B64 AZURE_TENANT_ID_B64 AZURE_CLIENT_ID_B64
    50  
    51  # Machine settings.
    52  export CONTROL_PLANE_MACHINE_COUNT=${CONTROL_PLANE_MACHINE_COUNT:-3}
    53  export AZURE_CONTROL_PLANE_MACHINE_TYPE="${CONTROL_PLANE_MACHINE_TYPE:-Standard_B2s}"
    54  export AZURE_NODE_MACHINE_TYPE="${NODE_MACHINE_TYPE:-Standard_B2s}"
    55  export WORKER_MACHINE_COUNT=${WORKER_MACHINE_COUNT:-2}
    56  export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.29.5}"
    57  export CLUSTER_TEMPLATE="${CLUSTER_TEMPLATE:-cluster-template.yaml}"
    58  
    59  # identity secret settings.
    60  export CLUSTER_IDENTITY_NAME=${CLUSTER_IDENTITY_NAME:="cluster-identity"}
    61  export ASO_CREDENTIAL_SECRET_NAME=${ASO_CREDENTIAL_SECRET_NAME:="aso-credentials"}
    62  
    63  # Generate SSH key.
    64  capz::util::generate_ssh_key
    65  
    66  echo "================ DOCKER BUILD ==============="
    67  PULL_POLICY=IfNotPresent make modules docker-build
    68  
    69  setup() {
    70      echo "================ MAKE CLEAN ==============="
    71      make clean
    72  
    73      echo "================ KIND RESET ==============="
    74      make kind-reset
    75  
    76      echo "================ INSTALL TOOLS ==============="
    77      make install-tools
    78  }
    79  
    80  create_cluster() {
    81      echo "================ CREATE CLUSTER ==============="
    82      make create-cluster
    83  }
    84  
    85  retries=$CLUSTER_CREATE_ATTEMPTS
    86  while ((retries > 0)); do
    87      setup
    88      create_cluster && break
    89      sleep 5
    90      ((retries --))
    91  done