github.com/verrazzano/verrazzano@v1.7.1/ci/scripts/prepare_distribution_test_jenkins_at_environment.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Copyright (c) 2022, 2023, 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 "$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 25 if [ -z "$3" ]; then 26 echo "Location of verrazzano install file must be specified" 27 exit 1 28 fi 29 30 INSTALL_CONFIG_FILE_KIND="$3" 31 KIND_NODE_COUNT=${KIND_NODE_COUNT:-1} 32 33 BOM_FILE=${TARBALL_DIR}/manifests/verrazzano-bom.json 34 CHART_LOCATION=${TARBALL_DIR}/manifests/charts 35 36 cd ${GO_REPO_PATH}/verrazzano 37 echo "tests will execute" > ${TESTS_EXECUTED_FILE} 38 echo "Create Kind cluster" 39 cd ${TEST_SCRIPTS_DIR} 40 SETUP_PRIVATE_REGISTRY=true ./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} 41 42 if [ $INSTALL_CALICO == true ]; then 43 echo "Install Calico" 44 cd ${GO_REPO_PATH}/verrazzano 45 ./ci/scripts/install_calico.sh "${CLUSTER_NAME}" 46 fi 47 48 # With the Calico configuration to set disableDefaultCNI to true in the KIND configuration, the control plane node will 49 # be ready only after applying calico.yaml. So wait for the KIND control plane node to be ready, before proceeding further, 50 # with maximum wait period of 5 minutes. 51 kubectl wait --for=condition=ready nodes/${CLUSTER_NAME}-control-plane --timeout=5m --all 52 kubectl wait --for=condition=ready pods/kube-controller-manager-${CLUSTER_NAME}-control-plane -n kube-system --timeout=5m 53 echo "Listing pods in kube-system namespace ..." 54 kubectl get pods -n kube-system 55 56 echo "Install metallb" 57 cd ${GO_REPO_PATH}/verrazzano 58 ./tests/e2e/config/scripts/install-metallb.sh 59 60 echo "Create Image Pull Secrets" 61 cd ${GO_REPO_PATH}/verrazzano 62 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${REGISTRY}" "${PRIVATE_REGISTRY_USR}" "${PRIVATE_REGISTRY_PSW}" 63 ./tests/e2e/config/scripts/create-image-pull-secret.sh ocr "${OCR_REPO}" "${OCR_CREDS_USR}" "${OCR_CREDS_PSW}" 64 65 # Create docker secret for platform operator image 66 kubectl create ns verrazzano-install 67 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${REGISTRY}" "${PRIVATE_REGISTRY_USR}" "${PRIVATE_REGISTRY_PSW}" verrazzano-install 68 69 # optionally create a cluster dump snapshot for verifying uninstalls 70 if [ -n "${CLUSTER_SNAPSHOT_DIR}" ]; then 71 ./tests/e2e/config/scripts/looping-test/dump_cluster.sh ${CLUSTER_SNAPSHOT_DIR} 72 fi 73 74 yq eval -i '.metadata.name = "verrazzano"' ${INSTALL_CONFIG_FILE_KIND} 75 yq eval -i '.spec.components.prometheusAdapter.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 76 yq eval -i '.spec.components.kubeStateMetrics.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 77 yq eval -i '.spec.components.prometheusPushgateway.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 78 yq eval -i '.spec.components.velero.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 79 yq eval -i '.spec.components.rancherBackup.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 80 yq eval -i '.spec.components.jaegerOperator.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 81 yq eval -i '.spec.components.argoCD.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 82 yq eval -i '.spec.components.clusterAPI.enabled = true' ${INSTALL_CONFIG_FILE_KIND} 83 84 # Configure the custom resource to install Verrazzano on Kind 85 ./tests/e2e/config/scripts/process_kind_install_yaml.sh ${INSTALL_CONFIG_FILE_KIND} ${WILDCARD_DNS_DOMAIN} 86 87 echo "Installing Verrazzano on Kind" 88 ${GO_REPO_PATH}/vz install -f "${INSTALL_CONFIG_FILE_KIND}" --manifests "${TARBALL_DIR}/manifests/k8s/verrazzano-platform-operator.yaml" --image-registry ${REGISTRY} --image-prefix ${PRIVATE_REPO}