Skip to content

Commit 05cf128

Browse files
authored
Add vs/vsr snippets support
1 parent 5b354eb commit 05cf128

File tree

20 files changed

+262
-58
lines changed

20 files changed

+262
-58
lines changed

cmd/nginx-ingress/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ var (
132132
enableCustomResources = flag.Bool("enable-custom-resources", true,
133133
"Enable custom resources")
134134

135+
enableSnippets = flag.Bool("enable-snippets", false,
136+
"Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources.")
137+
135138
globalConfiguration = flag.String("global-configuration", "",
136139
`A GlobalConfiguration resource for global configuration of the Ingress Controller. Requires -enable-custom-resources. If the flag is set,
137140
but the Ingress controller is not able to fetch the corresponding resource from Kubernetes API, the Ingress Controller
@@ -392,6 +395,7 @@ func main() {
392395
NginxStatusPort: *nginxStatusPort,
393396
StubStatusOverUnixSocketForOSS: *enablePrometheusMetrics,
394397
TLSPassthrough: *enableTLSPassthrough,
398+
EnableSnippets: *enableSnippets,
395399
SpiffeCerts: *spireAgentAddress != "",
396400
}
397401

deployments/common/vs-definition.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ spec:
5959
properties:
6060
host:
6161
type: string
62+
http-snippets:
63+
type: string
6264
ingressClassName:
6365
type: string
6466
routes:
@@ -186,6 +188,8 @@ spec:
186188
type: string
187189
type:
188190
type: string
191+
location-snippets:
192+
type: string
189193
matches:
190194
type: array
191195
items:
@@ -474,6 +478,8 @@ spec:
474478
type: string
475479
weight:
476480
type: integer
481+
server-snippets:
482+
type: string
477483
tls:
478484
description: TLS defines TLS configuration for a VirtualServer.
479485
type: object

deployments/common/vsr-definition.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ spec:
184184
type: string
185185
type:
186186
type: string
187+
location-snippets:
188+
type: string
187189
matches:
188190
type: array
189191
items:

deployments/helm-chart/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ Parameter | Description | Default
210210
`controller.watchNamespace` | Namespace to watch for Ingress resources. By default the Ingress controller watches all namespaces. | ""
211211
`controller.enableCustomResources` | Enable the custom resources. | true
212212
`controller.enableTLSPassthrough` | Enable TLS Passthrough on port 443. Requires `controller.enableCustomResources`. | false
213+
`controller.enableSnippets` | Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources. | false
213214
`controller.healthStatus` | Add a location "/nginx-health" to the default server. The location responds with the 200 status code for any request. Useful for external health-checking of the Ingress controller. | false
214215
`controller.healthStatusURI` | Sets the URI of health status location in the default server. Requires `contoller.healthStatus`. | "/nginx-health"
215216
`controller.nginxStatus.enable` | Enable the NGINX stub_status, or the NGINX Plus API. | true

deployments/helm-chart/crds/virtualserver.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ spec:
6161
description: VirtualServerSpec is the spec of the VirtualServer resource.
6262
type: object
6363
properties:
64-
ingressClassName:
65-
type: string
6664
host:
6765
type: string
66+
http-snippets:
67+
type: string
68+
ingressClassName:
69+
type: string
6870
routes:
6971
type: array
7072
items:
@@ -190,6 +192,8 @@ spec:
190192
type: string
191193
type:
192194
type: string
195+
location-snippets:
196+
type: string
193197
matches:
194198
type: array
195199
items:
@@ -478,6 +482,8 @@ spec:
478482
type: string
479483
weight:
480484
type: integer
485+
server-snippets:
486+
type: string
481487
tls:
482488
description: TLS defines TLS configuration for a VirtualServer.
483489
type: object

deployments/helm-chart/crds/virtualserverroute.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ spec:
188188
type: string
189189
type:
190190
type: string
191+
location-snippets:
192+
type: string
191193
matches:
192194
type: array
193195
items:

deployments/helm-chart/templates/controller-daemonset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,6 @@ spec:
130130
- -enable-custom-resources={{ .Values.controller.enableCustomResources }}
131131
{{- if .Values.controller.enableCustomResources }}
132132
- -enable-tls-passthrough={{ .Values.controller.enableTLSPassthrough }}
133+
- -enable-snippets={{ .Values.controller.enableSnippets }}
133134
{{- end }}
134135
{{- end }}

deployments/helm-chart/templates/controller-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,6 @@ spec:
128128
- -enable-custom-resources={{ .Values.controller.enableCustomResources }}
129129
{{- if .Values.controller.enableCustomResources }}
130130
- -enable-tls-passthrough={{ .Values.controller.enableTLSPassthrough }}
131+
- -enable-snippets={{ .Values.controller.enableSnippets }}
131132
{{- end }}
132133
{{- end }}

deployments/helm-chart/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ controller:
124124
## Enable TLS Passthrough on port 443. Requires controller.enableCustomResources.
125125
enableTLSPassthrough: false
126126

127+
## Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources.
128+
enableSnippets: false
129+
127130
## Add a location based on the value of health-status-uri to the default server. The location responds with the 200 status code for any request.
128131
## Useful for external health-checking of the Ingress controller.
129132
healthStatus: false

docs-web/configuration/global-configuration/command-line-arguments.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The Ingress Controller supports several command-line arguments. Setting the argu
66

77
Below we describe the available command-line arguments:
88
```eval_rst
9+
.. option:: -enable-snippets
10+
11+
Enable custom NGINX configuration snippets in VirtualServer and VirtualServerRoute resources. (default false)
12+
913
.. option:: -default-server-tls-secret <string>
1014
1115
Secret with a TLS certificate and key for TLS termination of the default server.
@@ -27,11 +31,11 @@ Below we describe the available command-line arguments:
2731
2832
.. option:: -enable-custom-resources
2933
30-
Enables custom resources (default true)
34+
Enables custom resources. (default true)
3135
3236
.. option:: -enable-leader-election
3337
34-
Enables Leader election to avoid multiple replicas of the controller reporting the status of Ingress, VirtualServer and VirtualServerRoute resources -- only one replica will report status (default true).
38+
Enables Leader election to avoid multiple replicas of the controller reporting the status of Ingress, VirtualServer and VirtualServerRoute resources -- only one replica will report status. (default true)
3539
3640
See :option:`-report-ingress-status` flag.
3741
@@ -161,13 +165,13 @@ Below we describe the available command-line arguments:
161165
162166
Enables exposing NGINX or NGINX Plus metrics in the Prometheus format.
163167
164-
.. option:: -prometheus-metrics-listen-port
168+
.. option:: -prometheus-metrics-listen-port <int>
165169
166170
Sets the port where the Prometheus metrics are exposed.
167171
168172
Format: ``[1023 - 65535]`` (default 9113)
169173
170-
.. option:: -spire-agent-address
174+
.. option:: -spire-agent-address <string>
171175
172176
Specifies the address of a running Spire agent. **For use with NGINX Service Mesh only**.
173177

0 commit comments

Comments
 (0)