From 66e5b0d0204571a73552918b8cfcbfa7263d01a3 Mon Sep 17 00:00:00 2001 From: Nawaz Hussain Khazielakha Date: Fri, 27 Dec 2024 13:23:14 -0800 Subject: [PATCH] make private IP of the ILB configurable --- templates/cluster-template-apiserver-ilb.yaml | 4 ++-- templates/cluster-template-windows-apiserver-ilb.yaml | 6 +++--- templates/flavors/apiserver-ilb/patches/control-plane.yaml | 2 +- .../apiserver-ilb/patches/kubeadm-config-template.yaml | 2 +- templates/flavors/windows-apiserver-ilb/kustomization.yaml | 6 +++--- .../patches/kubeadm-config-template.yaml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/templates/cluster-template-apiserver-ilb.yaml b/templates/cluster-template-apiserver-ilb.yaml index 825c65046a1..fee9a9cadac 100644 --- a/templates/cluster-template-apiserver-ilb.yaml +++ b/templates/cluster-template-apiserver-ilb.yaml @@ -36,7 +36,7 @@ spec: dnsName: ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com name: ${CLUSTER_NAME}-api-lb - name: ${CLUSTER_NAME}-internal-lb-private-ip - privateIP: ${APISERVER_ILB_PRIVATE_IP:-30.0.0.100} + privateIP: ${AZURE_INTERNAL_LB_PRIVATE_IP:-30.0.0.100} subnets: - cidrBlocks: - 30.0.0.0/16 @@ -204,7 +204,7 @@ spec: cloud-provider: external name: '{{ ds.meta_data["local_hostname"] }}' preKubeadmCommands: - - echo '${APISERVER_ILB_PRIVATE_IP:-30.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' + - echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-30.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 diff --git a/templates/cluster-template-windows-apiserver-ilb.yaml b/templates/cluster-template-windows-apiserver-ilb.yaml index c3e75bdd128..80b9470222a 100644 --- a/templates/cluster-template-windows-apiserver-ilb.yaml +++ b/templates/cluster-template-windows-apiserver-ilb.yaml @@ -40,7 +40,7 @@ spec: dnsName: ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com name: ${CLUSTER_NAME}-api-lb - name: ${CLUSTER_NAME}-internal-lb-private-ip - privateIP: ${APISERVER_ILB_PRIVATE_IP:-40.0.0.100} + privateIP: ${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} subnets: - cidrBlocks: - 40.0.0.0/16 @@ -208,7 +208,7 @@ spec: cloud-provider: external name: '{{ ds.meta_data["local_hostname"] }}' preKubeadmCommands: - - echo '${APISERVER_ILB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' + - echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts --- apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 @@ -306,7 +306,7 @@ spec: - powershell C:/defender-exclude-calico.ps1 preKubeadmCommands: - powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' - -Value '${APISERVER_ILB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'" + -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'" users: - groups: Administrators name: capi diff --git a/templates/flavors/apiserver-ilb/patches/control-plane.yaml b/templates/flavors/apiserver-ilb/patches/control-plane.yaml index 3d954fc8584..9e41e78b75a 100644 --- a/templates/flavors/apiserver-ilb/patches/control-plane.yaml +++ b/templates/flavors/apiserver-ilb/patches/control-plane.yaml @@ -13,7 +13,7 @@ spec: name: ${CLUSTER_NAME}-api-lb dnsName: ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com - name: ${CLUSTER_NAME}-internal-lb-private-ip - privateIP: 30.0.0.100 + privateIP: ${AZURE_INTERNAL_LB_PRIVATE_IP:-30.0.0.100} vnet: cidrBlocks: - 30.0.0.0/8 diff --git a/templates/flavors/apiserver-ilb/patches/kubeadm-config-template.yaml b/templates/flavors/apiserver-ilb/patches/kubeadm-config-template.yaml index 84c9cd4d07f..3b657cc407b 100644 --- a/templates/flavors/apiserver-ilb/patches/kubeadm-config-template.yaml +++ b/templates/flavors/apiserver-ilb/patches/kubeadm-config-template.yaml @@ -9,4 +9,4 @@ spec: # This custom DNS Resolution of the API server ensures that the worker nodes can reach the API server when # the public IP of the API server is not accessible. preKubeadmCommands: - - echo '30.0.0.100 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts + - echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-30.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts diff --git a/templates/flavors/windows-apiserver-ilb/kustomization.yaml b/templates/flavors/windows-apiserver-ilb/kustomization.yaml index 83f7ba8fe03..bb1a5e96279 100644 --- a/templates/flavors/windows-apiserver-ilb/kustomization.yaml +++ b/templates/flavors/windows-apiserver-ilb/kustomization.yaml @@ -14,13 +14,13 @@ patches: patch: |- - op: replace path: /spec/template/spec/preKubeadmCommands/0 - value: echo '40.0.0.100 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts + value: echo '${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts - target: kind: AzureCluster patch: |- - op: replace path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP - value: 40.0.11.100 + value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} - target: kind: AzureCluster patch: |- @@ -46,7 +46,7 @@ patches: - op: replace path: /spec/template/spec/preKubeadmCommands/0 value: - powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '40.0.0.100 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'" + powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'" sortOptions: order: fifo diff --git a/templates/flavors/windows-apiserver-ilb/patches/kubeadm-config-template.yaml b/templates/flavors/windows-apiserver-ilb/patches/kubeadm-config-template.yaml index 3509792752a..cb22f9843db 100644 --- a/templates/flavors/windows-apiserver-ilb/patches/kubeadm-config-template.yaml +++ b/templates/flavors/windows-apiserver-ilb/patches/kubeadm-config-template.yaml @@ -9,4 +9,4 @@ spec: # so that worker nodes can access the API server using the internal IP. # 10.0.0.100 is the default IP that gets assigned to a internal load balancer. preKubeadmCommands: - - powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '10.0.0.100 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'" + - powershell -Command "Add-Content -Path 'C:\\Windows\\System32\\drivers\\etc\\hosts' -Value '${AZURE_INTERNAL_LB_PRIVATE_IP:-40.0.0.100} ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com'"