From cecf9ec3e4885f97a054d595cbbcad9224640ef7 Mon Sep 17 00:00:00 2001 From: sgavrylenko <13081190+sgavrylenko@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:45:06 +0300 Subject: [PATCH] Add custom annotations into GatewayClass and NginxGateway manifests (#1993) Problem: For deploying our service we use ArgoCD. For this, we have a Helm Chart that contains multiple resources that are using CRDs, that are not managed by this helm chart. When trying to sync this application, it fails if at least one CRD is not installed in the cluster. This is expected. Solution: To work around this problem, we want to use SkipDryRunOnMissingResource option as annotation for GatewayClass and NginxGateway objects from the nginx-gateway-fabric chart --- charts/nginx-gateway-fabric/README.md | 2 ++ charts/nginx-gateway-fabric/templates/gatewayclass.yaml | 6 ++++++ charts/nginx-gateway-fabric/templates/nginxgateway.yaml | 6 ++++++ charts/nginx-gateway-fabric/values.yaml | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/charts/nginx-gateway-fabric/README.md b/charts/nginx-gateway-fabric/README.md index 72784ad08..45efa1ff6 100644 --- a/charts/nginx-gateway-fabric/README.md +++ b/charts/nginx-gateway-fabric/README.md @@ -253,9 +253,11 @@ The following tables lists the configurable parameters of the NGINX Gateway Fabr | `nginxGateway.lifecycle` | The `lifecycle` of the nginx-gateway container. | {} | | `nginxGateway.extraVolumeMounts` | Extra `volumeMounts` for the nginxGateway container. | {} | | `nginxGateway.gatewayClassName` | The name of the GatewayClass for the NGINX Gateway Fabric deployment. | nginx | +| `nginxGateway.gatewayClassAnnotations` | Set of custom annotations for GatewayClass objects. | {} | | `nginxGateway.gatewayControllerName` | The name of the Gateway controller. The controller name must be of the form: DOMAIN/PATH. The controller's domain is gateway.nginx.org. | gateway.nginx.org/nginx-gateway-controller | | `nginxGateway.kind` | The kind of the NGINX Gateway Fabric installation - currently, only Deployment is supported. | deployment | | `nginxGateway.config` | The dynamic configuration for the control plane that is contained in the NginxGateway resource | [See nginxGateway.config section](values.yaml) | +| `nginxGateway.configAnnotations` | Set of custom annotations for NginxGateway objects. | {} | | `nginxGateway.readinessProbe.enable` | Enable the /readyz endpoint on the control plane. | true | | `nginxGateway.readinessProbe.port` | Port in which the readiness endpoint is exposed. | 8081 | | `nginxGateway.readinessProbe.initialDelaySeconds` | The number of seconds after the Pod has started before the readiness probes are initiated. | 3 | diff --git a/charts/nginx-gateway-fabric/templates/gatewayclass.yaml b/charts/nginx-gateway-fabric/templates/gatewayclass.yaml index 4ecafd287..ee08e1a72 100644 --- a/charts/nginx-gateway-fabric/templates/gatewayclass.yaml +++ b/charts/nginx-gateway-fabric/templates/gatewayclass.yaml @@ -4,6 +4,12 @@ metadata: name: {{ .Values.nginxGateway.gatewayClassName }} labels: {{- include "nginx-gateway.labels" . | nindent 4 }} + {{- if .Values.nginxGateway.gatewayClassAnnotations }} + annotations: + {{- range $key, $value := .Values.nginxGateway.gatewayClassAnnotations }} + {{ printf "%s: %s" $key $value }} + {{- end }} + {{- end }} spec: controllerName: {{ .Values.nginxGateway.gatewayControllerName }} {{- if .Values.nginx.config }} diff --git a/charts/nginx-gateway-fabric/templates/nginxgateway.yaml b/charts/nginx-gateway-fabric/templates/nginxgateway.yaml index 0385e44a0..40e9412b2 100644 --- a/charts/nginx-gateway-fabric/templates/nginxgateway.yaml +++ b/charts/nginx-gateway-fabric/templates/nginxgateway.yaml @@ -5,5 +5,11 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "nginx-gateway.labels" . | nindent 4 }} + {{- if .Values.nginxGateway.configAnnotations }} + annotations: + {{- range $key, $value := .Values.nginxGateway.configAnnotations }} + {{ printf "%s: %s" $key $value }} + {{- end }} + {{- end }} spec: {{- toYaml .Values.nginxGateway.config | nindent 2 }} diff --git a/charts/nginx-gateway-fabric/values.yaml b/charts/nginx-gateway-fabric/values.yaml index 9c2ec18df..10e0cdd04 100644 --- a/charts/nginx-gateway-fabric/values.yaml +++ b/charts/nginx-gateway-fabric/values.yaml @@ -5,6 +5,10 @@ nginxGateway: ## Fabric must have a unique corresponding GatewayClass resource. NGINX Gateway Fabric only processes resources that ## belong to its class - i.e. have the "gatewayClassName" field resource equal to the class. gatewayClassName: nginx + ## Set of custom annotations for GatewayClass objects, e.g: + ## gatewayClassAnnotations: + ## someKey: someValue + gatewayClassAnnotations: {} ## The name of the Gateway controller. The controller name must be of the form: DOMAIN/PATH. The controller's domain ## is gateway.nginx.org. gatewayControllerName: gateway.nginx.org/nginx-gateway-controller @@ -13,6 +17,10 @@ nginxGateway: logging: ## Log level. Supported values "info", "debug", "error". level: info + ## Set of custom annotations for NginxGateway objects, e.g: + ## configAnnotations: + ## someKey: someValue + configAnnotations: {} ## The number of replicas of the NGINX Gateway Fabric Deployment. replicaCount: 1 ## The configuration for leader election.