Skip to content

Commit 986971e

Browse files
committed
Add support for nginx debug mode in CP/DP split
1 parent 85c6f78 commit 986971e

File tree

17 files changed

+48
-0
lines changed

17 files changed

+48
-0
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ type PodSpec struct {
435435

436436
// ContainerSpec defines container fields for the NGINX container.
437437
type ContainerSpec struct {
438+
// Debug enables debugging for NGINX by using the nginx-debug binary.
439+
//
440+
// +optional
441+
// +kubebuilder:default=false
442+
Debug *bool `json:"debug,omitempty"`
443+
438444
// Image is the NGINX image to use.
439445
//
440446
// +optional

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 5 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/templates/nginxproxy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ spec:
2323
{{- end }}
2424
image:
2525
{{- toYaml .Values.nginx.image | nindent 10 }}
26+
debug: {{ .Values.nginx.debug }}
2627
{{- end }}
2728
{{- if .Values.nginx.service }}
2829
service:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ spec:
7979
description: Container defines container fields for the NGINX
8080
container.
8181
properties:
82+
debug:
83+
default: false
84+
description: Debug enables debugging for NGINX by using
85+
the nginx-debug binary.
86+
type: boolean
8287
image:
8388
description: Image is the NGINX image to use.
8489
properties:

deploy/aws-nlb/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ spec:
301301
kubernetes:
302302
deployment:
303303
container:
304+
debug: false
304305
image:
305306
pullPolicy: Always
306307
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

deploy/azure/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ spec:
303303
kubernetes:
304304
deployment:
305305
container:
306+
debug: false
306307
image:
307308
pullPolicy: Always
308309
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

deploy/crds.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ spec:
664664
description: Container defines container fields for the NGINX
665665
container.
666666
properties:
667+
debug:
668+
default: false
669+
description: Debug enables debugging for NGINX by using
670+
the nginx-debug binary.
671+
type: boolean
667672
image:
668673
description: Image is the NGINX image to use.
669674
properties:

deploy/default/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ spec:
301301
kubernetes:
302302
deployment:
303303
container:
304+
debug: false
304305
image:
305306
pullPolicy: Always
306307
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

deploy/experimental-nginx-plus/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ spec:
308308
kubernetes:
309309
deployment:
310310
container:
311+
debug: false
311312
image:
312313
pullPolicy: Always
313314
repository: private-registry.nginx.com/nginx-gateway-fabric/nginx-plus

deploy/experimental/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ spec:
306306
kubernetes:
307307
deployment:
308308
container:
309+
debug: false
309310
image:
310311
pullPolicy: Always
311312
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

deploy/nginx-plus/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ spec:
303303
kubernetes:
304304
deployment:
305305
container:
306+
debug: false
306307
image:
307308
pullPolicy: Always
308309
repository: private-registry.nginx.com/nginx-gateway-fabric/nginx-plus

deploy/nodeport/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ spec:
301301
kubernetes:
302302
deployment:
303303
container:
304+
debug: false
304305
image:
305306
pullPolicy: Always
306307
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

deploy/openshift/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ spec:
311311
kubernetes:
312312
deployment:
313313
container:
314+
debug: false
314315
image:
315316
pullPolicy: Always
316317
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

deploy/snippets-filters-nginx-plus/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ spec:
306306
kubernetes:
307307
deployment:
308308
container:
309+
debug: false
309310
image:
310311
pullPolicy: Always
311312
repository: private-registry.nginx.com/nginx-gateway-fabric/nginx-plus

deploy/snippets-filters/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ spec:
304304
kubernetes:
305305
deployment:
306306
container:
307+
debug: false
307308
image:
308309
pullPolicy: Always
309310
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx

internal/mode/static/provisioner/objects.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,12 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
447447
}
448448
container.Lifecycle = containerSpec.Lifecycle
449449
container.VolumeMounts = append(container.VolumeMounts, containerSpec.VolumeMounts...)
450+
451+
// ensure that this "effectiveNginxProxy" works
452+
if containerSpec.Debug != nil && *containerSpec.Debug {
453+
container.Command = append(container.Command, "/bin/sh")
454+
container.Args = append(container.Args, "-c", "rm -rf /var/run/nginx/*sock && nginx-debug -g 'daemon off;'")
455+
}
450456
spec.Spec.Containers[0] = container
451457
}
452458
}

internal/mode/static/state/graph/nginxproxy_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func TestBuildEffectiveNginxProxy(t *testing.T) {
5555
logLevel ngfAPIv1alpha2.NginxErrorLogLevel,
5656
setIP bool,
5757
disableHTTP bool,
58+
nginxDebug bool,
5859
) *ngfAPIv1alpha2.NginxProxy {
5960
return &ngfAPIv1alpha2.NginxProxy{
6061
Spec: ngfAPIv1alpha2.NginxProxySpec{
@@ -79,6 +80,13 @@ func TestBuildEffectiveNginxProxy(t *testing.T) {
7980
ErrorLevel: &logLevel,
8081
},
8182
DisableHTTP2: &disableHTTP,
83+
Kubernetes: &ngfAPIv1alpha2.KubernetesSpec{
84+
Deployment: &ngfAPIv1alpha2.DeploymentSpec{
85+
Container: ngfAPIv1alpha2.ContainerSpec{
86+
Debug: &nginxDebug,
87+
},
88+
},
89+
},
8290
},
8391
}
8492
}
@@ -100,6 +108,7 @@ func TestBuildEffectiveNginxProxy(t *testing.T) {
100108
ngfAPIv1alpha2.NginxLogLevelAlert,
101109
true,
102110
false,
111+
false,
103112
)
104113
}
105114

@@ -120,6 +129,7 @@ func TestBuildEffectiveNginxProxy(t *testing.T) {
120129
ngfAPIv1alpha2.NginxLogLevelError,
121130
false,
122131
true,
132+
true,
123133
)
124134
}
125135

0 commit comments

Comments
 (0)