Skip to content

Commit 393fbc2

Browse files
committed
rewrite the IPs of the CIDRs
1 parent 20ed0c0 commit 393fbc2

27 files changed

+174
-150
lines changed

Tiltfile

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ def flavors():
312312
os.environ.update({az_key_name: read_file_from_path(default_key_path)})
313313

314314
# Prefer templates/internal if subscription-type is msft
315+
# TODO: improve this subscription type check
315316
template_list = []
316317
if settings.get("subscription-type", "") == "msft":
317-
print("Using Azure subscription type: msft. CAPZ flavors from ./templates/internal will be used.")
318+
print("Using Azure subscription type: corporate. Selecting CAPZ flavors from ./templates/internal .")
318319
template_list = [item for item in listdir("./templates/internal")]
319320
else:
320321
template_list = [item for item in listdir("./templates")]
@@ -343,6 +344,7 @@ def deploy_worker_templates(template, substitutions):
343344
fail(template + " not found")
344345

345346
yaml = str(read_file(template))
347+
parsed_yamls=decode_yaml_stream(yaml)
346348
flavor = os.path.basename(template).replace("cluster-template-", "").replace(".yaml", "")
347349

348350
# for the base cluster-template, flavor is "default"
@@ -396,12 +398,34 @@ def deploy_worker_templates(template, substitutions):
396398
flavor_name = os.path.basename(flavor)
397399
flavor_cmd = "RANDOM=$(bash -c 'echo $RANDOM'); "
398400

401+
402+
if settings.get("subscription-type", "") == "msft":
403+
if apiserver_lb_private_ip != "":
404+
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"" + apiserver_lb_private_ip + "\"; "
405+
else:
406+
azurecluster_doc = None
407+
408+
for d in parsed_yamls:
409+
# Safely handle empty/null documents
410+
if d not None and d.get("kind") == "AzureCluster":
411+
azurecluster_doc = d
412+
break
413+
414+
if azurecluster_doc == None:
415+
fail("No AzureCluster kind found in YAML")
416+
else:
417+
print("Found an AzureCluster doc")
418+
# For example, extract a field:
419+
private_ip = azurecluster_doc["spec"]["networkSpec"]["apiServerLB"]["frontendIPs"][1]["privateIP"]
420+
print("Private IP is:", private_ip)
421+
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"" + private_ip + "\"; "
422+
399423
# TODO: maintain a matrix for flavors and their respective internal LB IPs
400-
apiserver_lb_private_ip = os.getenv("AZURE_INTERNAL_LB_PRIVATE_IP", "")
401-
if "windows-apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
402-
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"40.0.11.100\"; "
403-
elif "apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
404-
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"30.0.11.100\"; "
424+
# apiserver_lb_private_ip = os.getenv("AZURE_INTERNAL_LB_PRIVATE_IP", "")
425+
# if "windows-apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
426+
# flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"40.0.11.100\"; "
427+
# elif "apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
428+
# flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"30.0.11.100\"; "
405429

406430
flavor_cmd += "export CLUSTER_NAME=" + flavor.replace("windows", "win") + "-$RANDOM; echo " + yaml + "> ./.tiltbuild/" + flavor + "; cat ./.tiltbuild/" + flavor + " | " + envsubst_cmd + " | " + kubectl_cmd + " apply -f -; "
407431
flavor_cmd += "echo \"Cluster ${CLUSTER_NAME} created, don't forget to delete\"; "

