Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
britaniar committed Mar 18, 2024
1 parent e1b07a2 commit e3e0ed4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 69 deletions.
81 changes: 18 additions & 63 deletions hack/setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<YOUR-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=<YOUR-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
Expand Down Expand Up @@ -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 <MEMBER-CLUSTER-NAME1> and <MEMBER-CLUSTER-NAME-2> 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="<MEMBER-CLUSTER-NAME-1> <MEMBER-CLUSTER-NAME-2>"
# 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 <MEMBER-CLUSTER-NAME-1> <MEMBER-CLUSTER-NAME-2>
```
It may take a few minutes for the script to finish running. Once it is completed, verify
Expand All @@ -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.
Expand Down
8 changes: 2 additions & 6 deletions hack/setup/joinMC.sh
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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 <<EOF | kubectl apply -f -
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
Expand Down

0 comments on commit e3e0ed4

Please sign in to comment.