From 5aaaca3d722dbc4b6ae381c80bc8615a824904f1 Mon Sep 17 00:00:00 2001 From: ktatarnikov Date: Wed, 3 Dec 2025 11:09:54 +0100 Subject: [PATCH 1/3] EDGE-372 renaming into dev template --- config/generator/{config-template.yaml => config-dev.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/generator/{config-template.yaml => config-dev.yaml} (100%) diff --git a/config/generator/config-template.yaml b/config/generator/config-dev.yaml similarity index 100% rename from config/generator/config-template.yaml rename to config/generator/config-dev.yaml From 73efa2c5d6a1d38bfee00e72ec43ec0ed879c59b Mon Sep 17 00:00:00 2001 From: ktatarnikov Date: Wed, 3 Dec 2025 11:12:33 +0100 Subject: [PATCH 2/3] EDGE-372 cluster setup script --- config/generator/env/clusters.sh | 394 +++++++++++++++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100755 config/generator/env/clusters.sh diff --git a/config/generator/env/clusters.sh b/config/generator/env/clusters.sh new file mode 100755 index 0000000..fe58e66 --- /dev/null +++ b/config/generator/env/clusters.sh @@ -0,0 +1,394 @@ +#!/bin/bash +# +# This script manages the creation, deletion, and configuration of Kubernetes clusters using kind (Kubernetes IN Docker). +# It sets up multiple clusters with Calico for inter-cluster networking and configures BGP for routing between clusters. +# +# Usage: +# ./clusters.sh {create|delete|cloudprovider} +# +# Commands: +# create - Creates the clusters, installs and configures Calico, and sets up BGP and DNS. +# delete - Deletes all the clusters. +# cloudprovider - Runs the cloud-provider-kind. +# +# Prerequisites: +# - jq +# - kind +# - kubectl +# - cloud-provider-kind +# +# Environment Variables: +# CLUSTERS - Array of cluster names. +# POD_SUBNETS - Array of pod subnets for each cluster. +# SVC_SUBNETS - Array of service subnets for each cluster. +# AS_NUMBERS - Array of BGP Autonomous System (AS) numbers for each cluster. +# DNS_DOMAINS - Array of DNS domains for each cluster. +# DEFAULT_DNS_IPS - Array of default DNS IPs for each cluster. +# NODES - Array of node roles for each cluster. +# +CLUSTERS=("kind-cluster1" "kind-cluster2") +POD_SUBNETS=("192.168.0.0" "192.169.0.0") +SVC_SUBNETS=("10.96.0.0" "10.97.0.0") +AS_NUMBERS=("65001" "65002") +DNS_DOMAINS=("cluster1.local" "cluster2.local") +DEFAULT_DNS_IPS=("10.96.0.10" "10.97.0.10") + +NODES=("control-plane" "worker") + +usage() { + echo "Usage: $0 {create|delete|cloudprovider}" + exit 1 +} + +main () { + if [ $# -ne 1 ]; then + usage + fi + + case "$1" in + create) + create_clusters + ;; + delete) + delete_clusters + ;; + cloudprovider) + run_cloud_provider_kind + ;; + *) + echo "Error: Invalid command '$1'" + usage + ;; + esac +} + +create_clusters() { + validate + create_clusters_all + merge_kubeconfig + install_calico_all + configure_calico_all + wait_pods_ready_all + configure_dns_all + wait_pods_ready_all + configure_bgp_all + wait_pods_ready_all + configure_bgp_peers_all + + echo "Clusters with Calico with inter-cluster networking are now set up!" +} + +validate() { + if ! command -v jq &> /dev/null; then + echo "jq is not installed. Please install it before running this script." + exit 1 + fi + + if ! command -v kind &> /dev/null; then + echo "kind is not installed. Please install it before running this script." + exit 1 + fi + + if ! command -v kubectl &> /dev/null; then + echo "kubectl is not installed. Please install it before running this script." + exit 1 + fi + + if ! command -v cloud-provider-kind &> /dev/null; then + echo "cloud-provider-kind is not installed. Please install it before running this script." + exit 1 + fi + + mkdir -p target +} + +create_clusters_all() { + echo "### Creating clusters... ###" + + for i in "${!CLUSTERS[@]}"; do + cluster="${CLUSTERS[$i]}" + pod_subnet="${POD_SUBNETS[$i]}" + svc_subnet="${SVC_SUBNETS[$i]}" + dns_domain="${DNS_DOMAINS[$i]}" + create_cluster $cluster $pod_subnet $svc_subnet $dns_domain + done + kind get clusters + echo "" +} + +create_cluster() { + local cluster_name=$1 + local pod_subnet=$2 + local svc_subnet=$3 + local dns_domain=$4 + + echo "Creating cluster: $cluster_name" + + kind create cluster --name $cluster_name --config - < ./target/kubeconfig.${cluster}.yaml + KUBECONFIG=./target/kubeconfig.${cluster}.yaml:${KUBECONFIG}: + done + + export KUBECONFIG=${KUBECONFIG} + kubectl config view --merge --flatten > ./target/merged-kubeconfig.yaml + + export KUBECONFIG=$(pwd)/target/merged-kubeconfig.yaml + echo "KUBECONFIG set to: ${KUBECONFIG}" + echo "" +} + +install_calico_all() { + echo "### Installing Calico... ###" + for i in "${!CLUSTERS[@]}"; do + cluster="${CLUSTERS[$i]}" + install_calico $cluster + done + echo "" + sleep 1 +} + +install_calico() { + local cluster=$1 + + echo "Installing Calico on $cluster..." + kubectl --context kind-${cluster} create ns calico-system + kubectl --context kind-${cluster} create -f https://raw.githubusercontent.com/projectcalico/calico/v3.30.1/manifests/operator-crds.yaml + kubectl --context kind-${cluster} create -f https://raw.githubusercontent.com/projectcalico/calico/v3.30.1/manifests/tigera-operator.yaml +} + +configure_calico_all() { + echo "### Configuring Calico... ###" + + for i in "${!CLUSTERS[@]}"; do + cluster="${CLUSTERS[$i]}" + pod_subnet="${POD_SUBNETS[$i]}" + configure_calico $cluster $pod_subnet + done + echo "" +} + +configure_calico() { + local cluster=$1 + local pod_subnet=$2 + + echo "Configuring Calico on $cluster..." + + kubectl --context kind-${cluster} create -f -< Date: Wed, 3 Dec 2025 11:28:21 +0100 Subject: [PATCH 3/3] EDGE-372 docs: install scripts --- docs/usage/installation.md | 41 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/usage/installation.md b/docs/usage/installation.md index d604808..995546e 100644 --- a/docs/usage/installation.md +++ b/docs/usage/installation.md @@ -11,9 +11,46 @@ Requirements: 1. Generate multi cluster configuration using script [here](https://github.com/HIRO-MicroDataCenters-BV/anyapplication-controller/tree/main/config/generator) -2. Execute install scripts for all clusters + The command below will generate development configuration from ./config-dev.yaml file for two clusters - kind-cluster1 and kind-cluster2. - TBD + ```sh + ./generate.sh create-config ./config-dev.yaml ./target + ``` + + Note that the script will generate keys for all clusters. New ones are generated on every call. + +2. Execute install scripts for all clusters: + + ```sh + + # kind-kind-cluster1 + ./target/kind-kind-cluster1/anyapplication-install.sh + ./target/kind-kind-cluster1/mesh-install.sh + ./target/kind-kind-cluster1/placement-install.sh + + # kind-kind-cluster2 + ./target/kind-kind-cluster2/anyapplication-install.sh + ./target/kind-kind-cluster2/mesh-install.sh + ./target/kind-kind-cluster2/placement-install.sh + + ``` +## Uninstall Guide + +Execute uninstall scripts for all clusters + + ```sh + + # kind-kind-cluster1 + ./target/kind-kind-cluster1/anyapplication-uninstall.sh + ./target/kind-kind-cluster1/mesh-uninstall.sh + ./target/kind-kind-cluster1/placement-uninstall.sh + + # kind-kind-cluster2 + ./target/kind-kind-cluster2/anyapplication-uninstall.sh + ./target/kind-kind-cluster2/mesh-uninstall.sh + ./target/kind-kind-cluster2/placement-uninstall.sh + + ``` ## Application Deployment