templates/internal/aad/kustomization.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,41 @@ patches:
1313
patch: |-
1414
- op: replace
1515
path: /spec/template/spec/preKubeadmCommands/0
16-
value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-50.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts
16+
value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-31.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts
1717
options:
1818
allowResourceNotFound: true
1919
- target:
2020
kind: AzureCluster
2121
patch: |-
2222
- op: replace
2323
path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP
24-
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-50.0.0.100}
24+
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-31.0.0.100}
2525
- target:
2626
kind: AzureCluster
2727
patch: |-
2828
- op: replace
2929
path: /spec/networkSpec/vnet/cidrBlocks/0
30-
value: 50.0.0.0/8
30+
value: 31.0.0.0/8
3131
- target:
3232
kind: AzureCluster
3333
patch: |-
3434
- op: replace
3535
path: /spec/networkSpec/subnets/0/cidrBlocks/0
36-
value: 50.0.0.0/16
36+
value: 31.0.0.0/16
3737
- target:
3838
kind: AzureCluster
3939
patch: |-
4040
- op: replace
4141
path: /spec/networkSpec/subnets/1/cidrBlocks/0
42-
value: 50.1.0.0/16
42+
value: 31.1.0.0/16
4343
- target:
4444
kind: KubeadmConfigTemplate
4545
name: .*-md-win
4646
patch: |-
4747
- op: replace
4848
path: /spec/template/spec/preKubeadmCommands/0
4949
value:
50-
powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-50.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"
50+
powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-31.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"
5151
options:
5252
allowResourceNotFound: true
5353

templates/internal/azure-bastion/kustomization.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,41 @@ patches:
1313
patch: |-
1414
- op: replace
1515
path: /spec/template/spec/preKubeadmCommands/0
16-
value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-60.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts
16+
value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-32.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts
1717
options:
1818
allowResourceNotFound: true
1919
- target:
2020
kind: AzureCluster
2121
patch: |-
2222
- op: replace
2323
path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP
24-
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-60.0.0.100}
24+
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-32.0.0.100}
2525
- target:
2626
kind: AzureCluster
2727
patch: |-
2828
- op: replace
2929
path: /spec/networkSpec/vnet/cidrBlocks/0
30-
value: 60.0.0.0/8
30+
value: 32.0.0.0/8
3131
- target:
3232
kind: AzureCluster
3333
patch: |-
3434
- op: replace
3535
path: /spec/networkSpec/subnets/0/cidrBlocks/0
36-
value: 60.0.0.0/16
36+
value: 32.0.0.0/16
3737
- target:
3838
kind: AzureCluster
3939
patch: |-
4040
- op: replace
4141
path: /spec/networkSpec/subnets/1/cidrBlocks/0
42-
value: 60.1.0.0/16
42+
value: 32.1.0.0/16
4343
- target:
4444
kind: KubeadmConfigTemplate
4545
name: .*-md-win
4646
patch: |-
4747
- op: replace
4848
path: /spec/template/spec/preKubeadmCommands/0
4949
value:
50-
powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-60.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"
50+
powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-32.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"
5151
options:
5252
allowResourceNotFound: true
5353

templates/internal/azure-cni-v1/kustomization.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,41 @@ patches:
1313
patch: |-
1414
- op: replace
1515
path: /spec/template/spec/preKubeadmCommands/0
16-
value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-70.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts
16+
value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-33.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts
1717
options:
1818
allowResourceNotFound: true
1919
- target:
2020
kind: AzureCluster
2121
patch: |-
2222
- op: replace
2323
path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP
24-
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-70.0.0.100}
24+
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-33.0.0.100}
2525
- target:
2626
kind: AzureCluster
2727
patch: |-
2828
- op: replace
2929
path: /spec/networkSpec/vnet/cidrBlocks/0
30-
value: 70.0.0.0/8
30+
value: 33.0.0.0/8
3131
- target:
3232
kind: AzureCluster
3333
patch: |-
3434
- op: replace
3535
path: /spec/networkSpec/subnets/0/cidrBlocks/0
36-
value: 70.0.0.0/16
36+
value: 33.0.0.0/16
3737
- target:
3838
kind: AzureCluster
3939
patch: |-
4040
- op: replace
4141
path: /spec/networkSpec/subnets/1/cidrBlocks/0
42-
value: 70.1.0.0/16
42+
value: 33.1.0.0/16
4343
- target:
4444
kind: KubeadmConfigTemplate
4545
name: .*-md-win
4646
patch: |-
4747
- op: replace
4848
path: /spec/template/spec/preKubeadmCommands/0
4949
value:
50-
powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-70.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"
50+
powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-33.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"
5151
options:
5252
allowResourceNotFound: true
5353

templates/internal/cluster-template-aad.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/internal/cluster-template-azure-bastion.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/internal/cluster-template-azure-cni-v1.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/internal/cluster-template-dual-stack.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/internal/cluster-template-edgezone.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/internal/cluster-template-ephemeral.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)