Skip to content

Commit 6865e29

Browse files
committed
adding apiserver ilb soln to self-managed flavors
1 parent c725b38 commit 6865e29

38 files changed

+5013
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ARG ARCH
1919

2020
# Build the manager binary
21-
FROM golang:1.22 AS builder
21+
FROM golang:1.22.11 AS builder
2222
WORKDIR /workspace
2323

2424
# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,10 @@ test-cover: test ## Run tests with code coverage and generate reports.
726726
.PHONY: create-bootstrap
727727
create-bootstrap: $(KUBECTL) ## Create capz kind bootstrap cluster.
728728
if [ "$(MGMT_CLUSTER_TYPE)" == "aks" ]; then \
729-
MGMT_CLUSTER_NAME=capz-e2e-4 \
730-
AKS_RESOURCE_GROUP=capz-e2e-4 \
731-
AKS_MGMT_VNET_NAME=capz-e2e-4-mgmt-vnet \
732-
AKS_MGMT_SUBNET_NAME=capz-e2e-4-mgmt-subnet \
729+
MGMT_CLUSTER_NAME=capz-e2e-6 \
730+
AKS_RESOURCE_GROUP=capz-e2e-6 \
731+
AKS_MGMT_VNET_NAME=capz-e2e-6-mgmt-vnet \
732+
AKS_MGMT_SUBNET_NAME=capz-e2e-6-mgmt-subnet \
733733
./scripts/aks-as-mgmt.sh; \
734734
else \
735735
KIND_CLUSTER_NAME=capz-e2e ./scripts/kind-with-registry.sh; \

Tiltfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,14 @@ def flavors():
311311
os.environ.update({az_key_b64_name: base64_encode_file(default_key_path)})
312312
os.environ.update({az_key_name: read_file_from_path(default_key_path)})
313313

314-
template_list = [item for item in listdir("./templates")]
314+
# Prefer templates/internal if subscription-type is msft
315+
template_list = []
316+
if settings.get("subscription-type", "") == "msft":
317+
print("Using Azure subscription type: msft. CAPZ flavors from ./templates/internal will be used.")
318+
template_list = [item for item in listdir("./templates/internal")]
319+
else:
320+
template_list = [item for item in listdir("./templates")]
321+
315322
template_list = [template for template in template_list if os.path.basename(template).endswith("yaml")]
316323

317324
for template in template_list:
@@ -389,6 +396,7 @@ def deploy_worker_templates(template, substitutions):
389396
flavor_name = os.path.basename(flavor)
390397
flavor_cmd = "RANDOM=$(bash -c 'echo $RANDOM'); "
391398

399+
# TODO: maintain a matrix for flavors and their respective internal LB IPs
392400
apiserver_lb_private_ip = os.getenv("AZURE_INTERNAL_LB_PRIVATE_IP", "")
393401
if "windows-apiserver-ilb" in flavor and apiserver_lb_private_ip == "":
394402
flavor_cmd += "export AZURE_INTERNAL_LB_PRIVATE_IP=\"40.0.11.100\"; "

config/capz/manager_image_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ spec:
88
spec:
99
containers:
1010
# Change the value of image field below to your controller image URL
11-
- image: gcr.io/k8s-staging-cluster-api-azure/cluster-api-azure-controller:main
11+
- image: nhkregistry.azurecr.io/cluster-api-azure-controller-amd64:20250204005305
1212
name: manager

config/capz/manager_pull_policy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ spec:
88
spec:
99
containers:
1010
- name: manager
11-
imagePullPolicy: Always
11+
imagePullPolicy: IfNotPresent

hack/gen-flavors.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ make --directory="${REPO_ROOT}" "${KUSTOMIZE##*/}"
2727
flavors_dir="${REPO_ROOT}/templates/flavors/"
2828
ci_dir="${REPO_ROOT}/templates/test/ci/"
2929
dev_dir="${REPO_ROOT}/templates/test/dev/"
30+
internal_dir="${REPO_ROOT}/templates/internal/"
3031

