From e3e0ed424c2fee02ef38700a4d5bdbd7fff2ec63 Mon Sep 17 00:00:00 2001 From: Britania Rodriguez Reyes Date: Mon, 18 Mar 2024 13:39:31 -0700 Subject: [PATCH] address comments --- hack/setup/README.md | 81 ++++++++++---------------------------------- hack/setup/joinMC.sh | 8 ++--- 2 files changed, 20 insertions(+), 69 deletions(-) diff --git a/hack/setup/README.md b/hack/setup/README.md index e6ea12834..e21a9be6d 100644 --- a/hack/setup/README.md +++ b/hack/setup/README.md @@ -15,22 +15,28 @@ This how-to guide discusses how to create a fleet, specifically: > * `curl` > * `jq` > * `base64` +> +> +> Also, make sure that you have already cloned the repo and are in the root directory. +> * `git clone https://github.com/Azure/fleet.git` +> * `cd fleet` + +## Create a hub cluster from an AKS Cluster +> Note +> +> Make sure you have already created an AKS cluster and have gotten its credentials. +> Instructions to create an AKS cluster can be found [here](https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-cli). +> -## Create a hub cluster from a cluster For your convenience, Fleet provides a script that can automate the process of creating a hub cluster. To use script, run the commands bellow: ```sh # Replace the value of HUB_CLUSTER_CONTEXT with the name of the kubeconfig context you use for # accessing your hub cluster. export HUB_CLUSTER_CONTEXT= -# Replace the value of HUB_CLUSTER_ADDRESS with the address of your hub cluster API server. +# Replace the value of HUB_CLUSTER_ADDRESS with the address of your hub cluster API server located in the kubeconfig file. export HUB_CLUSTER_ADDRESS= -# Clone the Fleet GitHub repository, if necessary. -git clone https://github.com/Azure/fleet.git -# Go into fleet directory. -cd fleet - # Run the script. chmod +x hack/setup/createHubCluster.sh ./hack/setup/createHubCluster.sh @@ -78,33 +84,18 @@ A cluster can join in a hub cluster if: > Note > -> To run these scripts, make sure you have already created cluster(s) and gotten their credentials. +> To run this script, make sure you have already created cluster(s) and gotten their credentials. > For your convenience, Fleet provides a script that can automate the process of joining a cluster onto a hub cluster. To use the script, run the commands below after creating needed AKS clusters: - -In `joinMC.sh` file line 4, replace current values of `MC_NAMES` with the names of the AKS cluster you want to join. ```sh -# Replace the value of HUB_CLUSTER_CONTEXT with the name of the kubeconfig context you use for -# accessing your hub cluster. -export HUB_CLUSTER_CONTEXT=YOUR-HUB-CLUSTER-CONTEXT -# Replace the value of HUB_CLUSTER_ADDRESS with the address of your hub cluster API server. -export HUB_CLUSTER_ADDRESS=YOUR-HUB-CLUSTER-ADDRESS - -# Replace and with a list of cluster names (separated by a space as a string) -# that you would like to join the fleet as member clusters. Their context will be used to access the cluster. -# Ex.: export MC_NAMES_STR="member member2" -export MC_NAMES_STR=" " - -# Clone the Fleet GitHub repository, if necessary. -git clone https://github.com/Azure/fleet.git -# Go into fleet directory. -cd fleet - +# Pass in a list of cluster names (separated by a space) as arguments to the script that you would like to +# join the fleet as member clusters. Their context will be used to access the cluster. +# Ex.: ./hack/setup/joinMC.sh member member2 member3 member4 # Run the script. chmod +x hack/setup/joinMC.sh -./hack/setup/joinMC.sh +./hack/setup/joinMC.sh ``` It may take a few minutes for the script to finish running. Once it is completed, verify @@ -120,42 +111,6 @@ is still connecting to the hub cluster. Should this state persist for a prolonge period, refer to the [Troubleshooting Guide](../../docs/troubleshooting/README.md) for more information. -### Viewing the status of a member cluster - -Similarly, you can use the `MemberCluster` API in the hub cluster to view the status of a -member cluster: - -```sh -# Replace the value of MEMBER-CLUSTER with the name of the member cluster of which you would like -# to view the status. -export MEMBER_CLUSTER=YOUR-MEMBER-CLUSTER -kubectl get membercluster $MEMBER_CLUSTER -o jsonpath="{.status}" -``` - -The status consists of: - -* an array of conditions, including: - - * the `ReadyToJoin` condition, which signals whether the hub cluster is ready to accept - the member cluster; and - * the `Joined` condition, which signals whether the cluster has joined the fleet; and - * the `Healthy` condition, which signals whether the cluster is in a healthy state. - - Typically, a member cluster should have all three conditions set to true. Refer to the - [Troubleshooting Guide](../../docs/troubleshooting/README.md) for help if a cluster fails to join - into a fleet. - -* the resource usage of the cluster; at this moment Fleet reports the capacity and - the allocatable amount of each resource in the cluster, summed up from all nodes in the cluster. - -* an array of agent status, which reports the status of specific Fleet agents installed in - the cluster; each entry features: - - * an array of conditions, in which `Joined` signals whether the specific agent has been - successfully installed in the cluster, and `Healthy` signals whether the agent is in a - healthy state; and - * the timestamp of the last received heartbeat from the agent. - ## Adding labels to a member cluster You can add labels to a `MemberCluster` object in the same as with any other Kubernetes object. diff --git a/hack/setup/joinMC.sh b/hack/setup/joinMC.sh index b07f6ee0e..62e999213 100644 --- a/hack/setup/joinMC.sh +++ b/hack/setup/joinMC.sh @@ -1,11 +1,7 @@ # CAN ONLY BE RUN AFTER CREATING NEEDED AKS CLUSTERS AND HUB CLUSTER. This script creates member clusters from # AKS Cluster's and joins them onto the hub cluster. -# Convert the string to an array -MC_NAMES=($MC_NAMES_STR) - -for MC in "${MC_NAMES[@]}"; do - +for MC in "$@"; do # Note that Fleet will recognize your cluster with this name once it joins. export MEMBER_CLUSTER=${MC} export MEMBER_CLUSTER_CONTEXT=${MC} @@ -24,7 +20,7 @@ kubectl create serviceaccount $SERVICE_ACCOUNT -n fleet-system echo "Creating member service account secret..." export SERVICE_ACCOUNT_SECRET="$MEMBER_CLUSTER-hub-cluster-access-token" -cat <