Skip to content
Snippets Groups Projects
Commit 36da51d8 authored by garciadeblas's avatar garciadeblas
Browse files

Update krm-functions to fix clutser registration issues


Change-Id: I85cb8e6015e2e989cff8a0e1231bdeec6abdf837
Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent 2b28210d
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#######################################################################################
# Copyright ETSI Contributors and Others.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################
function generator_encrypted_secret_cloud_credentials() {
local CLOUD_CREDENTIALS_FILENAME="$1"
......@@ -491,11 +496,12 @@ function create_bootstrap_for_remote_cluster() {
local PUBLIC_KEY_MGMT="${8:-"${PUBLIC_KEY_MGMT}"}"
local PUBLIC_KEY_NEW_CLUSTER="$9"
local PRIVATE_KEY_NEW_CLUSTER="${10:-${PRIVATE_KEY_NEW_CLUSTER}}"
local IMPORTED_CLUSTER="${11:-"false"}"
# Calculates the folder where managed resources area defined
local MGMT_RESOURCES_DIR="${FLEET_REPO_DIR}/${MGMT_PROJECT_NAME}/managed-resources/_management"
# Create profile folders
echo "" | \
generator_profile_folders_new_cluster \
......@@ -544,6 +550,42 @@ function create_bootstrap_for_remote_cluster() {
prepend_folder_path "${CLUSTER_KUSTOMIZATION_NAME}/" | \
list2folder_cp_over \
"${MGMT_RESOURCES_DIR}"
# If it is an imported cluster, we must create a placeholder Kustomization
if [[ "${IMPORTED_CLUSTER,,}" == "true" ]];
then
TEMPLATES_DIR="${SW_CATALOGS_REPO_DIR}/cloud-resources/flux-remote-bootstrap/empty-kustomization/templates"
export CLUSTER_KUSTOMIZATION_NAME
folder2list \
"${TEMPLATES_DIR}" | \
replace_env_vars \
'${CLUSTER_KUSTOMIZATION_NAME}' | \
prepend_folder_path "${CLUSTER_KUSTOMIZATION_NAME}/" | \
list2folder_cp_over \
"${MGMT_RESOURCES_DIR}"
fi
}
# Disconnect Flux of remote cluster
function disconnect_flux_remote_cluster() {
local CLUSTER_KUSTOMIZATION_NAME="$1"
local FLEET_REPO_DIR="${2:-"${FLEET_REPO_DIR}"}"
local MGMT_PROJECT_NAME="${3:-${MGMT_PROJECT_NAME}}"
# Calculates key folders
## Base folder with Kustomizations for the new cluster
local CLUSTER_FOLDER="${FLEET_REPO_DIR}/clusters/${CLUSTER_KUSTOMIZATION_NAME}"
## Folder where managed resources are defined in the management cluster
local MGMT_RESOURCES_CLUSTER_DIR="${FLEET_REPO_DIR}/${MGMT_PROJECT_NAME}/managed-resources/_management/${CLUSTER_KUSTOMIZATION_NAME}"
# Delete Flux resources syncronized directly from remote cluster
rm -rf "${CLUSTER_FOLDER}/flux-system"
# Delete Flux resources bootstraped remotely
rm -rf "${MGMT_RESOURCES_CLUSTER_DIR}/cluster-bootstrap-${CLUSTER_KUSTOMIZATION_NAME}.yaml"
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment