github.com/verrazzano/verrazzano@v1.7.1/ci/scripts/prepare_private_registry_jenkins_at_environment.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Copyright (c) 2021, 2022, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  #
     6  
     7  # $1 Boolean indicates whether to setup and install Calico or not
     8  
     9  set -o pipefail
    10  
    11  set -xv
    12  
    13  if [ -z "$GO_REPO_PATH" ] || [ -z "$WORKSPACE" ] || [ -z "$TARBALL_DIR" ] || [ -z "$CLUSTER_NAME" ] ||
    14    [ -z "$KIND_KUBERNETES_CLUSTER_VERSION" ] || [ -z "$KUBECONFIG" ] ||
    15    [ -z "$IMAGE_PULL_SECRET" ] || [ -z "$PRIVATE_REPO" ] || [ -z "$REGISTRY" ] || [ -z "$PRIVATE_REGISTRY_USR" ] ||
    16    [ -z "$PRIVATE_REGISTRY_PSW" ] || [ -z "$VZ_ENVIRONMENT_NAME" ] || [ -z "$INSTALL_PROFILE" ] ||
    17    [ -z "$TESTS_EXECUTED_FILE" ] || [ -z "$INSTALL_CONFIG_FILE_KIND" ] || [ -z "$TEST_SCRIPTS_DIR" ]; then
    18    echo "This script must only be called from Jenkins and requires a number of environment variables are set"
    19    exit 1
    20  fi
    21  
    22  INSTALL_CALICO=${1:-false}
    23  WILDCARD_DNS_DOMAIN=${2:-"nip.io"}
    24  KIND_NODE_COUNT=${KIND_NODE_COUNT:-1}
    25  
    26  BOM_FILE=${TARBALL_DIR}/verrazzano-bom.json
    27  CHART_LOCATION=${TARBALL_DIR}/charts
    28  
    29  cd ${GO_REPO_PATH}/verrazzano
    30  echo "tests will execute" > ${TESTS_EXECUTED_FILE}
    31  echo "Create Kind cluster"
    32  cd ${TEST_SCRIPTS_DIR}
    33  ./create_kind_cluster.sh "${CLUSTER_NAME}" "${GO_REPO_PATH}/verrazzano/platform-operator" "${KUBECONFIG}" "${KIND_KUBERNETES_CLUSTER_VERSION}" true true true $INSTALL_CALICO "NONE" ${KIND_NODE_COUNT}
    34  
    35  if [ $INSTALL_CALICO == true ]; then
    36      echo "Install Calico"
    37      cd ${GO_REPO_PATH}/verrazzano
    38      ./ci/scripts/install_calico.sh "${CLUSTER_NAME}"
    39  fi
    40  
    41  # With the Calico configuration to set disableDefaultCNI to true in the KIND configuration, the control plane node will
    42  # be ready only after applying calico.yaml. So wait for the KIND control plane node to be ready, before proceeding further,
    43  # with maximum wait period of 5 minutes.
    44  kubectl wait --for=condition=ready nodes/${CLUSTER_NAME}-control-plane --timeout=5m --all
    45  kubectl wait --for=condition=ready pods/kube-controller-manager-${CLUSTER_NAME}-control-plane -n kube-system --timeout=5m
    46  echo "Listing pods in kube-system namespace ..."
    47  kubectl get pods -n kube-system
    48  
    49  echo "Install metallb"
    50  cd ${GO_REPO_PATH}/verrazzano
    51  ./tests/e2e/config/scripts/install-metallb.sh
    52  
    53  echo "Create Image Pull Secrets"
    54  cd ${GO_REPO_PATH}/verrazzano
    55  ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${REGISTRY}" "${PRIVATE_REGISTRY_USR}" "${PRIVATE_REGISTRY_PSW}"
    56  ./tests/e2e/config/scripts/create-image-pull-secret.sh ocr "${OCR_REPO}" "${OCR_CREDS_USR}" "${OCR_CREDS_PSW}"
    57  
    58  echo "Install Platform Operator"
    59  VPO_IMAGE=$(cat ${BOM_FILE} | jq -r '.components[].subcomponents[] | select(.name == "verrazzano-platform-operator") | "\(.repository)/\(.images[].image):\(.images[].tag)"')
    60  
    61  helm upgrade --install myv8o ${CHART_LOCATION}/verrazzano-platform-operator \
    62      --set global.imagePullSecrets[0]=${IMAGE_PULL_SECRET} \
    63      --set image=${REGISTRY}/${PRIVATE_REPO}/${VPO_IMAGE} --set global.registry=${REGISTRY} \
    64      --set global.repository=${PRIVATE_REPO}
    65  
    66  # make sure ns exists
    67  ./tests/e2e/config/scripts/check_verrazzano_ns_exists.sh verrazzano-install
    68  
    69  # Create docker secret for platform operator image
    70  ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${REGISTRY}" "${PRIVATE_REGISTRY_USR}" "${PRIVATE_REGISTRY_PSW}" verrazzano-install
    71  
    72  # optionally create a cluster dump snapshot for verifying uninstalls
    73  if [ -n "${CLUSTER_SNAPSHOT_DIR}" ]; then
    74    ./tests/e2e/config/scripts/looping-test/dump_cluster.sh ${CLUSTER_SNAPSHOT_DIR}
    75  fi
    76  
    77  # Configure the custom resource to install Verrazzano on Kind
    78  ./tests/e2e/config/scripts/process_kind_install_yaml.sh ${INSTALL_CONFIG_FILE_KIND} ${WILDCARD_DNS_DOMAIN}
    79  
    80  echo "Wait for Operator to be ready"
    81  cd ${GO_REPO_PATH}/verrazzano
    82  kubectl -n verrazzano-install rollout status deployment/verrazzano-platform-operator
    83  if [ $? -ne 0 ]; then
    84    echo "Operator is not ready"
    85    exit 1
    86  fi
    87  
    88  echo "Installing Verrazzano on Kind"
    89  install_retries=0
    90  until kubectl apply -f ${INSTALL_CONFIG_FILE_KIND}; do
    91    install_retries=$((install_retries+1))
    92    sleep 6
    93    if [ $install_retries -ge 10 ] ; then
    94      echo "Installation Failed trying to apply the Verrazzano CR YAML"
    95      exit 1
    96    fi
    97  done
    98  
    99  # wait for Verrazzano install to complete
   100  ./tests/e2e/config/scripts/wait-for-verrazzano-install.sh
   101  if [ $? -ne 0 ]; then
   102    exit 1
   103  fi
   104  
   105  exit 0