| 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 | |
| 19 | set -e -o pipefail |
| 20 | |
| 21 | export HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") |
| 22 | source "${HERE}/library/functions.sh" |
| 23 | source "${HERE}/library/trap.sh" |
| 24 | |
| 25 | |
| garciadeblas | 8a28f6d | 2025-06-11 11:11:56 +0200 | [diff] [blame^] | 26 | # Preparation for Openshift |
| 27 | if [ -n "${OPENSHIFT_MGMT_CLUSTER}" ]; then |
| 28 | m "Detected OpenShift management cluster, initilializing flux with SCC..." "${GREEN}" |
| 29 | # Preparation for Openshift |
| 30 | pushd "${FLEET_REPO_DIR}" > /dev/null |
| 31 | FLUX_SYSTEM_DIR="clusters/_management/flux-system" |
| 32 | FLUX_SYSTEM_SW_CATALOG_DIR="${HERE}/../templates/sw-catalogs/cloud-resources/flux-remote-bootstrap/cluster-base-openshift/templates/flux-system" |
| 33 | mkdir -p "${FLUX_SYSTEM_DIR}" |
| 34 | touch "${FLUX_SYSTEM_DIR}/gotk-components.yaml" |
| 35 | touch "${FLUX_SYSTEM_DIR}/gotk-sync.yaml" |
| 36 | cp "${FLUX_SYSTEM_SW_CATALOG_DIR}/scc.yaml" "${FLUX_SYSTEM_DIR}" |
| 37 | cp "${FLUX_SYSTEM_SW_CATALOG_DIR}/kustomization.yaml" "${FLUX_SYSTEM_DIR}" |
| 38 | # git status |
| 39 | git add -A |
| 40 | git commit -m "init flux" |
| 41 | git pull origin main |
| 42 | git push -u origin main |
| 43 | popd > /dev/null |
| 44 | fi |
| 45 | |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 46 | # Bootstrap |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 47 | GIT_PATH=./clusters/_management |
| 48 | GIT_BRANCH=main |
| garciadeblas | 8a28f6d | 2025-06-11 11:11:56 +0200 | [diff] [blame^] | 49 | if [ -n "${MGMT_CLUSTER_CA_FILE}" ]; then |
| 50 | flux bootstrap git \ |
| 51 | --url=${FLEET_REPO_HTTP_URL} \ |
| 52 | --allow-insecure-http=true \ |
| 53 | --username=${FLEET_REPO_GIT_USERNAME} \ |
| 54 | --password="${FLEET_REPO_GIT_USER_PASS}" \ |
| 55 | --token-auth=true \ |
| 56 | --branch=${GIT_BRANCH} \ |
| 57 | --ca-file=${MGMT_CLUSTER_CA_FILE} \ |
| 58 | --path=${GIT_PATH} |
| 59 | else |
| 60 | flux bootstrap git \ |
| 61 | --url=${FLEET_REPO_HTTP_URL} \ |
| 62 | --allow-insecure-http=true \ |
| 63 | --username=${FLEET_REPO_GIT_USERNAME} \ |
| 64 | --password="${FLEET_REPO_GIT_USER_PASS}" \ |
| 65 | --token-auth=true \ |
| 66 | --branch=${GIT_BRANCH} \ |
| 67 | --path=${GIT_PATH} |
| 68 | fi |
| garciadeblas | 8d8cd99 | 2024-05-21 16:04:14 +0200 | [diff] [blame] | 69 | |
| 70 | # Check if successful |
| 71 | flux check |