|
| 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