3132
for name in $(find "${flavors_dir}"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {} | grep -v base); do
3233
${KUSTOMIZE} build --load-restrictor LoadRestrictionsNone "${flavors_dir}${name}" > "${REPO_ROOT}/templates/cluster-template-${name}.yaml"
@@ -41,3 +42,8 @@ done
4142
for name in $(find "${dev_dir}"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {} | grep -v patches); do
4243
${KUSTOMIZE} build --load-restrictor LoadRestrictionsNone "${dev_dir}${name}" > "${dev_dir}cluster-template-${name}.yaml"
4344
done
45+
46+
for name in $(find "${internal_dir}"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {} | grep -v base); do
47+
${KUSTOMIZE} build --load-restrictor LoadRestrictionsNone "${internal_dir}${name}" > "${REPO_ROOT}/templates/internal/cluster-template-${name}.yaml"
48+
done
49+
mv "${REPO_ROOT}/templates/internal/cluster-template-default.yaml" "${REPO_ROOT}/templates/internal/cluster-template.yaml"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: default
4+
resources:
5+
- ../../flavors/aad
6+
7+
patches:
8+
- path: ../../flavors/apiserver-ilb/patches/kubeadm-config-template.yaml
9+
- path: ../../flavors/apiserver-ilb/patches/control-plane.yaml
10+
- target:
11+
kind: KubeadmConfigTemplate
12+
name: .*-md-0
13+
patch: |-
14+
- op: replace
15+
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
17+
options:
18+
allowResourceNotFound: true
19+
- target:
20+
kind: AzureCluster
21+
patch: |-
22+
- op: replace
23+
path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP
24+
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-50.0.0.100}
25+
- target:
26+
kind: AzureCluster
27+
patch: |-
28+
- op: replace
29+
path: /spec/networkSpec/vnet/cidrBlocks/0
30+
value: 50.0.0.0/8
31+
- target:
32+
kind: AzureCluster
33+
patch: |-
34+
- op: replace
35+
path: /spec/networkSpec/subnets/0/cidrBlocks/0
36+
value: 50.0.0.0/16
37+
- target:
38+
kind: AzureCluster
39+
patch: |-
40+
- op: replace
41+
path: /spec/networkSpec/subnets/1/cidrBlocks/0
42+
value: 50.1.0.0/16
43+
- target:
44+
kind: KubeadmConfigTemplate
45+
name: .*-md-win
46+
patch: |-
47+
- op: replace
48+
path: /spec/template/spec/preKubeadmCommands/0
49+
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'"
51+
options:
52+
allowResourceNotFound: true
53+
54+
sortOptions:
55+
order: fifo
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: default
4+
resources:
5+
- ../../flavors/azure-bastion
6+
7+
patches:
8+
- path: ../../flavors/apiserver-ilb/patches/kubeadm-config-template.yaml
9+
- path: ../../flavors/apiserver-ilb/patches/control-plane.yaml
10+
- target:
11+
kind: KubeadmConfigTemplate
12+
name: .*-md-0
13+
patch: |-
14+
- op: replace
15+
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
17+
options:
18+
allowResourceNotFound: true
19+
- target:
20+
kind: AzureCluster
21+
patch: |-
22+
- op: replace
23+
path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP
24+
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-60.0.0.100}
25+
- target:
26+
kind: AzureCluster
27+
patch: |-
28+
- op: replace
29+
path: /spec/networkSpec/vnet/cidrBlocks/0
30+
value: 60.0.0.0/8
31+
- target:
32+
kind: AzureCluster
33+
patch: |-
34+
- op: replace
35+
path: /spec/networkSpec/subnets/0/cidrBlocks/0
36+
value: 60.0.0.0/16
37+
- target:
38+
kind: AzureCluster
39+
patch: |-
40+
- op: replace
41+
path: /spec/networkSpec/subnets/1/cidrBlocks/0
42+
value: 60.1.0.0/16
43+
- target:
44+
kind: KubeadmConfigTemplate
45+
name: .*-md-win
46+
patch: |-
47+
- op: replace
48+
path: /spec/template/spec/preKubeadmCommands/0
49+
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'"
51+
options:
52+
allowResourceNotFound: true
53+
54+
55+
sortOptions:
56+
order: fifo
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: default
4+
resources:
5+
- ../../flavors/azure-cni-v1
6+
7+
patches:
8+
- path: ../../flavors/apiserver-ilb/patches/kubeadm-config-template.yaml
9+
- path: ../../flavors/apiserver-ilb/patches/control-plane.yaml
10+
- target:
11+
kind: KubeadmConfigTemplate
12+
name: .*-md-0
13+
patch: |-
14+
- op: replace
15+
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
17+
options:
18+
allowResourceNotFound: true
19+
- target:
20+
kind: AzureCluster
21+
patch: |-
22+
- op: replace
23+
path: /spec/networkSpec/apiServerLB/frontendIPs/1/privateIP
24+
value: ${AZURE_INTERNAL_LB_PRIVATE_IP:-70.0.0.100}
25+
- target:
26+
kind: AzureCluster
27+
patch: |-
28+
- op: replace
29+
path: /spec/networkSpec/vnet/cidrBlocks/0
30+
value: 70.0.0.0/8
31+
- target:
32+
kind: AzureCluster
33+
patch: |-
34+
- op: replace
35+
path: /spec/networkSpec/subnets/0/cidrBlocks/0
36+
value: 70.0.0.0/16
37+
- target:
38+
kind: AzureCluster
39+
patch: |-
40+
- op: replace
41+
path: /spec/networkSpec/subnets/1/cidrBlocks/0
42+
value: 70.1.0.0/16
43+
- target:
44+
kind: KubeadmConfigTemplate
45+
name: .*-md-win
46+
patch: |-
47+
- op: replace
48+
path: /spec/template/spec/preKubeadmCommands/0
49+
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'"
51+
options:
52+
allowResourceNotFound: true
53+
54+
55+
sortOptions:
56+
order: fifo

0 commit comments

Comments
 (0)