From c24cf2c9ffb947a5fc0051a7268d9d81bb82dd9c Mon Sep 17 00:00:00 2001 From: Robert Lijkendijk Date: Tue, 16 Jul 2024 13:47:28 +0200 Subject: [PATCH 1/3] Add possibility to provide custom pod annotations --- charts/nginx-gateway-fabric/README.md | 1 + charts/nginx-gateway-fabric/templates/deployment.yaml | 7 +++++-- charts/nginx-gateway-fabric/values.yaml | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/charts/nginx-gateway-fabric/README.md b/charts/nginx-gateway-fabric/README.md index 73aaaa2bc6..2ab4681ccd 100644 --- a/charts/nginx-gateway-fabric/README.md +++ b/charts/nginx-gateway-fabric/README.md @@ -285,6 +285,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri | `nginxGateway.leaderElection.enable` | Enable leader election. Leader election is used to avoid multiple replicas of the NGINX Gateway Fabric reporting the status of the Gateway API resources. If not enabled, all replicas of NGINX Gateway Fabric will update the statuses of the Gateway API resources. | bool | `true` | | `nginxGateway.leaderElection.lockName` | The name of the leader election lock. A Lease object with this name will be created in the same Namespace as the controller. | string | Autogenerated if not set or set to "". | | `nginxGateway.lifecycle` | The lifecycle of the nginx-gateway container. | object | `{}` | +| `nginxGateway.podAnnotations` | Set of custom annotations for the NGINX Gateway Fabric pods. | object | `{}` | | `nginxGateway.productTelemetry.enable` | Enable the collection of product telemetry. | bool | `true` | | `nginxGateway.readinessProbe.enable` | Enable the /readyz endpoint on the control plane. | bool | `true` | | `nginxGateway.readinessProbe.initialDelaySeconds` | The number of seconds after the Pod has started before the readiness probes are initiated. | int | `3` | diff --git a/charts/nginx-gateway-fabric/templates/deployment.yaml b/charts/nginx-gateway-fabric/templates/deployment.yaml index ce2d38a8e9..c6dd25c03d 100644 --- a/charts/nginx-gateway-fabric/templates/deployment.yaml +++ b/charts/nginx-gateway-fabric/templates/deployment.yaml @@ -15,14 +15,17 @@ spec: metadata: labels: {{- include "nginx-gateway.selectorLabels" . | nindent 8 }} - {{- if .Values.metrics.enable }} annotations: + {{- if .Values.nginxGateway.podAnnotations }} + {{- toYaml .Values.nginxGateway.podAnnotations | trim | nindent 8 }} + {{- end }} + {{- if .Values.metrics.enable }} prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.metrics.port }}" {{- if .Values.metrics.secure }} prometheus.io/scheme: "https" {{- end }} - {{- end }} + {{- end }} spec: containers: - args: diff --git a/charts/nginx-gateway-fabric/values.yaml b/charts/nginx-gateway-fabric/values.yaml index e9804ae239..827d414fab 100644 --- a/charts/nginx-gateway-fabric/values.yaml +++ b/charts/nginx-gateway-fabric/values.yaml @@ -7,6 +7,9 @@ nginxGateway: # belong to its class - i.e. have the "gatewayClassName" field resource equal to the class. gatewayClassName: nginx + # -- Set of custom annotations for the NGINX Gateway Fabric pods. + podAnnotations: {} + # -- Set of custom annotations for GatewayClass objects. gatewayClassAnnotations: {} From 0c7977b10e198dab3faabf2657fecf5ea517dad9 Mon Sep 17 00:00:00 2001 From: Robert Lijkendijk Date: Tue, 16 Jul 2024 14:15:48 +0200 Subject: [PATCH 2/3] Trim trailing white space --- charts/nginx-gateway-fabric/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nginx-gateway-fabric/templates/deployment.yaml b/charts/nginx-gateway-fabric/templates/deployment.yaml index c6dd25c03d..6aba0e8af0 100644 --- a/charts/nginx-gateway-fabric/templates/deployment.yaml +++ b/charts/nginx-gateway-fabric/templates/deployment.yaml @@ -18,7 +18,7 @@ spec: annotations: {{- if .Values.nginxGateway.podAnnotations }} {{- toYaml .Values.nginxGateway.podAnnotations | trim | nindent 8 }} - {{- end }} + {{- end }} {{- if .Values.metrics.enable }} prometheus.io/scrape: "true" prometheus.io/port: "{{ .Values.metrics.port }}" From 867aa2c4cd52e40ce14f3640c7dc2c9b40e4ce69 Mon Sep 17 00:00:00 2001 From: Robert Lijkendijk Date: Wed, 17 Jul 2024 08:03:05 +0200 Subject: [PATCH 3/3] Add additional if statement before the annotations and remove trim --- charts/nginx-gateway-fabric/templates/deployment.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/charts/nginx-gateway-fabric/templates/deployment.yaml b/charts/nginx-gateway-fabric/templates/deployment.yaml index 6aba0e8af0..6abed60a4a 100644 --- a/charts/nginx-gateway-fabric/templates/deployment.yaml +++ b/charts/nginx-gateway-fabric/templates/deployment.yaml @@ -15,9 +15,10 @@ spec: metadata: labels: {{- include "nginx-gateway.selectorLabels" . | nindent 8 }} + {{- if or .Values.nginxGateway.podAnnotations .Values.metrics.enable }} annotations: {{- if .Values.nginxGateway.podAnnotations }} - {{- toYaml .Values.nginxGateway.podAnnotations | trim | nindent 8 }} + {{- toYaml .Values.nginxGateway.podAnnotations | nindent 8 }} {{- end }} {{- if .Values.metrics.enable }} prometheus.io/scrape: "true" @@ -26,6 +27,7 @@ spec: prometheus.io/scheme: "https" {{- end }} {{- end }} + {{- end }} spec: containers: - args: