Skip to content

Commit f874c2a

Browse files
GermanCopilot
andcommitted
fix: address PR review feedback for k3s-azure-fleet playground
- Convert ALL_MEMBERS from string to bash array to prevent word-splitting and glob expansion issues when passing cluster names to joinMC.sh - Remove fleet-networking installation since Istio handles all cross-cluster networking (mTLS, service discovery, east-west traffic) per reviewer feedback - Clean up unused FLEET_NET_DIR variable and trap Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 84c30b9 commit f874c2a

1 file changed

Lines changed: 9 additions & 70 deletions

File tree

documentdb-playground/k3s-azure-fleet/setup-fleet.sh

Lines changed: 9 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,21 @@ for cmd in kubectl helm git jq curl; do
3333
done
3434

3535
# Get all member clusters (hub is also a member + k3s clusters)
36-
ALL_MEMBERS="$HUB_CLUSTER_NAME"
36+
ALL_MEMBERS=("$HUB_CLUSTER_NAME")
3737

3838
# Add k3s clusters from deployment info
3939
IFS=' ' read -ra K3S_REGION_ARRAY <<< "$K3S_REGIONS"
4040
for region in "${K3S_REGION_ARRAY[@]}"; do
4141
if kubectl config get-contexts "k3s-$region" &>/dev/null; then
42-
ALL_MEMBERS="$ALL_MEMBERS k3s-$region"
42+
ALL_MEMBERS+=("k3s-$region")
4343
fi
4444
done
4545

46-
echo "Members to join: $ALL_MEMBERS"
46+
echo "Members to join: ${ALL_MEMBERS[*]}"
4747

4848
# Clone KubeFleet repository
4949
KUBFLEET_DIR=$(mktemp -d)
50-
FLEET_NET_DIR=""
51-
trap 'rm -rf "$KUBFLEET_DIR" "$FLEET_NET_DIR"' EXIT
50+
trap 'rm -rf "$KUBFLEET_DIR"' EXIT
5251

5352
echo ""
5453
echo "Cloning KubeFleet repository..."
@@ -94,73 +93,13 @@ echo "✓ Hub-agent installed"
9493
echo ""
9594
echo "Joining member clusters to fleet..."
9695
chmod +x ./hack/membership/joinMC.sh
97-
# Note: $ALL_MEMBERS is intentionally unquoted — joinMC.sh expects individual context names as separate args
98-
./hack/membership/joinMC.sh "$TAG" "$HUB_CLUSTER_NAME" $ALL_MEMBERS
96+
./hack/membership/joinMC.sh "$TAG" "$HUB_CLUSTER_NAME" "${ALL_MEMBERS[@]}"
9997

10098
popd > /dev/null
10199

102-
# Install fleet-networking
103-
echo ""
104-
echo "Setting up fleet-networking..."
105-
FLEET_NET_DIR=$(mktemp -d)
106-
if ! git clone --quiet https://github.com/Azure/fleet-networking.git "$FLEET_NET_DIR"; then
107-
echo "ERROR: Failed to clone fleet-networking repository"
108-
exit 1
109-
fi
110-
111-
pushd "$FLEET_NET_DIR" > /dev/null
112-
113-
NETWORKING_TAG=$(curl -s "https://api.github.com/repos/Azure/fleet-networking/tags" | jq -r '.[0].name')
114-
echo "Using fleet-networking version: $NETWORKING_TAG"
115-
116-
# Install hub-net-controller-manager
117-
kubectl config use-context "$HUB_CLUSTER_NAME"
118-
echo "Installing hub-net-controller-manager..."
119-
120-
helm upgrade --install hub-net-controller-manager ./charts/hub-net-controller-manager/ \
121-
--set fleetSystemNamespace=fleet-system-hub \
122-
--set leaderElectionNamespace=fleet-system-hub \
123-
--set image.tag=$NETWORKING_TAG \
124-
--wait || echo "Warning: hub-net-controller-manager installation may have issues"
125-
126-
HUB_CLUSTER_ADDRESS=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$HUB_CLUSTER_NAME\")].cluster.server}")
127-
128-
# Install networking on each member
129-
for MEMBER_CLUSTER in $ALL_MEMBERS; do
130-
echo ""
131-
echo "Installing fleet-networking on $MEMBER_CLUSTER..."
132-
133-
kubectl config use-context "$MEMBER_CLUSTER"
134-
135-
# Apply CRDs
136-
kubectl apply -f config/crd/ 2>/dev/null || true
137-
138-
# Install mcs-controller-manager
139-
helm upgrade --install mcs-controller-manager ./charts/mcs-controller-manager/ \
140-
--set refreshtoken.repository=$REGISTRY/refresh-token \
141-
--set refreshtoken.tag=$FLEET_TAG \
142-
--set image.tag=$NETWORKING_TAG \
143-
--set image.pullPolicy=Always \
144-
--set refreshtoken.pullPolicy=Always \
145-
--set config.hubURL=$HUB_CLUSTER_ADDRESS \
146-
--set config.memberClusterName=$MEMBER_CLUSTER \
147-
--set enableV1Beta1APIs=true \
148-
--set logVerbosity=5 || echo "Warning: mcs-controller-manager may have issues on $MEMBER_CLUSTER"
149-
150-
# Install member-net-controller-manager
151-
helm upgrade --install member-net-controller-manager ./charts/member-net-controller-manager/ \
152-
--set refreshtoken.repository=$REGISTRY/refresh-token \
153-
--set refreshtoken.tag=$FLEET_TAG \
154-
--set image.tag=$NETWORKING_TAG \
155-
--set image.pullPolicy=Always \
156-
--set refreshtoken.pullPolicy=Always \
157-
--set config.hubURL=$HUB_CLUSTER_ADDRESS \
158-
--set config.memberClusterName=$MEMBER_CLUSTER \
159-
--set enableV1Beta1APIs=true \
160-
--set logVerbosity=5 || echo "Warning: member-net-controller-manager may have issues on $MEMBER_CLUSTER"
161-
done
162-
163-
popd > /dev/null
100+
# Note: fleet-networking is NOT installed because Istio handles all cross-cluster
101+
# networking (mTLS, service discovery, east-west traffic). Installing both would
102+
# create conflicting network configurations.
164103

165104
# Verify fleet status
166105
echo ""
@@ -183,7 +122,7 @@ echo "✅ KubeFleet Setup Complete!"
183122
echo "======================================="
184123
echo ""
185124
echo "Hub: $HUB_CLUSTER_NAME"
186-
echo "Members: $ALL_MEMBERS"
125+
echo "Members: ${ALL_MEMBERS[*]}"
187126
echo ""
188127
echo "Commands:"
189128
echo " kubectl --context $HUB_CLUSTER_NAME get membercluster"

0 commit comments

Comments
 (0)