Skip to content

Support configurable hostPort in helm chart #3321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
5 changes: 4 additions & 1 deletion charts/nginx-gateway-fabric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,13 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
| `certGenerator.serverTLSSecretName` | The name of the Secret containing TLS CA, certificate, and key for the NGINX Gateway Fabric control plane to securely communicate with the NGINX Agent. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `"server-tls"` |
| `clusterDomain` | The DNS cluster domain of your Kubernetes cluster. | string | `"cluster.local"` |
| `gateways` | A list of Gateway objects. View https://gateway-api.sigs.k8s.io/reference/spec/#gateway for full Gateway reference. | list | `[]` |
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"config":{},"container":{},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","plus":false,"pod":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"config":{},"container":{},"debug":false,"hostPort":{"enable":false,"port":443},"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","plus":false,"pod":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
| `nginx.config` | The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
| `nginx.container` | The container configuration for the NGINX container. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
| `nginx.debug` | Enable debugging for NGINX. Uses the nginx-debug binary. The NGINX error log level should be set to debug in the NginxProxy resource. | bool | `false` |
| `nginx.hostPort` | The hostPort configuration | object | `{"enable":false,"port":443}` |
| `nginx.hostPort.enable` | Enables hostPort. | bool | `false` |
| `nginx.hostPort.port` | The port | int | `443` |
| `nginx.image.repository` | The NGINX image to use. | string | `"ghcr.io/nginx/nginx-gateway-fabric/nginx"` |
| `nginx.imagePullSecret` | The name of the secret containing docker registry credentials. Secret must exist in the same namespace as the helm release. The control plane will copy this secret into any namespace where NGINX is deployed. | string | `""` |
| `nginx.imagePullSecrets` | A list of secret names containing docker registry credentials. Secrets must exist in the same namespace as the helm release. The control plane will copy these secrets into any namespace where NGINX is deployed. | list | `[]` |
Expand Down
3 changes: 3 additions & 0 deletions charts/nginx-gateway-fabric/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ spec:
ports:
- name: agent-grpc
containerPort: 8443
{{- if .Values.nginx.hostPort.enable }}
hostPort: {{ .Values.nginx.hostPort.port }}
{{- end }}
Comment on lines +138 to +140
Copy link
Collaborator

@sjberman sjberman May 29, 2025

Choose a reason for hiding this comment

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

This deployment is no longer for nginx, it's just the control plane.

The nginx deployment is built in-code by the control plane. #3319 is an example of how we now add a new field to the nginx deployment/service, so you'll need to do something similar to add these new hostPort fields. The fields need to exist in the NginxProxy CRD, which is populated at installation time via the helm chart (or at runtime via the k8s API), and is then ingested by the control plane to configure and deploy the nginx deployment.

Copy link
Author

Choose a reason for hiding this comment

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

ok, i will adjust nginxProxy CRD in order to support this hostPort field

{{- if .Values.nginxGateway.metrics.enable }}
- name: metrics
containerPort: {{ .Values.nginxGateway.metrics.port }}
Expand Down
24 changes: 24 additions & 0 deletions charts/nginx-gateway-fabric/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,30 @@
"title": "debug",
"type": "boolean"
},
"hostPort": {
"description": "The hostPort configuration",
"properties": {
"enable": {
"default": false,
"description": "Enables hostPort.",
"required": [],
"title": "enable",
"type": "boolean"
},
"port": {
"default": 443,
"description": "The port",
"maximum": 65535,
"minimum": 1,
"required": [],
"title": "port",
"type": "integer"
}
},
"required": [],
"title": "hostPort",
"type": "object"
},
"image": {
"properties": {
"pullPolicy": {
Expand Down
13 changes: 13 additions & 0 deletions charts/nginx-gateway-fabric/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@ nginx:
# Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway).
clientSSLSecretName: ""

# -- The hostPort configuration
hostPort:
# -- Enables hostPort.
enable: false

# @schema
# type: integer
# minimum: 1
# maximum: 65535
# @schema
# -- The port
port: 443

# @schema
# type: object
# properties:
Expand Down