diff --git a/kubernetes-ingress/Chart.yaml b/kubernetes-ingress/Chart.yaml index a38cfa2..4e17382 100644 --- a/kubernetes-ingress/Chart.yaml +++ b/kubernetes-ingress/Chart.yaml @@ -16,7 +16,7 @@ apiVersion: v2 name: kubernetes-ingress description: A Helm chart for HAProxy Kubernetes Ingress Controller type: application -version: 1.52.1 +version: 1.53.0 appVersion: 3.2.12 kubeVersion: ">=1.23.0-0" keywords: diff --git a/kubernetes-ingress/README.md b/kubernetes-ingress/README.md index 8a603cb..d7d63dc 100644 --- a/kubernetes-ingress/README.md +++ b/kubernetes-ingress/README.md @@ -512,6 +512,14 @@ A Helm `post-install` / `pre-upgrade` hook Job that applies the controller's CRD | `crdjob.nodeSelector` / `.tolerations` / `.affinity` | Scheduling controls for the Job pod. | `{}` / `[]` / `{}` | | `crdjob.resources.requests` / `.limits` | CPU/memory requests and (optional) limits for the Job container. | `cpu: 250m`, `memory: 400Mi` (no limits) | +### Extra Objects + +Declare additional arbitrary raw CR manifests to deploy as a part of the helm release. + +| Key | Description | Default | +|---|---|---| +| `extraObjects` | Extra raw objects to template. | `[]` | + ### Migration notes (1.50.0) - **Prometheus / pprof decoupled from `admin` port.** Previously, setting `controller.service.enablePorts.admin=false` implicitly disabled the controller's `/metrics` and `/debug/pprof` endpoints. Starting in 1.50.0, the dedicated toggles `controller.prometheus.enabled` and `controller.pprof.enabled` control these (both default `true`). If you were relying on the old coupling, set the new toggles to `false` explicitly. diff --git a/kubernetes-ingress/ci/deployment-extraobjects-values.yaml b/kubernetes-ingress/ci/deployment-extraobjects-values.yaml new file mode 100644 index 0000000..6e86bad --- /dev/null +++ b/kubernetes-ingress/ci/deployment-extraobjects-values.yaml @@ -0,0 +1,16 @@ +extraObjects: + - apiVersion: v1 + kind: ConfigMap + metadata: + name: extra-conf-1 + data: + extra.conf: | + example_config_1 + - | + apiVersion: v1 + kind: ConfigMap + metadata: + name: {{ .Release.Name }}-extra-conf-2 + data: + extra.conf: | + example_config_2 diff --git a/kubernetes-ingress/templates/_helpers.tpl b/kubernetes-ingress/templates/_helpers.tpl index b18a842..578727d 100644 --- a/kubernetes-ingress/templates/_helpers.tpl +++ b/kubernetes-ingress/templates/_helpers.tpl @@ -260,4 +260,72 @@ Create a name for the auxiliary configmap. {{- printf "%s-%s" (include "kubernetes-ingress.fullname" . | trunc 54 | trimSuffix "-") "auxiliary" }} {{- end -}} +{{/* +Create extra raw objects labels. +*/}} +{{- define "kubernetes-ingress.extraRawLabels" -}} +metadata: + labels: + {{- include "kubernetes-ingress.labels" $ | nindent 4 }} +{{- end }} + +{{/* +Ensure an extra object is a Kubernetes CR. +It must be a map with at least apiVersion, kind, metadata.name, spec or data keys. +*/}} +{{- define "kubernetes-ingress.validateExtraObject" -}} +{{- $obj := . -}} +{{- $tplName := "kubernetes-ingress.validateExtraObject" -}} +{{- if not (kindIs "map" $obj) -}} +{{- fail (printf "%s: expected a map, got %s" $tplName (kindOf $obj)) -}} +{{- end -}} +{{- if not (hasKey $obj "apiVersion") -}} +{{- fail (printf "%s: object is missing required key 'apiVersion'" $tplName) -}} +{{- end -}} +{{- if not (kindIs "string" $obj.apiVersion) -}} +{{- fail (printf "%s: 'apiVersion' must be a string, got %s" $tplName (kindOf $obj.apiVersion)) -}} +{{- end -}} +{{- $_ := required (printf "%s: 'apiVersion' must not be empty" $tplName) $obj.apiVersion -}} +{{- if not (hasKey $obj "kind") -}} +{{- fail (printf "%s: object is missing required key 'kind'" $tplName) -}} +{{- end -}} +{{- if not (kindIs "string" $obj.kind) -}} +{{- fail (printf "%s: 'kind' must be a string, got %s" $tplName (kindOf $obj.kind)) -}} +{{- end -}} +{{- $_ := required (printf "%s: 'kind' must not be empty" $tplName) $obj.kind -}} +{{- if not (hasKey $obj "metadata") -}} +{{- fail (printf "%s: object is missing required key 'metadata'" $tplName) -}} +{{- end -}} +{{- if not (kindIs "map" $obj.metadata) -}} +{{- fail (printf "%s: 'metadata' must be a map, got %s" $tplName (kindOf $obj.metadata)) -}} +{{- end -}} +{{- if not (hasKey $obj.metadata "name") -}} +{{- fail (printf "%s: object is missing required key 'metadata.name'" $tplName) -}} +{{- end -}} +{{- if not (kindIs "string" $obj.metadata.name) -}} +{{- fail (printf "%s: 'metadata.name' must be a string, got %s" $tplName (kindOf $obj.metadata.name)) -}} +{{- end -}} +{{- $_ := required (printf "%s: 'metadata.name' must not be empty" $tplName) $obj.metadata.name -}} +{{- if not (or (hasKey $obj "spec") (hasKey $obj "data")) -}} +{{- fail (printf "%s: object must have either 'spec' or 'data' key" $tplName) -}} +{{- end -}} +{{- end }} + +{{/* +Render an extra object that might contain templates. +*/}} +{{- define "kubernetes-ingress.renderExtraObject" -}} +{{- $labels := fromYaml (include "kubernetes-ingress.extraRawLabels" .context) -}} +{{- if typeIs "string" .value }} + {{- /* string form is an explicit opt-in to templating */ -}} + {{- $templatedValue := fromYaml (tpl .value .context) -}} + {{- include "kubernetes-ingress.validateExtraObject" $templatedValue }} + {{- toYaml (merge $templatedValue $labels) }} +{{- else }} + {{- /* map form is emitted verbatim; foreign {{ }} left untouched */ -}} + {{- include "kubernetes-ingress.validateExtraObject" .value }} + {{- toYaml (merge (deepCopy .value) $labels) }} +{{- end }} +{{- end -}} + {{/* vim: set filetype=mustache: */}} diff --git a/kubernetes-ingress/templates/extra-objects.yaml b/kubernetes-ingress/templates/extra-objects.yaml new file mode 100644 index 0000000..343940f --- /dev/null +++ b/kubernetes-ingress/templates/extra-objects.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraObjects }} +--- +{{ include "kubernetes-ingress.renderExtraObject" (dict "value" . "context" $) }} +{{- end }} diff --git a/kubernetes-ingress/values.yaml b/kubernetes-ingress/values.yaml index 531463f..57db135 100644 --- a/kubernetes-ingress/values.yaml +++ b/kubernetes-ingress/values.yaml @@ -735,3 +735,27 @@ crdjob: requests: cpu: 250m memory: 400Mi + +## Extra raw objects to template +## Note: this manifest is not capability-gated; if specific CRDs are +## missing, helm install will fail; this being said, this manifest +## is not intended to be used to deploy ingress.v3.haproxy.org/v3 CRs +## since their CRDs are installed/upgraded via a post-install/pre-upgrade job +extraObjects: [] + ## Use maps to declare raw manifests + # - apiVersion: v1 + # kind: ConfigMap + # metadata: + # name: extra-conf-1 + # data: + # extra.conf: | + # example_config_1 + ## Use multiline strings to declare templated manifests + # - | + # apiVersion: v1 + # kind: ConfigMap + # metadata: + # name: {{ .Release.Name }}-extra-conf-2 + # data: + # extra.conf: | + # example_config_2