File tree Expand file tree Collapse file tree 10 files changed +125
-104
lines changed
charts/nginx-gateway-fabric
snippets-filters-nginx-plus
internal/mode/static/nginx/config Expand file tree Collapse file tree 10 files changed +125
-104
lines changed Original file line number Diff line number Diff line change 519
519
"required" : [],
520
520
"title" : " securityContext" ,
521
521
"type" : " object"
522
+ },
523
+ "snippetsFilters" : {
524
+ "properties" : {
525
+ "enable" : {
526
+ "default" : false ,
527
+ "description" : " Enable SnippetsFilters feature. SnippetsFilters allow inserting NGINX configuration into the generated NGINX\n config for HTTPRoute and GRPCRoute resources." ,
528
+ "required" : [],
529
+ "title" : " enable" ,
530
+ "type" : " boolean"
531
+ }
532
+ },
533
+ "required" : [],
534
+ "title" : " snippetsFilters" ,
535
+ "type" : " object"
522
536
}
523
537
},
524
538
"required" : [
Original file line number Diff line number Diff line change @@ -153,6 +153,19 @@ subjects:
153
153
namespace : nginx-gateway
154
154
---
155
155
apiVersion : v1
156
+ data :
157
+ main.conf : |
158
+ error_log stderr info;
159
+ kind : ConfigMap
160
+ metadata :
161
+ labels :
162
+ app.kubernetes.io/instance : nginx-gateway
163
+ app.kubernetes.io/name : nginx-gateway
164
+ app.kubernetes.io/version : edge
165
+ name : nginx-includes
166
+ namespace : nginx-gateway
167
+ ---
168
+ apiVersion : v1
156
169
kind : Service
157
170
metadata :
158
171
labels :
@@ -299,6 +312,33 @@ spec:
299
312
name : nginx-cache
300
313
- mountPath : /etc/nginx/includes
301
314
name : nginx-includes
315
+ initContainers :
316
+ - command :
317
+ - /usr/bin/gateway
318
+ - copy
319
+ - --source
320
+ - /includes/main.conf
321
+ - --destination
322
+ - /etc/nginx/main-includes/main.conf
323
+ image : ghcr.io/nginxinc/nginx-gateway-fabric:edge
324
+ imagePullPolicy : Always
325
+ name : copy-nginx-config
326
+ securityContext :
327
+ capabilities :
328
+ add :
329
+ - KILL
330
+ drop :
331
+ - ALL
332
+ readOnlyRootFilesystem : true
333
+ runAsGroup : 1001
334
+ runAsUser : 102
335
+ seccompProfile :
336
+ type : RuntimeDefault
337
+ volumeMounts :
338
+ - mountPath : /includes
339
+ name : nginx-includes-configmap
340
+ - mountPath : /etc/nginx/main-includes
341
+ name : nginx-main-includes
302
342
securityContext :
303
343
fsGroup : 1001
304
344
runAsNonRoot : true
@@ -320,6 +360,9 @@ spec:
320
360
name : nginx-cache
321
361
- emptyDir : {}
322
362
name : nginx-includes
363
+ - configMap :
364
+ name : nginx-includes
365
+ name : nginx-includes-configmap
323
366
---
324
367
apiVersion : gateway.networking.k8s.io/v1
325
368
kind : GatewayClass
Original file line number Diff line number Diff line change @@ -145,6 +145,19 @@ subjects:
145
145
namespace : nginx-gateway
146
146
---
147
147
apiVersion : v1
148
+ data :
149
+ main.conf : |
150
+ error_log stderr info;
151
+ kind : ConfigMap
152
+ metadata :
153
+ labels :
154
+ app.kubernetes.io/instance : nginx-gateway
155
+ app.kubernetes.io/name : nginx-gateway
156
+ app.kubernetes.io/version : edge
157
+ name : nginx-includes
158
+ namespace : nginx-gateway
159
+ ---
160
+ apiVersion : v1
148
161
kind : Service
149
162
metadata :
150
163
labels :
@@ -290,6 +303,33 @@ spec:
290
303
name : nginx-cache
291
304
- mountPath : /etc/nginx/includes
292
305
name : nginx-includes
306
+ initContainers :
307
+ - command :
308
+ - /usr/bin/gateway
309
+ - copy
310
+ - --source
311
+ - /includes/main.conf
312
+ - --destination
313
+ - /etc/nginx/main-includes/main.conf
314
+ image : ghcr.io/nginxinc/nginx-gateway-fabric:edge
315
+ imagePullPolicy : Always
316
+ name : copy-nginx-config
317
+ securityContext :
318
+ capabilities :
319
+ add :
320
+ - KILL
321
+ drop :
322
+ - ALL
323
+ readOnlyRootFilesystem : true
324
+ runAsGroup : 1001
325
+ runAsUser : 102
326
+ seccompProfile :
327
+ type : RuntimeDefault
328
+ volumeMounts :
329
+ - mountPath : /includes
330
+ name : nginx-includes-configmap
331
+ - mountPath : /etc/nginx/main-includes
332
+ name : nginx-main-includes
293
333
securityContext :
294
334
fsGroup : 1001
295
335
runAsNonRoot : true
@@ -311,6 +351,9 @@ spec:
311
351
name : nginx-cache
312
352
- emptyDir : {}
313
353
name : nginx-includes
354
+ - configMap :
355
+ name : nginx-includes
356
+ name : nginx-includes-configmap
314
357
---
315
358
apiVersion : gateway.networking.k8s.io/v1
316
359
kind : GatewayClass
Original file line number Diff line number Diff line change @@ -146,7 +146,6 @@ func (g GeneratorImpl) getExecuteFuncs(generator policies.Generator) []executeFu
146
146
g .executeStreamUpstreams ,
147
147
executeStreamMaps ,
148
148
executeVersion ,
149
- executeMainIncludesConfig ,
150
149
}
151
150
}
152
151
Original file line number Diff line number Diff line change @@ -11,16 +11,16 @@ import (
11
11
var mainConfigTemplate = gotemplate .Must (gotemplate .New ("main" ).Parse (mainConfigTemplateText ))
12
12
13
13
type mainConfig struct {
14
- Includes []shared.Include
15
- TelemetryEnabled bool
14
+ Includes []shared.Include
15
+ Conf dataplane. Configuration
16
16
}
17
17
18
18
func executeMainConfig (conf dataplane.Configuration ) []executeResult {
19
19
includes := createIncludesFromSnippets (conf .MainSnippets )
20
20
21
21
mc := mainConfig {
22
- TelemetryEnabled : conf . Telemetry . Endpoint != "" ,
23
- Includes : includes ,
22
+ Conf : conf ,
23
+ Includes : includes ,
24
24
}
25
25
26
26
results := make ([]executeResult , 0 , len (includes )+ 1 )
Original file line number Diff line number Diff line change 1
1
package config
2
2
3
3
const mainConfigTemplateText = `
4
- {{ if .TelemetryEnabled -}}
4
+ {{ if .Conf.Telemetry.Endpoint -}}
5
5
load_module modules/ngx_otel_module.so;
6
6
{{ end -}}
7
7
8
+ error_log stderr {{ .Conf.Logging.ErrorLevel }};
9
+
8
10
{{ range $i := .Includes -}}
9
11
include {{ $i.Name }};
10
12
{{ end -}}
Original file line number Diff line number Diff line change @@ -56,6 +56,24 @@ func TestExecuteMainConfig_Telemetry(t *testing.T) {
56
56
}
57
57
}
58
58
59
+ func TestExecuteMainConfig_Logging (t * testing.T ) {
60
+ t .Parallel ()
61
+
62
+ conf := dataplane.Configuration {
63
+ Logging : dataplane.Logging {
64
+ ErrorLevel : "info" ,
65
+ },
66
+ }
67
+
68
+ g := NewWithT (t )
69
+
70
+ res := executeMainConfig (conf )
71
+ g .Expect (res ).To (HaveLen (1 ))
72
+ g .Expect (res [0 ].dest ).To (Equal (mainIncludesConfigFile ))
73
+
74
+ g .Expect (string (res [0 ].data )).To (ContainSubstring ("error_log stderr info" ))
75
+ }
76
+
59
77
func TestExecuteMainConfig_Snippets (t * testing.T ) {
60
78
t .Parallel ()
61
79
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments