sigs.k8s.io/cluster-api-provider-azure@v1.14.3/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_B64="$(echo -n "$AZURE_SUBSCRIPTION_ID" | base64 | tr -d '\n')"
    42  AZURE_TENANT_ID_B64="$(echo -n "$AZURE_TENANT_ID" | base64 | tr -d '\n')"
    43  AZURE_CLIENT_ID_B64="$(echo -n "$AZURE_CLIENT_ID" | base64 | tr -d '\n')"
    44  AZURE_CLIENT_SECRET_B64="$(echo -n "$AZURE_CLIENT_SECRET" | base64 | tr -d '\n')"
    45  
    46  export AZURE_SUBSCRIPTION_ID_B64 AZURE_TENANT_ID_B64 AZURE_CLIENT_ID_B64 AZURE_CLIENT_SECRET_B64
    47  
    48  # Machine settings.
    49  export CONTROL_PLANE_MACHINE_COUNT=${CONTROL_PLANE_MACHINE_COUNT:-3}
    50  export AZURE_CONTROL_PLANE_MACHINE_TYPE="${CONTROL_PLANE_MACHINE_TYPE:-Standard_B2s}"
    51  export AZURE_NODE_MACHINE_TYPE="${NODE_MACHINE_TYPE:-Standard_B2s}"
    52  export WORKER_MACHINE_COUNT=${WORKER_MACHINE_COUNT:-2}
    53  export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.26.6}"
    54  export CLUSTER_TEMPLATE="${CLUSTER_TEMPLATE:-cluster-template.yaml}"
    55  
    56  # identity secret settings.
    57  export AZURE_CLUSTER_IDENTITY_SECRET_NAME="cluster-identity-secret"
    58  export CLUSTER_IDENTITY_NAME=${CLUSTER_IDENTITY_NAME:="cluster-identity"}
    59  export AZURE_CLUSTER_IDENTITY_SECRET_NAMESPACE="default"
    60  
    61  # Generate SSH key.
    62  capz::util::generate_ssh_key
    63  
    64  echo "================ DOCKER BUILD ==============="
    65  PULL_POLICY=IfNotPresent make modules docker-build
    66  
    67  setup() {
    68      echo "================ MAKE CLEAN ==============="
    69      make clean
    70  
    71      echo "================ KIND RESET ==============="
    72      make kind-reset
    73  
    74      echo "================ INSTALL TOOLS ==============="
    75      make install-tools
    76  }
    77  
    78  create_cluster() {
    79      echo "================ CREATE CLUSTER ==============="
    80      make create-cluster
    81  }
    82  
    83  setup
    84  
    85  retries=$CLUSTER_CREATE_ATTEMPTS
    86  while ((retries > 0)); do
    87      create_cluster && break
    88      setup
    89      sleep 5
    90      ((retries --))
    91  done