-
Notifications
You must be signed in to change notification settings - Fork 14
Add region playground #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alaye-ms
wants to merge
8
commits into
documentdb:main
Choose a base branch
from
alaye-ms:addRegionPlayground
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f57f313
update readme and deployment
alaye-ms dcfa735
bugfix: don't create cluster when not in crd
alaye-ms b8c1d8a
fix hub/member service conflicts
alaye-ms 4aad5db
Delete MCS when region is removed
alaye-ms e440e3e
GPT5.2-codex review comments
alaye-ms b817d65
remove token from logs
alaye-ms a156930
Move constant to proper file
alaye-ms 8860648
check update
alaye-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
documentdb-playground/aks-fleet-deployment/parameters.bicepparam
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||
| # Fleet Add Region Playground | ||||||
|
|
||||||
| This playground focuses on exercising DocumentDB across changing fleet shapes. | ||||||
| It builds on the AKS Fleet Deployment playground (shared Bicep templates and | ||||||
| install scripts) but layers extra tooling to: add a region, remove a region, | ||||||
| verify wiring, and iterate rapidly on those flows before changes graduate to | ||||||
|
||||||
| verify wiring, and iterate rapidly on those flows before changes graduate to | |
| verify configuration and connectivity, and iterate rapidly on those flows before changes graduate to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| RESOURCE_GROUP="${RESOURCE_GROUP:-documentdb-aks-fleet-rg}" | ||
| HUB_REGION="${HUB_REGION:-westus3}" | ||
| PRIMARY_REGION="${PRIMARY_REGION:-eastus2}" | ||
| EXCLUDE_REGION="${EXCLUDE_REGION:-westus2}" | ||
|
|
||
| # Dynamically get member clusters from Azure | ||
| echo "Discovering member clusters in resource group: $RESOURCE_GROUP..." | ||
| MEMBER_CLUSTERS=$(az aks list -g "$RESOURCE_GROUP" -o json | jq -r '.[] | select(.name|startswith("member-")) | .name' | sort) | ||
|
|
||
| if [ -z "$MEMBER_CLUSTERS" ]; then | ||
| echo "Error: No member clusters found in resource group $RESOURCE_GROUP" | ||
| echo "Please ensure the fleet is deployed first" | ||
| exit 1 | ||
| fi | ||
|
|
||
| CLUSTER_ARRAY=($MEMBER_CLUSTERS) | ||
| echo "Found ${#CLUSTER_ARRAY[@]} member clusters:" | ||
| EXCLUDE_CLUSTER="" | ||
| for cluster in "${CLUSTER_ARRAY[@]}"; do | ||
| echo " - $cluster" | ||
| if [[ "$cluster" == *"$HUB_REGION"* ]]; then HUB_CLUSTER="$cluster"; fi | ||
| if [[ "$cluster" == *"$EXCLUDE_REGION"* ]]; then EXCLUDE_CLUSTER="$cluster"; fi | ||
| if [[ "$cluster" == *"$PRIMARY_REGION"* ]]; then PRIMARY_CLUSTER="$cluster"; fi | ||
| done | ||
|
|
||
| # Build the cluster list YAML with proper indentation | ||
| CLUSTER_LIST="" | ||
| CLUSTER_LIST_CRP="" | ||
| for cluster in "${CLUSTER_ARRAY[@]}"; do | ||
| if [ "$cluster" == "$EXCLUDE_CLUSTER" ]; then | ||
| echo "Including cluster $cluster in DocumentDB configuration" | ||
| fi | ||
| if [ -z "$CLUSTER_LIST" ]; then | ||
| CLUSTER_LIST=" - name: ${cluster}" | ||
| CLUSTER_LIST="${CLUSTER_LIST}"$'\n'" environment: aks" | ||
| CLUSTER_LIST_CRP=" - ${cluster}" | ||
| else | ||
| CLUSTER_LIST="${CLUSTER_LIST}"$'\n'" - name: ${cluster}" | ||
| CLUSTER_LIST="${CLUSTER_LIST}"$'\n'" environment: aks" | ||
| CLUSTER_LIST_CRP="${CLUSTER_LIST_CRP}"$'\n'" - ${cluster}" | ||
| fi | ||
| done | ||
|
|
||
| TEMP_YAML=$(mktemp) | ||
|
|
||
| # Use sed for safer substitution | ||
| sed -e "s/{{DOCUMENTDB_PASSWORD}}/$DOCUMENTDB_PASSWORD/g" \ | ||
| -e "s/{{PRIMARY_CLUSTER}}/$PRIMARY_CLUSTER/g" \ | ||
| "$SCRIPT_DIR/documentdb-resource-crp.yaml" | \ | ||
| while IFS= read -r line; do | ||
| if [[ "$line" == '{{CLUSTER_LIST}}' ]]; then | ||
| echo "$CLUSTER_LIST" | ||
| elif [[ "$line" == '{{CLUSTER_LIST_CRP}}' ]]; then | ||
| echo "$CLUSTER_LIST_CRP" | ||
| else | ||
| echo "$line" | ||
| fi | ||
| done > "$TEMP_YAML" | ||
|
|
||
| echo "" | ||
| echo "Applying DocumentDB multi-region configuration..." | ||
|
|
||
| MAX_RETRIES=60 | ||
| RETRY_INTERVAL=3 | ||
| RETRY_COUNT=0 | ||
|
|
||
| while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do | ||
| kubectl --context "$HUB_CLUSTER" apply -f "$TEMP_YAML" &> /dev/null | ||
|
|
||
| echo "Checking if $EXCLUDE_CLUSTER has been added to clusterReplication on the excluded cluster..." | ||
|
|
||
| # Get the clusterReplication.clusters field from the DocumentDB object on the excluded cluster | ||
| CLUSTER_LIST_JSON=$(kubectl --context "$EXCLUDE_CLUSTER" get documentdb documentdb-preview -n documentdb-preview-ns -o jsonpath='{.spec.clusterReplication.clusterList[*].name}' 2>/dev/null) | ||
|
|
||
| if echo "$CLUSTER_LIST_JSON" | grep -q "$EXCLUDE_CLUSTER"; then | ||
| echo "Success: $EXCLUDE_CLUSTER is now included in clusterReplication field" | ||
| break | ||
| fi | ||
|
|
||
| RETRY_COUNT=$((RETRY_COUNT + 1)) | ||
| echo "Cluster not yet in clusterReplication (attempt $RETRY_COUNT/$MAX_RETRIES). Retrying in ${RETRY_INTERVAL}s..." | ||
| sleep $RETRY_INTERVAL | ||
| done | ||
|
|
||
| if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then | ||
| echo "Error: Timed out waiting for $EXCLUDE_CLUSTER to appear in clusterReplication" | ||
| exit 1 | ||
| fi | ||
|
|
||
| rm -f "$TEMP_YAML" | ||
| echo "Done." |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.