Skip to content

Commit

Permalink
fine tune the Azure setup (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanzhang-oss authored Jun 13, 2024
1 parent 023ae19 commit a42e0aa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
ms.topic: article
ms.custom: azure-kubernetes-service, devx-track-azurecli
ms.date: 04/19/2024
author: michaelawyu

# Apply Fleet property-based scheduling (preview) on your Azure Kubernetes Service (AKS) cluster

This document explains how to try out the latest Fleet feature, property-based scheduling, using AKS clusters.
Expand Down
15 changes: 9 additions & 6 deletions hack/Azure/setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ run the commands bellow:
```sh
# Replace the value of <AZURE-SUBSCRIPTION-ID> with your Azure subscription ID.
export SUB=<AZURE-SUBSCRIPTION-ID>
export RESOURCE_GROUP=<HUB_RESOURCE_GROUP>
export LOCATION=<HUB_LOCATION>

# Run the script. Be sure to replace the values of <RESOURCE-GROUP-NAME>, <LOCATION>, and <HUB-CLUSTER-NAME> with those of your own.
# Run the script. Be sure to replace the values of <HUB-CLUSTER-NAME> with those of your own.
chmod +x hack/Azure/setup/createHubCluster.sh
./hack/Azure/setup/createHubCluster.sh <RESOURCE-GROUP-NAME> <LOCATION> <HUB-CLUSTER-NAME>
./hack/Azure/setup/createHubCluster.sh <HUB-CLUSTER-NAME>
```

It may take a few minutes for the script to finish running. Once it is completed, verify that the `hub-agent` has been installed:
Expand All @@ -49,9 +51,9 @@ If you would like to add a prometheus server to access metrics, run the followin
2. Install the Prometheus community Helm Chart
```
helm install prom prometheus-community/kube-prometheus-stack -f prom1.yaml
helm install prom prometheus-community/kube-prometheus-stack -f prommethus.yaml
```
The `prom1.yaml` file should contain the following YAML code:
The `prommethus.yaml` file should contain the following YAML code:
```yaml
prometheus:
service:
Expand All @@ -76,13 +78,14 @@ A cluster can join in a hub cluster if:
> Note
>
> To run this script, 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 in the same
> Kubeconfig file as the hub cluster.
>
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:
```sh
# Pass in the hub cluster name and a list of cluster names (separated by a space) as arguments to the script that you would like to
# Pass in the hub cluster name and a list of cluster context 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 test-hub member member2 member3
# Run the script.
Expand Down
4 changes: 1 addition & 3 deletions hack/Azure/setup/createHubCluster.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# This script creates a Hub CLuster from an AKS Cluster (AKS Cluster and Container Registry must be created beforehand).

export RESOURCE_GROUP=$1
export LOCATION=$2
export HUB_CLUSTER=$3
export HUB_CLUSTER=$1

az account set -s ${SUB}
az group create --name $RESOURCE_GROUP --location $LOCATION
Expand Down
7 changes: 5 additions & 2 deletions hack/Azure/setup/joinMC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ metadata:
type: kubernetes.io/service-account-token
EOF

echo "Creating member cluster..."
echo "Creating member cluster CR..."
export TOKEN="$(kubectl get secret $SERVICE_ACCOUNT_SECRET -n fleet-system -o jsonpath='{.data.token}' | base64 --decode)"
cat <<EOF | kubectl apply -f -
apiVersion: cluster.kubernetes-fleet.io/v1beta1
Expand All @@ -49,7 +49,7 @@ spec:
kind: ServiceAccount
namespace: fleet-system
apiGroup: ""
heartbeatPeriodSeconds: 60
heartbeatPeriodSeconds: 15
EOF

# # Install the member agent helm chart on the member cluster.
Expand All @@ -73,6 +73,9 @@ kubectl config use-context $MEMBER_CLUSTER_CONTEXT
echo "Creating secret..."
kubectl create secret generic hub-kubeconfig-secret --from-literal=token=$TOKEN

echo "Uninstalling member-agent..."
helm uninstall member-agent --wait

echo "Installing member-agent..."
helm install member-agent charts/member-agent/ \
--set config.hubURL=$HUB_CLUSTER_ADDRESS \
Expand Down
8 changes: 8 additions & 0 deletions hack/Azure/setup/prommethus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
prometheus:
service:
type: LoadBalancer
prometheusSpec:
additionalScrapeConfigs:
- job_name: "fleet"
static_configs:
- targets: ["<EXTERNAL-IP>:8080"]

0 comments on commit a42e0aa

Please sign in to comment.