This is an automated email from the ASF dual-hosted git repository.
moonming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git
The following commit(s) were added to refs/heads/master by this push:
new 0a1d301 feat(apisix-ingress-controller): let the IngressClass
reference an external GatewayProxy (#1035)
0a1d301 is described below
commit 0a1d301f617e4dbb78e72e4322350b5239bcd6f5
Author: Ming Wen <[email protected]>
AuthorDate: Thu Nov 19 16:03:44 2026 +0800
feat(apisix-ingress-controller): let the IngressClass reference an external
GatewayProxy (#1035)
---
.github/workflows/ci.yaml | 1 +
charts/apisix-ingress-controller/Chart.yaml | 2 +-
charts/apisix-ingress-controller/README.md | 1 +
.../templates/_helpers.tpl | 21 ++++++
.../templates/gatewayproxy.yaml | 2 +-
.../templates/ingress-class.yaml | 4 +-
charts/apisix-ingress-controller/values.yaml | 8 +++
test/render/gatewayproxy-name.py | 82 ++++++++++++++++++++++
8 files changed, 117 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index e2f15d3..f86e591 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -31,6 +31,7 @@ jobs:
--workdir /workdir/charts/apisix \
quay.io/helmpack/chart-testing:v3.13.0 sh -c 'helm dependency
update \
&& cd ../.. \
+ && python3 test/render/gatewayproxy-name.py \
&& helm repo add bitnami https://charts.bitnami.com/bitnami \
&& helm repo add apisix
https://apache.github.io/apisix-helm-chart \
&& ct lint \
diff --git a/charts/apisix-ingress-controller/Chart.yaml
b/charts/apisix-ingress-controller/Chart.yaml
index d2bee2f..ca69929 100644
--- a/charts/apisix-ingress-controller/Chart.yaml
+++ b/charts/apisix-ingress-controller/Chart.yaml
@@ -24,7 +24,7 @@ keywords:
- nginx
- crd
type: application
-version: 1.4.1
+version: 1.5.0
appVersion: 2.2.0
sources:
- https://github.com/apache/apisix-helm-chart
diff --git a/charts/apisix-ingress-controller/README.md
b/charts/apisix-ingress-controller/README.md
index 2a71f8f..cf37bec 100644
--- a/charts/apisix-ingress-controller/README.md
+++ b/charts/apisix-ingress-controller/README.md
@@ -147,6 +147,7 @@ The same for container level, you need to set:
| deployment.topologySpreadConstraints | list | `[]` | Topology Spread
Constraints for pod assignment spread across your cluster among failure-domains
ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
|
| fullnameOverride | string | `""` | |
| gatewayProxy.createDefault | bool | `false` | Controls whether to create a
default GatewayProxy custom resource. |
+| gatewayProxy.name | string | `""` | Name of the GatewayProxy that the
IngressClass references, in the release namespace. Rendered once per chart with
`tpl`. An unset name or one that renders to empty defaults to `<release
name>-config` only with `createDefault: true`. With `createDefault: false`, an
empty name omits the IngressClass parameters. Set a non-empty name with
`createDefault: false` to reference a GatewayProxy created outside this chart,
for example by the apisix chart. |
| gatewayProxy.pluginMetadata | object | `{}` | Global plugin metadata shared
by all instances of the same plugin. |
| gatewayProxy.plugins | list | `[]` | List of global plugins to be enabled on
the GatewayProxy. |
| gatewayProxy.provider | object |
`{"controlPlane":{"auth":{"adminKey":{"value":"edd1c9f034335f136f87ad84b625c8f1","valueFrom":{}},"type":"AdminKey"},"endpoints":[],"service":{"name":"","port":9180}},"type":"ControlPlane"}`
| Configuration for the GatewayProxy provider connection |
diff --git a/charts/apisix-ingress-controller/templates/_helpers.tpl
b/charts/apisix-ingress-controller/templates/_helpers.tpl
index 6bbb584..5855e64 100644
--- a/charts/apisix-ingress-controller/templates/_helpers.tpl
+++ b/charts/apisix-ingress-controller/templates/_helpers.tpl
@@ -104,3 +104,24 @@ Port of the controller health probe server, taken from
config.probeAddr
{{- end -}}
{{- $port -}}
{{- end -}}
+
+{{/*
+gatewayProxy.name rendered with tpl, so a parent chart can pass
+"{{ .Release.Name }}-...". Empty when it is not set or renders to nothing.
+Render once per chart so the created GatewayProxy and its reference agree.
+*/}}
+{{- define "apisix-ingress-controller-manager.configuredGatewayProxyName" -}}
+{{- $key := "_apisixIngressControllerConfiguredGatewayProxyName" -}}
+{{- if not (hasKey . $key) -}}
+{{- $_ := set . $key (tpl (.Values.gatewayProxy.name | default "" | toString)
.) -}}
+{{- end -}}
+{{- get . $key -}}
+{{- end -}}
+
+{{/*
+Name of the GatewayProxy that the IngressClass references, in the release
+namespace: gatewayProxy.name, or "<release name>-config".
+*/}}
+{{- define "apisix-ingress-controller-manager.gatewayProxyName" -}}
+{{- default (printf "%s-config" .Release.Name) (include
"apisix-ingress-controller-manager.configuredGatewayProxyName" .) -}}
+{{- end -}}
diff --git a/charts/apisix-ingress-controller/templates/gatewayproxy.yaml
b/charts/apisix-ingress-controller/templates/gatewayproxy.yaml
index 69bc6ea..c873871 100644
--- a/charts/apisix-ingress-controller/templates/gatewayproxy.yaml
+++ b/charts/apisix-ingress-controller/templates/gatewayproxy.yaml
@@ -19,7 +19,7 @@ apiVersion: apisix.apache.org/v1alpha1
kind: GatewayProxy
metadata:
namespace: {{ .Release.Namespace }}
- name: {{ .Release.Name }}-config
+ name: {{ include "apisix-ingress-controller-manager.gatewayProxyName" . |
quote }}
spec:
provider:
type: {{ .Values.gatewayProxy.provider.type }}
diff --git a/charts/apisix-ingress-controller/templates/ingress-class.yaml
b/charts/apisix-ingress-controller/templates/ingress-class.yaml
index 4e4e77e..234bf01 100644
--- a/charts/apisix-ingress-controller/templates/ingress-class.yaml
+++ b/charts/apisix-ingress-controller/templates/ingress-class.yaml
@@ -24,11 +24,11 @@ metadata:
{{- end }}
spec:
controller: {{ .Values.config.controllerName | default
"apisix.apache.org/apisix-ingress-controller" }}
- {{- if .Values.gatewayProxy.createDefault }}
+ {{- if or .Values.gatewayProxy.createDefault (include
"apisix-ingress-controller-manager.configuredGatewayProxyName" .) }}
parameters:
apiGroup: apisix.apache.org
kind: GatewayProxy
- name: {{ .Release.Name }}-config
+ name: {{ include "apisix-ingress-controller-manager.gatewayProxyName" . |
quote }}
namespace: {{ .Release.Namespace }}
scope: Namespace
{{- end}}
diff --git a/charts/apisix-ingress-controller/values.yaml
b/charts/apisix-ingress-controller/values.yaml
index 9452d04..a4109ae 100644
--- a/charts/apisix-ingress-controller/values.yaml
+++ b/charts/apisix-ingress-controller/values.yaml
@@ -133,6 +133,14 @@ gatewayProxy:
# -- Controls whether to create a default GatewayProxy custom resource.
createDefault: false
+ # -- Name of the GatewayProxy that the IngressClass references, in the
release namespace.
+ # Rendered once per chart with `tpl`. An unset name or one that renders to
empty
+ # defaults to `<release name>-config` only with `createDefault: true`.
+ # With `createDefault: false`, an empty name omits the IngressClass
parameters.
+ # Set a non-empty name with `createDefault: false` to reference a
GatewayProxy
+ # created outside this chart, for example by the apisix chart.
+ name: ""
+
# -- Configuration for the GatewayProxy provider connection
provider:
# -- Specifies the provider type for the GatewayProxy.
diff --git a/test/render/gatewayproxy-name.py b/test/render/gatewayproxy-name.py
new file mode 100644
index 0000000..19b73bc
--- /dev/null
+++ b/test/render/gatewayproxy-name.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python3
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+import unittest
+
+import yaml
+
+
+class GatewayProxyNameTest(unittest.TestCase):
+ def test_names(self):
+ chart = Path(__file__).resolve().parents[2] /
"charts/apisix-ingress-controller"
+ release = "gatewayproxy-test"
+ cases = [
+ ("unset", None, None),
+ ("empty", "", None),
+ ("custom", "custom", "custom"),
+ ("release-template", "{{ .Release.Name }}-config", release +
"-config"),
+ ("empty-template", '{{ "" }}', None),
+ ("numeric", "123", "123"),
+ ("leading-zero", "00123", "00123"),
+ ("boolean-like", "true", "true"),
+ ("null-like", "null", "null"),
+ ("numeric-template", '{{ "123" }}', "123"),
+ ("template-context", '{{ base .Template.Name | trimSuffix ".yaml"
}}-config', None),
+ ]
+ with tempfile.TemporaryDirectory() as directory:
+ values_file = Path(directory) / "values.yaml"
+ for create_default in (False, True):
+ for label, name, rendered in cases:
+ with self.subTest(createDefault=create_default,
name=label):
+ values = {"gatewayProxy": {"createDefault":
create_default}}
+ if name is not None:
+ values["gatewayProxy"]["name"] = name
+ values_file.write_text(yaml.safe_dump(values))
+ result = subprocess.run(
+ [os.environ.get("HELM_BIN", "helm"), "template",
release,
+ str(chart), "--values", str(values_file)],
+ capture_output=True, text=True,
+ )
+ self.assertEqual(result.returncode, 0, result.stderr)
+ docs = [doc for doc in
yaml.safe_load_all(result.stdout) if doc]
+ classes = [doc for doc in docs if doc["kind"] ==
"IngressClass"]
+ proxies = [doc for doc in docs if doc["kind"] ==
"GatewayProxy"]
+ self.assertEqual(len(classes), 1)
+ self.assertEqual(len(proxies), int(create_default))
+ if label == "template-context":
+ expected = classes[0]["spec"]["parameters"]["name"]
+ self.assertIn(expected, ("ingress-class-config",
"gatewayproxy-config"))
+ else:
+ expected = rendered or (release + "-config" if
create_default else None)
+ if expected is None:
+ self.assertNotIn("parameters", classes[0]["spec"])
+ else:
+ reference =
classes[0]["spec"]["parameters"]["name"]
+ self.assertIsInstance(reference, str)
+ self.assertEqual(reference, expected)
+ if create_default:
+ actual = proxies[0]["metadata"]["name"]
+ self.assertIsInstance(actual, str)
+ self.assertEqual(actual, expected)
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)