blob: 27caa84a0dbc3c787947d7c051dce5c0f25085fc [file] [log] [blame]
garciadeblas8d8cd992024-05-21 16:04:14 +02001#!/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
garciadeblas7c473cb2024-08-22 10:13:00 +020019set -e -o pipefail
garciadeblas8d8cd992024-05-21 16:04:14 +020020
21# Warning!!!: Remember to select the desired kubeconfig profile before launching this script
22
garciadeblascf603f52025-06-04 11:57:28 +020023HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")")
24source "${HERE}/../library/functions.sh"
25source "${HERE}/../library/trap.sh"
garciadeblas8d8cd992024-05-21 16:04:14 +020026
garciadeblascf603f52025-06-04 11:57:28 +020027pushd $HERE > /dev/null
28
29source "${HERE}/00-default-install-options.rc"
30[ ! -f "${OSM_HOME_DIR}/user-install-options.rc" ] || source "${OSM_HOME_DIR}/user-install-options.rc"
31echo "Loading env variables from 20-base-config.rc"
32source "${HERE}/20-base-config.rc"
33
34# TODO: move this to a parent script that creates the VM
35mkdir -p "${OSM_HOME_DIR}/clusters"
36if [ -n "${KUBECONFIG_AUX_CLUSTER}" ]; then
37 cp "${KUBECONFIG_AUX_CLUSTER}" "${OSM_HOME_DIR}/clusters/kubeconfig-aux-svc.yaml"
38else
39 cp "${HOME}/.kube/config" "${OSM_HOME_DIR}/clusters/kubeconfig-aux-svc.yaml"
40fi
41
42export KUBECONFIG="${OSM_HOME_DIR}/clusters/kubeconfig-aux-svc.yaml"
garciadeblas8d8cd992024-05-21 16:04:14 +020043
44############################ NGINX Ingress controller
45m "\n#####################################################################" "${CYAN}"
46m "(1/3) Installing NGINX Ingress controller..." "${CYAN}"
47m "#####################################################################\n" "${CYAN}"
48
49# Install NGINX Ingress controller (NOTE: this command is idempotent)
50## Uncomment for AKS:
51NGINX_VERSION="4.10.0"
52ANNOTATIONS='--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz'
garciadeblas8d8cd992024-05-21 16:04:14 +020053helm 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
58kubectl 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
67m "\n#####################################################################" "${CYAN}"
68m "(2/3) Installing Gitea..." "${CYAN}"
69m "#####################################################################\n" "${CYAN}"
70
71# Enter the Gitea folder
garciadeblascf603f52025-06-04 11:57:28 +020072# TODO: Should we use pushd $HERE/gitea instead of pushd gitea?
73pushd "${HERE}/gitea" > /dev/null
garciadeblas8d8cd992024-05-21 16:04:14 +020074
75# Install Gitea and expose web with Ingress
76export GITEA_CHART_VALUES_FILE=${GITEA_CHART_VALUES_FILE:-values-standalone-ingress.yaml}
77./ALL-IN-ONE-Gitea-install.sh
78
garciadeblascf603f52025-06-04 11:57:28 +020079# Setup Git user and SSH keys
80m "\nSetting up Git user and SSH keys..."
81./20-setup-gituser-and-sshkeygen.sh
82
garciadeblas8d8cd992024-05-21 16:04:14 +020083# Provision for OSM
84m "\nProvisioning Gitea for OSM use..."
85source "${CREDENTIALS_DIR}/gitea_environment.rc"
86./90-provision-gitea-for-osm.sh
87
88# Return to base folder
89popd > /dev/null
90
91#####################################################################
92
93
94############################ Minio
95m "\n#####################################################################" "${CYAN}"
96m "(3/3) Installing Minio..." "${CYAN}"
97m "#####################################################################\n" "${CYAN}"
98
garciadeblascf603f52025-06-04 11:57:28 +020099echo "INSTALL_MINIO=$INSTALL_MINIO"
garciadeblas8d8cd992024-05-21 16:04:14 +0200100if [ -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
107fi
108#####################################################################
garciadeblascf603f52025-06-04 11:57:28 +0200109
110
111# Source tokens
112source "${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
117popd > /dev/null