Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kubernetes-ingress/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions kubernetes-ingress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table is missing its header row

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, my bad, added missing table header

| 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.
Expand Down
8 changes: 8 additions & 0 deletions kubernetes-ingress/ci/extra-objects-configmap-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extraObjects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Release.Name }}-extra-conf"
data:
extra.conf: |
example config
21 changes: 21 additions & 0 deletions kubernetes-ingress/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,25 @@ 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 }}

{{/*
Render extra raw objects that might contain templates
*/}}
{{- define "kubernetes-ingress.renderExtraObjects" -}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$value is always coerced to a string
(typeIs "string" .value | ternary .value (.value | toYaml)), but the else
branch passes that string straight to merge, which needs a map:

Error: ... executing "kubernetes-ingress.renderExtraObjects" at <$value>:
wrong type for value; expected map[string]interface {}; got string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like

{{- define "kubernetes-ingress.renderExtraObjects" -}}
  {{- $labels := fromYaml (include "kubernetes-ingress.extraRawLabels" .context) -}}
  {{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
  {{- if contains "{{" (toString $value) }}
    {{- $value = tpl $value .context }}
  {{- end }}
  {{- toYaml (merge (fromYaml $value) $labels) }}
{{- end -}}

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I decided to complicate the original design that served as an inspiration https://github.com/CloudPirates-io/helm-charts/blob/aff6783b21ce92155849464eb612551d2e8788d5/charts/common/templates/_helpers.tpl#L231-L241 and botched it a bit, but your suggestion seems to be working, so accepted, thanks!

{{- $labels := fromYaml (include "kubernetes-ingress.extraRawLabels" .context) -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- if contains "{{" (toString $value) }}
{{- $value = tpl $value .context }}
{{- end }}
{{- toYaml (merge (fromYaml $value) $labels) }}
{{- end -}}

{{/* vim: set filetype=mustache: */}}
4 changes: 4 additions & 0 deletions kubernetes-ingress/templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- range .Values.extraObjects }}
---
{{ include "kubernetes-ingress.renderExtraObjects" (dict "value" . "context" $) }}
{{- end }}
14 changes: 14 additions & 0 deletions kubernetes-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -735,3 +735,17 @@ 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: []
# - apiVersion: v1
# kind: ConfigMap
# metadata:
# name: "{{ .Release.Name }}-extra-conf"
# data:
# extra.conf: |
# example config