Skip to content

Commit 642e881

Browse files
committed
clustermesh script
1 parent 055ff30 commit 642e881

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

hack/aks/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ overlay-net-up: ## Create vnet, nodenet subnets
121121
$(AZCLI) network vnet create -g $(GROUP) -l $(REGION) --name $(VNET) --address-prefixes 10.0.0.0/8 -o none
122122
$(AZCLI) network vnet subnet create -g $(GROUP) --vnet-name $(VNET) --name nodenet --address-prefix 10.10.0.0/16 -o none
123123

124+
cilium-net-up: ## Create vnet, nodenet and podnet subnets
125+
$(AZCLI) network vnet create -g $(GROUP) -l $(REGION) --name $(VNET) --address-prefixes $(VNET_PREFIX) -o none
126+
$(AZCLI) network vnet subnet create -g $(GROUP) --vnet-name $(VNET) --name nodenet --address-prefixes $(NODE_SUBNET_PREFIX) -o none
127+
$(AZCLI) network vnet subnet create -g $(GROUP) --vnet-name $(VNET) --name podnet --address-prefixes $(POD_SUBNET_PREFIX) -o none
128+
124129
##@ AKS Clusters
125130

126131
byocni-up: swift-byocni-up ## Alias to swift-byocni-up
@@ -258,6 +263,26 @@ swift-byocni-nokubeproxy-up: rg-up ipv4 swift-net-up ## Bring up a SWIFT BYO CNI
258263
--yes
259264
@$(MAKE) set-kubeconf
260265

266+
cilium-clustermesh-byocni-nokubeproxy-up: rg-up cilium-net-up ## Bring up a Cilium BYO CNI cluster without kube-proxy
267+
$(AZCLI) aks create -n $(CLUSTER) -g $(GROUP) -l $(REGION) \
268+
--auto-upgrade-channel $(AUTOUPGRADE) \
269+
--node-os-upgrade-channel $(NODEUPGRADE) \
270+
--kubernetes-version $(K8S_VER) \
271+
--node-count $(NODE_COUNT) \
272+
--node-vm-size $(VM_SIZE) \
273+
--load-balancer-sku basic \
274+
--network-plugin none \
275+
--pod-cidr $(POD_CIDR) \
276+
--service-cidr $(SVC_CIDR) \
277+
--dns-service-ip $(DNS_IP) \
278+
--vnet-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/nodenet \
279+
--pod-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/podnet \
280+
--no-ssh-key \
281+
--os-sku $(OS_SKU) \
282+
--kube-proxy-config ./kube-proxy.json \
283+
--yes
284+
@$(MAKE) set-kubeconf
285+
261286
swift-cilium-up: rg-up ipv4 swift-net-up ## Bring up a SWIFT Cilium cluster
262287
$(AZCLI) aks create -n $(CLUSTER) -g $(GROUP) -l $(REGION) \
263288
--auto-upgrade-channel $(AUTOUPGRADE) \
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
# Requires
3+
# sufix1 - unique single digit whole number 1-9. Cannot match sufix2
4+
# sufix2 - unique single digit whole number 1-9. Cannot match sufix1
5+
# SUB - GUID for subscription
6+
# clusterType - cilium-clustermesh-byocni-nokubeproxy-up is primary atm, but leaving for testing later.
7+
# Example command: clusterPrefix=isaiahraya sufix1=1 sufix2=2 SUB=d9eabe18-12f6-4421-934a-d7e2327585f5 clusterType=cilium-clustermesh-byocni-nokubeproxy-up ./enable-cilium-cluster-mesh.sh
8+
9+
sufixes="${sufix1} ${sufix2}"
10+
install=helm
11+
echo "sufixes ${sufixes}"
12+
13+
cd ../..
14+
for unique in $sufixes; do
15+
make -C ./hack/aks $clusterType \
16+
AZCLI=az REGION=westus2 SUB=$SUB \
17+
CLUSTER=${clusterPrefix}-${unique} \
18+
POD_CIDR=192.${unique}0.0.0/16 SVC_CIDR=192.${unique}1.0.0/16 DNS_IP=192.${unique}1.0.10 \
19+
VNET_PREFIX=10.${unique}0.0.0/16 NODE_SUBNET_PREFIX=10.${unique}0.0.0/17 POD_SUBNET_PREFIX=10.${unique}0.128.0/17
20+
21+
kubectl config use-context ${clusterPrefix}-${unique}
22+
23+
if [ $install == "helm" ]; then
24+
helm upgrade --install -n kube-system cilium cilium/cilium \
25+
--version v1.16.1 \
26+
--set cluster.name=${clusterPrefix}-${unique} \
27+
--set azure.resourceGroup=${clusterPrefix}-${unique}-rg \
28+
--set cluster.id=${unique} \
29+
--set ipam.operator.clusterPoolIPv4PodCIDRList='{192.'${unique}'0.0.0/16}' \
30+
--set hubble.enabled=false \
31+
--set envoy.enabled=false
32+
fi
33+
done
34+
35+
cd hack/scripts
36+
37+
VNET_ID1=$(az network vnet show \
38+
--resource-group "${clusterPrefix}-${sufix1}-rg" \
39+
--name "${clusterPrefix}-${sufix1}-vnet" \
40+
--query id -o tsv)
41+
42+
VNET_ID2=$(az network vnet show \
43+
--resource-group "${clusterPrefix}-${sufix2}-rg" \
44+
--name "${clusterPrefix}-${sufix2}-vnet" \
45+
--query id -o tsv)
46+
47+
az network vnet peering create \
48+
-g "${clusterPrefix}-${sufix1}-rg" \
49+
--name "peering-${clusterPrefix}-${sufix1}-to-${clusterPrefix}-${sufix2}" \
50+
--vnet-name "${clusterPrefix}-${sufix1}-vnet" \
51+
--remote-vnet "${VNET_ID2}" \
52+
--allow-vnet-access
53+
54+
az network vnet peering create \
55+
-g "${clusterPrefix}-${sufix2}-rg" \
56+
--name "peering-${clusterPrefix}-${sufix2}-to-${clusterPrefix}-${sufix1}" \
57+
--vnet-name "${clusterPrefix}-${sufix2}-vnet" \
58+
--remote-vnet "${VNET_ID1}" \
59+
--allow-vnet-access
60+
61+
62+
cilium clustermesh enable --context ${clusterPrefix}-${sufix1} --enable-kvstoremesh=true
63+
cilium clustermesh enable --context ${clusterPrefix}-${sufix2} --enable-kvstoremesh=true
64+
65+
66+
cilium clustermesh status --context ${clusterPrefix}-${sufix1} --wait
67+
cilium clustermesh status --context ${clusterPrefix}-${sufix2} --wait
68+
69+
# # CA is passed between clusters in this step
70+
cilium clustermesh connect --context ${clusterPrefix}-${sufix1} --destination-context ${clusterPrefix}-${sufix2}
71+
72+
# For 3+ clusters
73+
# cilium clustermesh connect --context ${clusterPrefix}-${sufix1} --destination-context ${clusterPrefix}-${sufix2} --connection-mode mesh
74+
# These can be run in parallel in different bash shells

0 commit comments

Comments
 (0)