Skip to content

Commit 1f347dc

Browse files
dkoshkinjimmidyson
andauthored
feat: enable Cilium kube-proxy replacement for new clusters (#1288)
**What problem does this PR solve?**: This PR enables Cilium's kube-proxy replacement feature automatically when clusters disable kube-proxy installation for new clusters. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. --> --------- Co-authored-by: Jimmi Dyson <[email protected]>
1 parent 4e28426 commit 1f347dc

File tree

9 files changed

+70
-7
lines changed

9 files changed

+70
-7
lines changed

charts/cluster-api-runtime-extensions-nutanix/addons/cni/cilium/values-template.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ socketLB:
3333
envoy:
3434
image:
3535
useDigest: false
36+
k8sServiceHost: auto
37+
{{- with .ControlPlane }}
38+
{{- range $key, $val := .metadata.annotations }}
39+
{{- if eq $key "controlplane.cluster.x-k8s.io/skip-kube-proxy" }}
40+
kubeProxyReplacement: true{{ break }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ spec:
1616
topology:
1717
class: aws-quick-start
1818
controlPlane:
19+
metadata:
20+
annotations:
21+
controlplane.cluster.x-k8s.io/skip-kube-proxy: ""
1922
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
2023
variables:
2124
- name: clusterConfig

examples/capi-quick-start/nutanix-cluster-cilium-helm-addon.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ spec:
5757
topology:
5858
class: nutanix-quick-start
5959
controlPlane:
60-
metadata: {}
60+
metadata:
61+
annotations:
62+
controlplane.cluster.x-k8s.io/skip-kube-proxy: ""
6163
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
6264
variables:
6365
- name: clusterConfig

hack/addons/kustomize/cilium/kustomization.yaml.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ helmCharts:
1919
skipTests: true
2020
namespace: kube-system
2121
kubeVersion: ${E2E_KUBERNETES_VERSION}
22-
valuesFile: ../../../../charts/cluster-api-runtime-extensions-nutanix/addons/cni/cilium/values-template.yaml
22+
# This values file will be created by the update-cilium-manifests.sh script when generating the CRS manifests.
23+
valuesFile: helm-values.yaml
2324
# The CRS manifests are generated from the Cilium Helm chart using Kustomize. The Cilium
2425
# Helm chart uses a Helm hook to generate TLS certificates for Hubble. As the
2526
# CRS manifests are static those Helm hooks don't apply and so for now Hubble is
@@ -29,5 +30,6 @@ helmCharts:
2930
enabled: false
3031
relay:
3132
enabled: false
33+
k8sServiceHost: ""
3234

3335
namespace: kube-system

hack/addons/update-cilium-manifests.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ readonly FILE_NAME="cilium.yaml"
2121

2222
readonly KUSTOMIZE_BASE_DIR="${SCRIPT_DIR}/kustomize/cilium"
2323
mkdir -p "${ASSETS_DIR}/cilium"
24-
envsubst -no-unset <"${KUSTOMIZE_BASE_DIR}/kustomization.yaml.tmpl" >"${KUSTOMIZE_BASE_DIR}/kustomization.yaml"
25-
trap_add "rm -f ${KUSTOMIZE_BASE_DIR}/kustomization.yaml" EXIT
24+
envsubst -no-unset <"${KUSTOMIZE_BASE_DIR}/kustomization.yaml.tmpl" >"${ASSETS_DIR}/kustomization.yaml"
25+
26+
cat <<EOF >"${ASSETS_DIR}/gomplate-context.yaml"
27+
ControlPlane: {}
28+
EOF
29+
gomplate -f "${GIT_REPO_ROOT}/charts/cluster-api-runtime-extensions-nutanix/addons/cni/cilium/values-template.yaml" \
30+
--context .="${ASSETS_DIR}/gomplate-context.yaml" \
31+
>"${ASSETS_DIR}/helm-values.yaml"
2632

2733
kustomize build \
2834
--load-restrictor LoadRestrictionsNone \
29-
--enable-helm "${KUSTOMIZE_BASE_DIR}/" >"${ASSETS_DIR}/${FILE_NAME}"
30-
trap_add "rm -rf ${KUSTOMIZE_BASE_DIR}/charts/" EXIT
35+
--enable-helm "${ASSETS_DIR}/" >"${ASSETS_DIR}/${FILE_NAME}"
3136

3237
# The operator manifest in YAML format is pretty big. It turns out that much of that is whitespace. Converting the
3338
# manifest to JSON without indentation allows us to remove most of the whitespace, reducing the size by more than half.

hack/examples/overlays/clusters/aws/cilium/helm-addon/kustomization.yaml.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ patches:
1414
- target:
1515
kind: Cluster
1616
path: ../../../../../patches/cilium.yaml
17+
- target:
18+
kind: Cluster
19+
path: ../../../../../patches/skip-kube-proxy.yaml

hack/examples/overlays/clusters/nutanix/cilium/helm-addon/kustomization.yaml.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ patches:
1414
- target:
1515
kind: Cluster
1616
path: ../../../../../patches/cilium.yaml
17+
- target:
18+
kind: Cluster
19+
path: ../../../../../patches/skip-kube-proxy.yaml
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2025 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: cluster.x-k8s.io/v1beta1
5+
kind: Cluster
6+
metadata:
7+
name: not-used
8+
spec:
9+
topology:
10+
controlPlane:
11+
metadata:
12+
annotations:
13+
controlplane.cluster.x-k8s.io/skip-kube-proxy: ""

hack/tools/fetch-images/main.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,31 @@ func getValuesFileForChartIfNeeded(chartName, carenChartDirectory string) (strin
259259
case "snapshot-controller":
260260
return filepath.Join(carenChartDirectory, "addons", "csi", "snapshot-controller", defaultHelmAddonFilename), nil
261261
case "cilium":
262-
return filepath.Join(carenChartDirectory, "addons", "cni", "cilium", defaultHelmAddonFilename), nil
262+
f := filepath.Join(carenChartDirectory, "addons", "cni", "cilium", defaultHelmAddonFilename)
263+
tempFile, err := os.CreateTemp("", "")
264+
if err != nil {
265+
return "", fmt.Errorf("failed to create temp file: %w", err)
266+
}
267+
268+
type input struct {
269+
ControlPlane map[string]interface{}
270+
}
271+
templateInput := input{
272+
ControlPlane: map[string]interface{}{
273+
"metadata": map[string]interface{}{
274+
"annotations": map[string]interface{}{
275+
"controlplane.cluster.x-k8s.io/skip-kube-proxy": "",
276+
},
277+
},
278+
},
279+
}
280+
281+
err = template.Must(template.New(defaultHelmAddonFilename).ParseFiles(f)).Execute(tempFile, &templateInput)
282+
if err != nil {
283+
return "", fmt.Errorf("failed to execute helm values template %w", err)
284+
}
285+
286+
return tempFile.Name(), nil
263287
// Calico values differ slightly per provider, but that does not have a material imapct on the images required
264288
// so we can use the default values file for AWS provider.
265289
case "tigera-operator":

0 commit comments

Comments
 (0)