From 196dc2daa14994d2195f5dec450d37d394d9cd74 Mon Sep 17 00:00:00 2001 From: Nawaz Hussain Khazielakha Date: Wed, 13 Nov 2024 00:44:47 -0800 Subject: [PATCH] update default template --- templates/cluster-template.yaml | 15 +++++++-- templates/flavors/default/kustomization.yaml | 4 +-- .../azure-cluster-vnet-subnet-cidrs.yaml | 31 +++++++++++++++++++ .../kubeadm-config-template-worker-node.yaml | 13 ++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 templates/flavors/default/patches/azure-cluster-vnet-subnet-cidrs.yaml create mode 100644 templates/flavors/default/patches/kubeadm-config-template-worker-node.yaml diff --git a/templates/cluster-template.yaml b/templates/cluster-template.yaml index a18b181f968..785ce8de299 100644 --- a/templates/cluster-template.yaml +++ b/templates/cluster-template.yaml @@ -35,12 +35,23 @@ spec: publicIP: dnsName: ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com name: ${CLUSTER_NAME}-api-lb + - name: ${CLUSTER_NAME}-internal-lb-ip + privateIP: 10.0.0.100 subnets: - - name: control-plane-subnet + - cidrBlocks: + - 10.0.0.0/24 + - 10.0.1.0/24 + name: control-plane-subnet role: control-plane - - name: node-subnet + - cidrBlocks: + - 10.0.2.0/24 + - 10.0.3.0/24 + - 10.0.4.0/24 + name: node-subnet role: node vnet: + cidrBlocks: + - 10.0.0.0/16 name: ${AZURE_VNET_NAME:=${CLUSTER_NAME}-vnet} resourceGroup: ${AZURE_RESOURCE_GROUP:=${CLUSTER_NAME}} subscriptionID: ${AZURE_SUBSCRIPTION_ID} diff --git a/templates/flavors/default/kustomization.yaml b/templates/flavors/default/kustomization.yaml index eb0e4743560..73db52cf938 100644 --- a/templates/flavors/default/kustomization.yaml +++ b/templates/flavors/default/kustomization.yaml @@ -8,8 +8,8 @@ resources: patches: - path: ../../azure-cluster-identity/azurecluster-identity-ref.yaml -- path: ../../internal-load-balancer/azure-cluster-frontend-ip.yaml -- path: ../../internal-load-balancer/kubeadm-config-template-worker-node.yaml +- path: patches/azure-cluster-vnet-subnet-cidrs.yaml +- path: patches/kubeadm-config-template-worker-node.yaml sortOptions: order: fifo diff --git a/templates/flavors/default/patches/azure-cluster-vnet-subnet-cidrs.yaml b/templates/flavors/default/patches/azure-cluster-vnet-subnet-cidrs.yaml new file mode 100644 index 00000000000..e3c87604735 --- /dev/null +++ b/templates/flavors/default/patches/azure-cluster-vnet-subnet-cidrs.yaml @@ -0,0 +1,31 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureCluster +metadata: + name: ${CLUSTER_NAME} +spec: + networkSpec: + apiServerLB: + # We pre-create this public IP and the DNS name to use it in the + # worker node's /etc/hosts. + frontendIPs: + - name: ${CLUSTER_NAME}-api-lb + publicIP: + name: ${CLUSTER_NAME}-api-lb + dnsName: ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com + - name: ${CLUSTER_NAME}-internal-lb-ip + privateIP: 10.0.0.100 + vnet: + cidrBlocks: + - 10.0.0.0/16 + subnets: + - name: control-plane-subnet + role: control-plane + cidrBlocks: + - 10.0.0.0/24 + - 10.0.1.0/24 + - name: node-subnet + role: node + cidrBlocks: + - 10.0.2.0/24 + - 10.0.3.0/24 + - 10.0.4.0/24 diff --git a/templates/flavors/default/patches/kubeadm-config-template-worker-node.yaml b/templates/flavors/default/patches/kubeadm-config-template-worker-node.yaml new file mode 100644 index 00000000000..6f5dc9a772c --- /dev/null +++ b/templates/flavors/default/patches/kubeadm-config-template-worker-node.yaml @@ -0,0 +1,13 @@ +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: KubeadmConfigTemplate +metadata: + name: "${CLUSTER_NAME}-md-0" +spec: + template: + spec: + # /etc/hosts file is updated with a pre-created DNS name of the API server and internal load-balancer's IP. + # 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. + # 10.0.0.100 is the default IP that gets assigned to an internal load balancer. + preKubeadmCommands: + - echo '10.0.0.100 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com' >> /etc/hosts