Skip to content

Commit 83267c5

Browse files
committed
Add EnforceInitialReport variable everywhere
1 parent 635b3fc commit 83267c5

File tree

12 files changed

+94
-48
lines changed

12 files changed

+94
-48
lines changed

charts/nginx-gateway-fabric/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
207207
| `certGenerator.ttlSecondsAfterFinished` | How long to wait after the cert generator job has finished before it is removed by the job controller. | int | `30` |
208208
| `clusterDomain` | The DNS cluster domain of your Kubernetes cluster. | string | `"cluster.local"` |
209209
| `gateways` | A list of Gateway objects. View https://gateway-api.sigs.k8s.io/reference/spec/#gateway for full Gateway reference. | list | `[]` |
210-
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"autoscaling":{"enable":false},"config":{},"container":{"hostPorts":[],"lifecycle":{},"readinessProbe":{},"resources":{},"volumeMounts":[]},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","nginxOneConsole":{"dataplaneKeySecretName":"","endpointHost":"agent.connect.nginx.com","endpointPort":443,"skipVerify":false},"patches":[],"plus":false,"pod":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"patches":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
210+
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"autoscaling":{"enable":false},"config":{},"container":{"hostPorts":[],"lifecycle":{},"readinessProbe":{},"resources":{},"volumeMounts":[]},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","nginxOneConsole":{"dataplaneKeySecretName":"","endpointHost":"agent.connect.nginx.com","endpointPort":443,"skipVerify":false},"patches":[],"plus":false,"pod":{},"replicas":1,"service":{"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"patches":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","enforceInitialReport":false,"resolver":"","secretName":"nplus-license","skipVerify":false}}` |
211211
| `nginx.autoscaling` | Autoscaling configuration for the NGINX data plane. | object | `{"enable":false}` |
212212
| `nginx.autoscaling.enable` | Enable or disable Horizontal Pod Autoscaler for the NGINX data plane. | bool | `false` |
213213
| `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 | `{}` |
@@ -241,6 +241,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
241241
| `nginx.usage.caSecretName` | The name of the Secret containing the NGINX Instance Manager CA certificate. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `""` |
242242
| `nginx.usage.clientSSLSecretName` | The name of the Secret containing the client certificate and key for authenticating with NGINX Instance Manager. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `""` |
243243
| `nginx.usage.endpoint` | The endpoint of the NGINX Plus usage reporting server. Default: product.connect.nginx.com | string | `""` |
244+
| `nginx.usage.enforceInitialReport` | Enable enforcement of the initial NGINX Plus licensing report. If set to false, the initial report is not enforced. | bool | `false` |
244245
| `nginx.usage.resolver` | The nameserver used to resolve the NGINX Plus usage reporting endpoint. Used with NGINX Instance Manager. | string | `""` |
245246
| `nginx.usage.secretName` | The name of the Secret containing the JWT for NGINX Plus usage reporting. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `"nplus-license"` |
246247
| `nginx.usage.skipVerify` | Disable client verification of the NGINX Plus usage reporting server certificate. | bool | `false` |

charts/nginx-gateway-fabric/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,14 @@ Filters out empty fields from a struct.
110110
{{- $result | toYaml -}}
111111
{{- end -}}
112112
{{- end }}
113+
114+
{{/*
115+
Enforcing the initial NGINX Plus licensing report.
116+
*/}}
117+
{{- define "nginx-gateway.enforceInitialReport" -}}
118+
{{- if .Values.Usage.enforceInitialReport }}
119+
enforce_initial_report on;
120+
{{- else }}
121+
enforce_initial_report off;
122+
{{- end }}
123+
{{- end }}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ spec:
7272
{{- if .Values.nginx.usage.clientSSLSecretName }}
7373
- --usage-report-client-ssl-secret={{ .Values.nginx.usage.clientSSLSecretName }}
7474
{{- end }}
75+
{{- if .Values.nginx.usage.enforceInitialReport }}
76+
- --usage-report-enforce-initial-report={{ .Values.nginx.usage.enforceInitialReport }}
77+
{{- end }}
7578
{{- end }}
7679
{{- if .Values.nginxGateway.metrics.enable }}
7780
- --metrics-port={{ .Values.nginxGateway.metrics.port }}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,13 @@
692692
"title": "endpoint",
693693
"type": "string"
694694
},
695+
"enforceInitialReport": {
696+
"default": false,
697+
"description": "Enable enforcement of the initial NGINX Plus licensing report. If set to false, the initial report is not enforced.",
698+
"required": [],
699+
"title": "enforceInitialReport",
700+
"type": "boolean"
701+
},
695702
"resolver": {
696703
"default": "",
697704
"description": "The nameserver used to resolve the NGINX Plus usage reporting endpoint. Used with NGINX Instance Manager.",

charts/nginx-gateway-fabric/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ nginx:
337337
# Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway).
338338
clientSSLSecretName: ""
339339

340+
# -- Enable enforcement of the initial NGINX Plus licensing report. If set to false, the initial report is not enforced.
341+
enforceInitialReport: false
342+
340343
# @schema
341344
# type: object
342345
# properties:

cmd/gateway/commands.go

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,32 @@ func createRootCommand() *cobra.Command {
5858
func createControllerCommand() *cobra.Command {
5959
// flag names
6060
const (
61-
configFlag = "config"
62-
serviceFlag = "service"
63-
agentTLSSecretFlag = "agent-tls-secret"
64-
nginxOneDataplaneKeySecretFlag = "nginx-one-dataplane-key-secret" //nolint:gosec // not credentials
65-
nginxOneTelemetryEndpointHostFlag = "nginx-one-telemetry-endpoint-host"
66-
nginxOneTelemetryEndpointPortFlag = "nginx-one-telemetry-endpoint-port"
67-
nginxOneTLSSkipVerifyFlag = "nginx-one-tls-skip-verify"
68-
metricsDisableFlag = "metrics-disable"
69-
metricsSecureFlag = "metrics-secure-serving"
70-
metricsPortFlag = "metrics-port"
71-
healthDisableFlag = "health-disable"
72-
healthPortFlag = "health-port"
73-
leaderElectionDisableFlag = "leader-election-disable"
74-
leaderElectionLockNameFlag = "leader-election-lock-name"
75-
productTelemetryDisableFlag = "product-telemetry-disable"
76-
gwAPIExperimentalFlag = "gateway-api-experimental-features"
77-
nginxDockerSecretFlag = "nginx-docker-secret" //nolint:gosec // not credentials
78-
usageReportSecretFlag = "usage-report-secret"
79-
usageReportEndpointFlag = "usage-report-endpoint"
80-
usageReportResolverFlag = "usage-report-resolver"
81-
usageReportSkipVerifyFlag = "usage-report-skip-verify"
82-
usageReportClientSSLSecretFlag = "usage-report-client-ssl-secret" //nolint:gosec // not credentials
83-
usageReportCASecretFlag = "usage-report-ca-secret" //nolint:gosec // not credentials
84-
snippetsFiltersFlag = "snippets-filters"
85-
nginxSCCFlag = "nginx-scc"
61+
configFlag = "config"
62+
serviceFlag = "service"
63+
agentTLSSecretFlag = "agent-tls-secret"
64+
nginxOneDataplaneKeySecretFlag = "nginx-one-dataplane-key-secret" //nolint:gosec // not credentials
65+
nginxOneTelemetryEndpointHostFlag = "nginx-one-telemetry-endpoint-host"
66+
nginxOneTelemetryEndpointPortFlag = "nginx-one-telemetry-endpoint-port"
67+
nginxOneTLSSkipVerifyFlag = "nginx-one-tls-skip-verify"
68+
metricsDisableFlag = "metrics-disable"
69+
metricsSecureFlag = "metrics-secure-serving"
70+
metricsPortFlag = "metrics-port"
71+
healthDisableFlag = "health-disable"
72+
healthPortFlag = "health-port"
73+
leaderElectionDisableFlag = "leader-election-disable"
74+
leaderElectionLockNameFlag = "leader-election-lock-name"
75+
productTelemetryDisableFlag = "product-telemetry-disable"
76+
gwAPIExperimentalFlag = "gateway-api-experimental-features"
77+
nginxDockerSecretFlag = "nginx-docker-secret" //nolint:gosec // not credentials
78+
usageReportSecretFlag = "usage-report-secret"
79+
usageReportEndpointFlag = "usage-report-endpoint"
80+
usageReportResolverFlag = "usage-report-resolver"
81+
usageReportSkipVerifyFlag = "usage-report-skip-verify"
82+
usageReportClientSSLSecretFlag = "usage-report-client-ssl-secret" //nolint:gosec // not credentials
83+
usageReportCASecretFlag = "usage-report-ca-secret" //nolint:gosec // not credentials
84+
snippetsFiltersFlag = "snippets-filters"
85+
nginxSCCFlag = "nginx-scc"
86+
usageReportEnforceInitialReportFlag = "usage-report-enforce-initial-report"
8687
)
8788

8889
// flag values
@@ -165,6 +166,7 @@ func createControllerCommand() *cobra.Command {
165166
usageReportCASecretName = stringValidatingValue{
166167
validator: validateResourceName,
167168
}
169+
usageReportEnforceInitialReport bool
168170
)
169171

170172
cmd := &cobra.Command{
@@ -218,12 +220,13 @@ func createControllerCommand() *cobra.Command {
218220

219221
if plus {
220222
usageReportConfig = config.UsageReportConfig{
221-
SecretName: usageReportSecretName.value,
222-
ClientSSLSecretName: usageReportClientSSLSecretName.value,
223-
CASecretName: usageReportCASecretName.value,
224-
Endpoint: usageReportEndpoint.value,
225-
Resolver: usageReportResolver.value,
226-
SkipVerify: usageReportSkipVerify,
223+
SecretName: usageReportSecretName.value,
224+
ClientSSLSecretName: usageReportClientSSLSecretName.value,
225+
CASecretName: usageReportCASecretName.value,
226+
Endpoint: usageReportEndpoint.value,
227+
Resolver: usageReportResolver.value,
228+
SkipVerify: usageReportSkipVerify,
229+
EnforceInitialReport: usageReportEnforceInitialReport,
227230
}
228231
}
229232

@@ -488,6 +491,13 @@ func createControllerCommand() *cobra.Command {
488491
` Only applicable in OpenShift.`,
489492
)
490493

494+
cmd.Flags().BoolVar(
495+
&usageReportEnforceInitialReport,
496+
usageReportEnforceInitialReportFlag,
497+
false,
498+
"Enable enforcement of the initial NGINX Plus licensing report. If set to false, the initial report is not enforced.",
499+
)
500+
491501
return cmd
492502
}
493503

cmd/gateway/commands_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func TestControllerCmdFlagValidation(t *testing.T) {
154154
"--usage-report-resolver=resolver.com",
155155
"--usage-report-ca-secret=ca-secret",
156156
"--usage-report-client-ssl-secret=client-secret",
157+
"--usage-report-enforce-initial-report=true",
157158
"--snippets-filters",
158159
"--nginx-scc=nginx-sscc-name",
159160
"--nginx-one-dataplane-key-secret=dataplane-key-secret",

internal/controller/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ type UsageReportConfig struct {
125125
Resolver string
126126
// SkipVerify controls whether the nginx verifies the server certificate.
127127
SkipVerify bool
128+
// Enabled is the flag for toggling usage reporting on or off.
129+
EnforceInitialReport bool
128130
}
129131

130132
// Flags contains the NGF command-line flag names and values.

internal/controller/nginx/config/main_config.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ func executeEventsConfig(conf dataplane.Configuration) []executeResult {
5555
}
5656

5757
type mgmtConf struct {
58-
Endpoint string
59-
Resolver string
60-
LicenseTokenFile string
61-
CACertFile string
62-
ClientSSLCertFile string
63-
ClientSSLKeyFile string
64-
SkipVerify bool
58+
Endpoint string
59+
Resolver string
60+
LicenseTokenFile string
61+
CACertFile string
62+
ClientSSLCertFile string
63+
ClientSSLKeyFile string
64+
SkipVerify bool
65+
EnforceInitialReport bool
6566
}
6667

6768
// generateMgmtFiles generates the NGINX Plus configuration file for the mgmt block. As part of this,
@@ -88,10 +89,11 @@ func (g GeneratorImpl) generateMgmtFiles(conf dataplane.Configuration) []agent.F
8889
files := []agent.File{tokenFile}
8990

9091
cfg := mgmtConf{
91-
Endpoint: g.usageReportConfig.Endpoint,
92-
Resolver: g.usageReportConfig.Resolver,
93-
LicenseTokenFile: tokenFile.Meta.Name,
94-
SkipVerify: g.usageReportConfig.SkipVerify,
92+
Endpoint: g.usageReportConfig.Endpoint,
93+
Resolver: g.usageReportConfig.Resolver,
94+
LicenseTokenFile: tokenFile.Meta.Name,
95+
SkipVerify: g.usageReportConfig.SkipVerify,
96+
EnforceInitialReport: g.usageReportConfig.EnforceInitialReport,
9597
}
9698

9799
if content, ok := conf.AuxiliarySecrets[graph.PlusReportCACertificate]; ok {

internal/controller/provisioner/objects.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ func (p *NginxProvisioner) buildNginxConfigMaps(
435435
"SkipVerify": p.cfg.PlusUsageConfig.SkipVerify,
436436
"UsageCASecret": caSecret,
437437
"UsageClientSSLSecret": clientSSLSecret,
438+
"EnforceInitialReport": p.cfg.PlusUsageConfig.EnforceInitialReport,
438439
}
439440

440441
bootstrapCM.Data["mgmt.conf"] = string(helpers.MustExecuteTemplate(mgmtTemplate, mgmtFields))

0 commit comments

Comments
 (0)