| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ####################################################################################### |
| 3 | # Copyright ETSI Contributors and Others. |
| 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 |
| 14 | # implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | ####################################################################################### |
| 18 | |
| garciadeblas | 7c473cb | 2024-08-22 10:13:00 +0200 | [diff] [blame] | 19 | set -e -o pipefail |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 20 | |
| 21 | # Warning!!!: Remember to select the desired kubeconfig profile before launching this script |
| 22 | |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 23 | HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") |
| 24 | source "${HERE}/../library/functions.sh" |
| 25 | source "${HERE}/../library/trap.sh" |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 26 | |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 27 | pushd $HERE > /dev/null |
| 28 | |
| 29 | source "${HERE}/00-default-install-options.rc" |
| 30 | [ ! -f "${OSM_HOME_DIR}/user-install-options.rc" ] || source "${OSM_HOME_DIR}/user-install-options.rc" |
| 31 | echo "Loading env variables from 20-base-config.rc" |
| 32 | source "${HERE}/20-base-config.rc" |
| 33 | |
| 34 | # TODO: move this to a parent script that creates the VM |
| 35 | mkdir -p "${OSM_HOME_DIR}/clusters" |
| 36 | if [ -n "${KUBECONFIG_AUX_CLUSTER}" ]; then |
| 37 | cp "${KUBECONFIG_AUX_CLUSTER}" "${OSM_HOME_DIR}/clusters/kubeconfig-aux-svc.yaml" |
| 38 | else |
| 39 | cp "${HOME}/.kube/config" "${OSM_HOME_DIR}/clusters/kubeconfig-aux-svc.yaml" |
| 40 | fi |
| 41 | |
| 42 | export KUBECONFIG="${OSM_HOME_DIR}/clusters/kubeconfig-aux-svc.yaml" |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 43 | |
| 44 | ############################ NGINX Ingress controller |
| 45 | m "\n#####################################################################" "${CYAN}" |
| 46 | m "(1/3) Installing NGINX Ingress controller..." "${CYAN}" |
| 47 | m "#####################################################################\n" "${CYAN}" |
| 48 | |
| 49 | # Install NGINX Ingress controller (NOTE: this command is idempotent) |
| 50 | ## Uncomment for AKS: |
| 51 | NGINX_VERSION="4.10.0" |
| 52 | ANNOTATIONS='--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz' |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 53 | helm upgrade --install ingress-nginx ingress-nginx \ |
| 54 | --repo https://kubernetes.github.io/ingress-nginx --version ${NGINX_VERSION} \ |
| 55 | --namespace ingress-nginx --create-namespace ${ANNOTATIONS} |
| 56 | |
| 57 | # Wait until ready |
| 58 | kubectl wait --namespace ingress-nginx \ |
| 59 | --for=condition=ready pod \ |
| 60 | --selector=app.kubernetes.io/component=controller \ |
| 61 | --timeout=120s |
| 62 | |
| 63 | ##################################################################### |
| 64 | |
| 65 | |
| 66 | ############################ Gitea |
| 67 | m "\n#####################################################################" "${CYAN}" |
| 68 | m "(2/3) Installing Gitea..." "${CYAN}" |
| 69 | m "#####################################################################\n" "${CYAN}" |
| 70 | |
| 71 | # Enter the Gitea folder |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 72 | # TODO: Should we use pushd $HERE/gitea instead of pushd gitea? |
| 73 | pushd "${HERE}/gitea" > /dev/null |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 74 | |
| 75 | # Install Gitea and expose web with Ingress |
| 76 | export GITEA_CHART_VALUES_FILE=${GITEA_CHART_VALUES_FILE:-values-standalone-ingress.yaml} |
| 77 | ./ALL-IN-ONE-Gitea-install.sh |
| 78 | |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 79 | # Setup Git user and SSH keys |
| 80 | m "\nSetting up Git user and SSH keys..." |
| 81 | ./20-setup-gituser-and-sshkeygen.sh |
| 82 | |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 83 | # Provision for OSM |
| 84 | m "\nProvisioning Gitea for OSM use..." |
| 85 | source "${CREDENTIALS_DIR}/gitea_environment.rc" |
| 86 | ./90-provision-gitea-for-osm.sh |
| 87 | |
| 88 | # Return to base folder |
| 89 | popd > /dev/null |
| 90 | |
| 91 | ##################################################################### |
| 92 | |
| 93 | |
| 94 | ############################ Minio |
| 95 | m "\n#####################################################################" "${CYAN}" |
| 96 | m "(3/3) Installing Minio..." "${CYAN}" |
| 97 | m "#####################################################################\n" "${CYAN}" |
| 98 | |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 99 | echo "INSTALL_MINIO=$INSTALL_MINIO" |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 100 | if [ -n "${INSTALL_MINIO}" ]; then |
| 101 | # Enter the Minio folder |
| 102 | pushd minio > /dev/null |
| 103 | # Install Minio and expose Console and tenant endpoint with Ingress |
| 104 | ./ALL-IN-ONE-Minio-install.sh |
| 105 | # Return to base folder |
| 106 | popd > /dev/null |
| 107 | fi |
| 108 | ##################################################################### |
| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 109 | |
| 110 | |
| 111 | # Source tokens |
| 112 | source "${CREDENTIALS_DIR}/gitea_tokens.rc" |
| 113 | |
| 114 | # Add the local Git user to Gitea as a profile, upload the public SSH key (to allow SSH operations), and add the user as "collaborator" to both repos |
| 115 | "${HERE}/gitea/91-provision-local-git-user.sh" |
| 116 | |
| 117 | popd > /dev/null |