Skip to content

Commit 7cb82dc

Browse files
committed
add readiness probe for nginx on startup
1 parent 487dbe6 commit 7cb82dc

File tree

25 files changed

+687
-27
lines changed

25 files changed

+687
-27
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,49 @@ type KubernetesSpec struct {
386386
//
387387
// +optional
388388
Service *ServiceSpec `json:"service,omitempty"`
389+
390+
// ReadinessProbe is the configuration for the NGINX Readiness probe.
391+
//
392+
// +optional
393+
ReadinessProbe *ReadinessProbeSpec `json:"readinessProbe,omitempty"`
394+
}
395+
396+
// ReadinessProbeSpec defines the configuration for the NGINX readiness probe.
397+
type ReadinessProbeSpec struct {
398+
// Port is the port on which the readiness endpoint is exposed.
399+
// If not specified, the default port is 8081.
400+
//
401+
// +optional
402+
// +kubebuilder:default:=8081
403+
// +kubebuilder:validation:Minimum=1
404+
// +kubebuilder:validation:Maximum=65535
405+
Port *int32 `json:"port,omitempty"`
406+
407+
// InitialDelaySeconds is the number of seconds after the container has
408+
// started before the readiness probe is initiated.
409+
// If not specified, the default is 3 seconds.
410+
// +optional
411+
// +kubebuilder:default:=3
412+
// +kubebuilder:validation:Minimum=0
413+
// +kubebuilder:validation:Maximum=3600
414+
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
415+
416+
// PeriodSeconds is the number of seconds between consecutive readiness probes.
417+
// If not specified, the default is 10 seconds.
418+
// +optional
419+
// +kubebuilder:default:=10
420+
// +kubebuilder:validation:Minimum=1
421+
// +kubebuilder:validation:Maximum=3600
422+
PeriodSeconds *int32 `json:"periodSeconds,omitempty"`
423+
424+
// TimeoutSeconds is the number of seconds after which the readiness probe times out.
425+
// If not specified, the default is 1 second.
426+
//
427+
// +optional
428+
// +kubebuilder:default:=1
429+
// +kubebuilder:validation:Minimum=1
430+
// +kubebuilder:validation:Maximum=3600
431+
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
389432
}
390433

391434
// Deployment is the configuration for the NGINX Deployment.

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/nginx-gateway-fabric/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
264264
| `certGenerator.ttlSecondsAfterFinished` | How long to wait after the cert generator job has finished before it is removed by the job controller. | int | `30` |
265265
| `clusterDomain` | The DNS cluster domain of your Kubernetes cluster. | string | `"cluster.local"` |
266266
| `gateways` | A list of Gateway objects. View https://gateway-api.sigs.k8s.io/reference/spec/#gateway for full Gateway reference. | list | `[]` |
267-
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"config":{},"container":{"hostPorts":[],"lifecycle":{},"resources":{},"volumeMounts":[]},"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}}` |
267+
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"config":{},"container":{"hostPorts":[],"lifecycle":{},"resources":{},"volumeMounts":[]},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","plus":false,"pod":{},"readinessProbe":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
268268
| `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 | `{}` |
269269
| `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 | `{"hostPorts":[],"lifecycle":{},"resources":{},"volumeMounts":[]}` |
270270
| `nginx.container.hostPorts` | A list of HostPorts to expose on the host. This configuration allows containers to bind to a specific port on the host node, enabling external network traffic to reach the container directly through the host's IP address and port. Use this option when you need to expose container ports on the host for direct access, such as for debugging, legacy integrations, or when NodePort/LoadBalancer services are not suitable. Note: Using hostPort may have security and scheduling implications, as it ties pods to specific nodes and ports. | list | `[]` |

charts/nginx-gateway-fabric/templates/nginxproxy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ spec:
5858
{{- end }}
5959
{{- end }}
6060
{{- end }}
61+
readinessProbe:
62+
port: {{ .Values.nginx.readinessProbe.port | default 8081 }}
63+
initialDelaySeconds: {{ .Values.nginx.readinessProbe.initialDelaySeconds | default 3 }}
64+
periodSeconds: {{ .Values.nginx.readinessProbe.periodSeconds | default 10 }}
65+
timeoutSeconds: {{ .Values.nginx.readinessProbe.timeoutSeconds | default 1 }}

