From 6465405473af5fa34cf77183f514aaba84f52c1b Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Wed, 31 Jul 2024 14:14:00 -0700 Subject: [PATCH 01/12] add joinMC script --- hack/Azure/joinMC.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 hack/Azure/joinMC.sh diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh new file mode 100644 index 00000000..31f4d733 --- /dev/null +++ b/hack/Azure/joinMC.sh @@ -0,0 +1,69 @@ +# CAN ONLY BE RUN AFTER CREATING NEEDED AKS CLUSTERS AND HUB CLUSTER. This script creates member clusters for +# AKS Clusters and joins them onto the fleet hub cluster. + +export REFRESH_TOKEN_IMAGE_TAG="$1" +export FLEET_NETWORKING_AGENT_IMAGE_TAG="$2" + +export HUB_CLUSTER="$3" +export HUB_CLUSTER_CONTEXT=$(kubectl config view -o jsonpath="{.contexts[?(@.context.cluster==\"$HUB_CLUSTER\")].name}") +export HUB_CLUSTER_ADDRESS=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$HUB_CLUSTER\")].cluster.server}") + +for MC in "${@:4}"; do + +# Note that Fleet will recognize your cluster with this name once it joins. +export MEMBER_CLUSTER=$(kubectl config view -o jsonpath="{.contexts[?(@.context.cluster==\"$MC\")].name}") +export MEMBER_CLUSTER_CONTEXT=$(kubectl config view -o jsonpath="{.contexts[?(@.context.cluster==\"$MC\")].name}") + +echo "Switching to member cluster context..." +kubectl config use-context $MEMBER_CLUSTER_CONTEXT + +echo "Apply the Fleet networking CRDs..." +kubectl apply -f config/crd/* + +# # Install the fleet networking member agent helm charts on the member cluster. + +# The variables below uses the Fleet networking images kept in the Microsoft Container Registry (MCR), +# and will retrieve the latest version from the Fleet GitHub repository. +# +# You can, however, build the Fleet networking images of your own; see the repository README for +# more information. +echo "Retrieving image..." +export REGISTRY="mcr.microsoft.com/aks/fleet" +export MCS_CONTROLLER_MANAGER_IMAGE="mcs-controller-manager" +export MEMBER_NET_CONTROLLER_MANAGER_IMAGE="member-net-controller-manager" +export REFRESH_TOKEN_IMAGE="${REFRESH_TOKEN_NAME:-refresh-token}" +export OUTPUT_TYPE="${OUTPUT_TYPE:-type=docker}" + +echo "Uninstalling mcs-controller-manager..." +helm uninstall mcs-controller-manager --wait + +echo "Installing mcs-controller-manager..." +helm install mcs-controller-manager ./charts/mcs-controller-manager/ \ +--set image.repository=$REGISTRY/$MCS_CONTROLLER_MANAGER_IMAGE \ +--set refreshtoken.repository=$REGISTRY/$REFRESH_TOKEN_IMAGE \ +--set refreshtoken.tag=$REFRESH_TOKEN_IMAGE_TAG \ +--set image.tag=$FLEET_NETWORKING_AGENT_IMAGE_TAG \ +--set image.pullPolicy=Always \ +--set refreshtoken.pullPolicy=Always \ +--set config.hubURL=$HUB_CLUSTER_ADDRESS \ +--set config.memberClusterName=$MEMBER_CLUSTER \ +--set enableV1Alpha1APIs=false \ +--set enableV1Beta1APIs=true \ +--set logVerbosity=8 + +echo "Uninstalling member-net-controller-manager..." +helm uninstall member-net-controller-manager --wait + +echo "Installing member-net-controller-manager..." +helm install member-net-controller-manager ./charts/member-net-controller-manager/ \ +--set image.repository=$REGISTRY/$MEMBER_NET_CONTROLLER_MANAGER_IMAGE \ +--set refreshtoken.repository=$REGISTRY/$REFRESH_TOKEN_IMAGE \ +--set refreshtoken.tag=$REFRESH_TOKEN_IMAGE_TAG \ +--set image.tag=$FLEET_NETWORKING_AGENT_IMAGE_TAG \ +--set timage.pullPolicy=Always \ +--set refreshtoken.pullPolicy=Always \ +--set config.hubURL=$HUB_CLUSTER_ADDRESS \ +--set config.memberClusterName=$MEMBER_CLUSTER \ +--set enableV1Alpha1APIs=false \ +--set enableV1Beta1APIs=true \ +--set logVerbosity=8 \ No newline at end of file From 9a3d927e87078ac4beadbfffeb7975fd2af185a8 Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Wed, 31 Jul 2024 14:51:35 -0700 Subject: [PATCH 02/12] minor fix --- hack/Azure/joinMC.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 hack/Azure/joinMC.sh diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh old mode 100644 new mode 100755 index 31f4d733..1ef1d4d4 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -66,4 +66,5 @@ helm install member-net-controller-manager ./charts/member-net-controller-manage --set config.memberClusterName=$MEMBER_CLUSTER \ --set enableV1Alpha1APIs=false \ --set enableV1Beta1APIs=true \ ---set logVerbosity=8 \ No newline at end of file +--set logVerbosity=8 +done \ No newline at end of file From 96b382138001a8d78539177e28aebf4bbf746907 Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Wed, 31 Jul 2024 14:56:30 -0700 Subject: [PATCH 03/12] add extra empty line --- hack/Azure/joinMC.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index 1ef1d4d4..aaaa2e57 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -67,4 +67,4 @@ helm install member-net-controller-manager ./charts/member-net-controller-manage --set enableV1Alpha1APIs=false \ --set enableV1Beta1APIs=true \ --set logVerbosity=8 -done \ No newline at end of file +done From f246f04e0bc6f39dbffb97b266c941716b742f76 Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Wed, 31 Jul 2024 15:10:25 -0700 Subject: [PATCH 04/12] minor changes to print MC --- hack/Azure/joinMC.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index aaaa2e57..b8de97d6 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -67,4 +67,8 @@ helm install member-net-controller-manager ./charts/member-net-controller-manage --set enableV1Alpha1APIs=false \ --set enableV1Beta1APIs=true \ --set logVerbosity=8 + +kubectl get pods -A +kubectl config use-context $HUB_CLUSTER_CONTEXT +kubectl get membercluster $MEMBER_CLUSTER done From 4d98d01ac07d6d298a7368650a16b3813e8880c8 Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Wed, 31 Jul 2024 17:05:08 -0700 Subject: [PATCH 05/12] minor change --- hack/Azure/joinMC.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index b8de97d6..540c7e3c 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -70,5 +70,5 @@ helm install member-net-controller-manager ./charts/member-net-controller-manage kubectl get pods -A kubectl config use-context $HUB_CLUSTER_CONTEXT -kubectl get membercluster $MEMBER_CLUSTER +kubectl get membercluster -A done From 05fd88b7ca1385afe43f7cd2d27dda1e1b756b1c Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 14:42:25 -0700 Subject: [PATCH 06/12] fix comment --- hack/Azure/joinMC.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index 540c7e3c..4e12b32f 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -1,5 +1,6 @@ -# CAN ONLY BE RUN AFTER CREATING NEEDED AKS CLUSTERS AND HUB CLUSTER. This script creates member clusters for -# AKS Clusters and joins them onto the fleet hub cluster. +# CAN ONLY BE RUN AFTER CREATING NEEDED MEMBER CLUSTERS, HUB CLUSTER AND INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER +# This can be achieved by running the script in fleet/hack/Azure/setup/joinHC.sh in the fleet repository +# This script installs the fleet-networking member agents on each member cluster. export REFRESH_TOKEN_IMAGE_TAG="$1" export FLEET_NETWORKING_AGENT_IMAGE_TAG="$2" From 0f4cd3267249023f3a8caef6b28c4480e287cffb Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 14:45:34 -0700 Subject: [PATCH 07/12] minor fix --- hack/Azure/joinMC.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index 4e12b32f..fd5bca75 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -1,5 +1,5 @@ -# CAN ONLY BE RUN AFTER CREATING NEEDED MEMBER CLUSTERS, HUB CLUSTER AND INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER -# This can be achieved by running the script in fleet/hack/Azure/setup/joinHC.sh in the fleet repository +# CAN ONLY BE RUN AFTER CREATING NEEDED MEMBER CLUSTERS, HUB CLUSTER AND INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER. +# This can be achieved by running the script in fleet/hack/Azure/setup/joinHC.sh in the fleet repository. # This script installs the fleet-networking member agents on each member cluster. export REFRESH_TOKEN_IMAGE_TAG="$1" From c9f19ae882951b26ea42b247518f9eb88201219f Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 14:47:57 -0700 Subject: [PATCH 08/12] print the specific member cluster --- hack/Azure/joinMC.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index fd5bca75..e552ea5d 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -71,5 +71,5 @@ helm install member-net-controller-manager ./charts/member-net-controller-manage kubectl get pods -A kubectl config use-context $HUB_CLUSTER_CONTEXT -kubectl get membercluster -A +kubectl get membercluster $MEMBER_CLUSTER done From 557df9e9a63af1325713d89ae11b80e12052c90e Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 14:52:47 -0700 Subject: [PATCH 09/12] remove unnecessary comments --- hack/Azure/joinMC.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index e552ea5d..f95fb0ea 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -1,4 +1,4 @@ -# CAN ONLY BE RUN AFTER CREATING NEEDED MEMBER CLUSTERS, HUB CLUSTER AND INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER. +# CAN ONLY BE RUN AFTER CREATING NEEDED HUB CLUSTER, MEMBER CLUSTERS AND AFTER INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER. # This can be achieved by running the script in fleet/hack/Azure/setup/joinHC.sh in the fleet repository. # This script installs the fleet-networking member agents on each member cluster. @@ -11,7 +11,6 @@ export HUB_CLUSTER_ADDRESS=$(kubectl config view -o jsonpath="{.clusters[?(@.nam for MC in "${@:4}"; do -# Note that Fleet will recognize your cluster with this name once it joins. export MEMBER_CLUSTER=$(kubectl config view -o jsonpath="{.contexts[?(@.context.cluster==\"$MC\")].name}") export MEMBER_CLUSTER_CONTEXT=$(kubectl config view -o jsonpath="{.contexts[?(@.context.cluster==\"$MC\")].name}") @@ -21,13 +20,8 @@ kubectl config use-context $MEMBER_CLUSTER_CONTEXT echo "Apply the Fleet networking CRDs..." kubectl apply -f config/crd/* -# # Install the fleet networking member agent helm charts on the member cluster. - -# The variables below uses the Fleet networking images kept in the Microsoft Container Registry (MCR), -# and will retrieve the latest version from the Fleet GitHub repository. -# -# You can, however, build the Fleet networking images of your own; see the repository README for -# more information. +# # Install the fleet-networking member agent helm charts on the member cluster. +# The variables below uses the fleet-networking images kept in the Microsoft Container Registry (MCR) echo "Retrieving image..." export REGISTRY="mcr.microsoft.com/aks/fleet" export MCS_CONTROLLER_MANAGER_IMAGE="mcs-controller-manager" From d86427f4c23774350bd6b511f2e9b3db6ce996ff Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 14:55:22 -0700 Subject: [PATCH 10/12] fix comment --- hack/Azure/joinMC.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index f95fb0ea..73d6cdf5 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -1,5 +1,5 @@ # CAN ONLY BE RUN AFTER CREATING NEEDED HUB CLUSTER, MEMBER CLUSTERS AND AFTER INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER. -# This can be achieved by running the script in fleet/hack/Azure/setup/joinHC.sh in the fleet repository. +# This can be achieved by running the script in fleet/hack/Azure/setup/joinMC.sh in the fleet repository. # This script installs the fleet-networking member agents on each member cluster. export REFRESH_TOKEN_IMAGE_TAG="$1" From d611e6f7f2214cac072d37869b432bbcb764ac40 Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 15:17:22 -0700 Subject: [PATCH 11/12] add fleet repo link --- hack/Azure/joinMC.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/Azure/joinMC.sh b/hack/Azure/joinMC.sh index 73d6cdf5..fdf59501 100755 --- a/hack/Azure/joinMC.sh +++ b/hack/Azure/joinMC.sh @@ -1,5 +1,5 @@ # CAN ONLY BE RUN AFTER CREATING NEEDED HUB CLUSTER, MEMBER CLUSTERS AND AFTER INSTALLING THE FLEET MEMBER AGENT ON EACH MEMBER CLUSTER. -# This can be achieved by running the script in fleet/hack/Azure/setup/joinMC.sh in the fleet repository. +# This can be achieved by running the script in fleet/hack/Azure/setup/joinMC.sh in the fleet repository https://github.com/Azure/fleet. # This script installs the fleet-networking member agents on each member cluster. export REFRESH_TOKEN_IMAGE_TAG="$1" From 2bd285df9e0fb6b193d9bf86f6f04d321fc55a2a Mon Sep 17 00:00:00 2001 From: Arvind Thirumurugan Date: Thu, 1 Aug 2024 17:50:06 -0700 Subject: [PATCH 12/12] change script directory --- hack/{Azure => membership}/joinMC.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename hack/{Azure => membership}/joinMC.sh (100%) diff --git a/hack/Azure/joinMC.sh b/hack/membership/joinMC.sh similarity index 100% rename from hack/Azure/joinMC.sh rename to hack/membership/joinMC.sh