charts/nginx-gateway-fabric/values.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,12 @@
447447
"title": "pod",
448448
"type": "object"
449449
},
450+
"readinessProbe": {
451+
"description": "# Defines the settings for the data plane readiness probe. This probe returns Ready when the NGINX data plane is ready to serve traffic.",
452+
"required": [],
453+
"title": "readinessProbe",
454+
"type": "object"
455+
},
450456
"replicas": {
451457
"default": 1,
452458
"description": "The number of replicas of the NGINX Deployment.",

charts/nginx-gateway-fabric/values.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,40 @@ nginx:
493493
# - port: 30025
494494
# listenerPort: 80
495495

496+
## Defines the settings for the data plane readiness probe. This probe returns Ready when the NGINX data plane is ready to serve traffic.
497+
readinessProbe: {}
498+
# @schema
499+
# type: integer
500+
# minimum: 1
501+
# maximum: 65535
502+
# @schema
503+
# -- Port in which the readiness endpoint is exposed.
504+
# port: 8081
505+
506+
# @schema
507+
# type: integer
508+
# minimum: 0
509+
# maximum: 3600
510+
# @schema
511+
# -- The number of seconds after the Pod has started before the readiness probes are initiated.
512+
# initialDelaySeconds: 3
513+
514+
# @schema
515+
# type: integer
516+
# minimum: 1
517+
# maximum: 3600
518+
# @schema
519+
# -- The number of seconds between consecutive readiness probes.
520+
# periodSeconds: 10
521+
522+
# @schema
523+
# type: integer
524+
# minimum: 1
525+
# maximum: 3600
526+
# @schema
527+
# -- The number of seconds after which the readiness probe times out.
528+
# timeoutSeconds: 1
529+
496530
# -- Enable debugging for NGINX. Uses the nginx-debug binary. The NGINX error log level should be set to debug in the NginxProxy resource.
497531
debug: false
498532

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6894,6 +6894,48 @@ spec:
68946894
format: int32
68956895
type: integer
68966896
type: object
6897+
readinessProbe:
6898+
description: ReadinessProbe is the configuration for the NGINX
6899+
Readiness probe.
6900+
properties:
6901+
initialDelaySeconds:
6902+
default: 3
6903+
description: |-
6904+
InitialDelaySeconds is the number of seconds after the container has
6905+
started before the readiness probe is initiated.
6906+
If not specified, the default is 3 seconds.
6907+
format: int32
6908+
maximum: 3600
6909+
minimum: 0
6910+
type: integer
6911+
periodSeconds:
6912+
default: 10
6913+
description: |-
6914+
PeriodSeconds is the number of seconds between consecutive readiness probes.
6915+
If not specified, the default is 10 seconds.
6916+
format: int32
6917+
maximum: 3600
6918+
minimum: 1
6919+
type: integer
6920+
port:
6921+
default: 8081
6922+
description: |-
6923+
Port is the port on which the readiness endpoint is exposed.
6924+
If not specified, the default port is 8081.
6925+
format: int32
6926+
maximum: 65535
6927+
minimum: 1
6928+
type: integer
6929+
timeoutSeconds:
6930+
default: 1
6931+
description: |-
6932+
TimeoutSeconds is the number of seconds after which the readiness probe times out.
6933+
If not specified, the default is 1 second.
6934+
format: int32
6935+
maximum: 3600
6936+
minimum: 1
6937+
type: integer
6938+
type: object
68976939
service:
68986940
description: Service is the configuration for the NGINX Service.
68996941
properties:

deploy/azure/deploy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ spec:
421421
nodeSelector:
422422
kubernetes.io/os: linux
423423
replicas: 1
424+
readinessProbe:
425+
initialDelaySeconds: 3
426+
periodSeconds: 10
427+
port: 8081
428+
timeoutSeconds: 1
424429
service:
425430
externalTrafficPolicy: Local
426431
type: LoadBalancer

deploy/crds.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7479,6 +7479,48 @@ spec:
74797479
format: int32
74807480
type: integer
74817481
type: object
7482+
readinessProbe:
7483+
description: ReadinessProbe is the configuration for the NGINX
7484+
Readiness probe.
7485+
properties:
7486+
initialDelaySeconds:
7487+
default: 3
7488+
description: |-
7489+
InitialDelaySeconds is the number of seconds after the container has
7490+
started before the readiness probe is initiated.
7491+
If not specified, the default is 3 seconds.
7492+
format: int32
7493+
maximum: 3600
7494+
minimum: 0
7495+
type: integer
7496+
periodSeconds:
7497+
default: 10
7498+
description: |-
7499+
PeriodSeconds is the number of seconds between consecutive readiness probes.
7500+
If not specified, the default is 10 seconds.
7501+
format: int32
7502+
maximum: 3600
7503+
minimum: 1
7504+
type: integer
7505+
port:
7506+
default: 8081
7507+
description: |-
7508+
Port is the port on which the readiness endpoint is exposed.
7509+
If not specified, the default port is 8081.
7510+
format: int32
7511+
maximum: 65535
7512+
minimum: 1
7513+
type: integer
7514+
timeoutSeconds:
7515+
default: 1
7516+
description: |-
7517+
TimeoutSeconds is the number of seconds after which the readiness probe times out.
7518+
If not specified, the default is 1 second.
7519+
format: int32
7520+
maximum: 3600
7521+
minimum: 1
7522+
type: integer
7523+
type: object
74827524
service:
74837525
description: Service is the configuration for the NGINX Service.
74847526
properties:

deploy/default/deploy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ spec:
416416
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx
417417
tag: edge
418418
replicas: 1
419+
readinessProbe:
420+
initialDelaySeconds: 3
421+
periodSeconds: 10
422+
port: 8081
423+
timeoutSeconds: 1
419424
service:
420425
externalTrafficPolicy: Local
421426
type: LoadBalancer

0 commit comments

Comments
 (0)