Skip to content

Commit 1dbe45a

Browse files
authored
Add flag to opt out of product telemetry (#1605)
Problem: As a user of NGF I want an easy option to opt out of recording and sending of all telemetry data So that if I am not comfortable sending that information, I can still continue to use NGF Solution: Added a new configurable flag that can disable telemetry. On by default. Also turns off any RBAC if not needed (for N+ usage or telemetry)
1 parent a66255b commit 1dbe45a

File tree

12 files changed

+128
-85
lines changed

12 files changed

+128
-85
lines changed

cmd/gateway/commands.go

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,24 @@ func createRootCommand() *cobra.Command {
4444
func createStaticModeCommand() *cobra.Command {
4545
// flag names
4646
const (
47-
gatewayFlag = "gateway"
48-
configFlag = "config"
49-
serviceFlag = "service"
50-
updateGCStatusFlag = "update-gatewayclass-status"
51-
metricsDisableFlag = "metrics-disable"
52-
metricsSecureFlag = "metrics-secure-serving"
53-
metricsPortFlag = "metrics-port"
54-
healthDisableFlag = "health-disable"
55-
healthPortFlag = "health-port"
56-
leaderElectionDisableFlag = "leader-election-disable"
57-
leaderElectionLockNameFlag = "leader-election-lock-name"
58-
plusFlag = "nginx-plus"
59-
gwAPIExperimentalFlag = "gateway-api-experimental-features"
60-
usageReportSecretFlag = "usage-report-secret"
61-
usageReportServerURLFlag = "usage-report-server-url"
62-
usageReportSkipVerifyFlag = "usage-report-skip-verify"
63-
usageReportClusterNameFlag = "usage-report-cluster-name"
47+
gatewayFlag = "gateway"
48+
configFlag = "config"
49+
serviceFlag = "service"
50+
updateGCStatusFlag = "update-gatewayclass-status"
51+
metricsDisableFlag = "metrics-disable"
52+
metricsSecureFlag = "metrics-secure-serving"
53+
metricsPortFlag = "metrics-port"
54+
healthDisableFlag = "health-disable"
55+
healthPortFlag = "health-port"
56+
leaderElectionDisableFlag = "leader-election-disable"
57+
leaderElectionLockNameFlag = "leader-election-lock-name"
58+
productTelemetryDisableFlag = "product-telemetry-disable"
59+
plusFlag = "nginx-plus"
60+
gwAPIExperimentalFlag = "gateway-api-experimental-features"
61+
usageReportSecretFlag = "usage-report-secret"
62+
usageReportServerURLFlag = "usage-report-server-url"
63+
usageReportSkipVerifyFlag = "usage-report-skip-verify"
64+
usageReportClusterNameFlag = "usage-report-cluster-name"
6465
)
6566

6667
// flag values
@@ -101,6 +102,8 @@ func createStaticModeCommand() *cobra.Command {
101102

102103
gwExperimentalFeatures bool
103104

105+
disableProductTelemetry bool
106+
104107
plus bool
105108
usageReportSkipVerify bool
106109
usageReportClusterName = stringValidatingValue{
@@ -203,12 +206,15 @@ func createStaticModeCommand() *cobra.Command {
203206
LockName: leaderElectionLockName.String(),
204207
Identity: podName,
205208
},
206-
UsageReportConfig: usageReportConfig,
207-
Plus: plus,
208-
TelemetryReportPeriod: period,
209-
Version: version,
210-
ExperimentalFeatures: gwExperimentalFeatures,
211-
ImageSource: imageSource,
209+
UsageReportConfig: usageReportConfig,
210+
ProductTelemetryConfig: config.ProductTelemetryConfig{
211+
TelemetryReportPeriod: period,
212+
Enabled: !disableProductTelemetry,
213+
},
214+
Plus: plus,
215+
Version: version,
216+
ExperimentalFeatures: gwExperimentalFeatures,
217+
ImageSource: imageSource,
212218
}
213219

214220
if err := static.StartManager(conf); err != nil {
@@ -315,6 +321,13 @@ func createStaticModeCommand() *cobra.Command {
315321
"A Lease object with this name will be created in the same Namespace as the controller.",
316322
)
317323

324+
cmd.Flags().BoolVar(
325+
&disableProductTelemetry,
326+
productTelemetryDisableFlag,
327+
false,
328+
"Disable the collection of product telemetry.",
329+
)
330+
318331
cmd.Flags().BoolVar(
319332
&plus,
320333
plusFlag,

deploy/helm-chart/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ The following tables lists the configurable parameters of the NGINX Gateway Fabr
293293
| `nginxGateway.replicaCount` | The number of replicas of the NGINX Gateway Fabric Deployment. | 1 |
294294
| `nginxGateway.leaderElection.enable` | Enable leader election. Leader election is used to avoid multiple replicas of the NGINX Gateway Fabric reporting the status of the Gateway API resources. | true |
295295
| `nginxGateway.leaderElection.lockName` | The name of the leader election lock. A Lease object with this name will be created in the same Namespace as the controller. | Autogenerated |
296+
| `nginxGateway.securityContext.allowPrivilegeEscalation` | Some environments may need this set to true in order for the control plane to successfully reload NGINX. | false |
297+
| `nginxGateway.productTelemetry.enable` | Enable the collection of product telemetry. | true |
298+
| `nginxGateway.gwAPIExperimentalFeatures.enable` | Enable the experimental features of Gateway API which are supported by NGINX Gateway Fabric. Requires the Gateway APIs installed from the experimental channel. | false |
296299
| `nginx.image.repository` | The repository for the NGINX image. | ghcr.io/nginxinc/nginx-gateway-fabric/nginx |
297300
| `nginx.image.tag` | The tag for the NGINX image. | edge |
298301
| `nginx.image.pullPolicy` | The `imagePullPolicy` for the NGINX image. | Always |

deploy/helm-chart/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ spec:
5252
{{- else }}
5353
- --leader-election-disable
5454
{{- end }}
55+
{{- if not .Values.nginxGateway.productTelemetry.enable }}
56+
- --product-telemetry-disable
57+
{{- end }}
5558
{{- if .Values.nginxGateway.gwAPIExperimentalFeatures.enable }}
5659
- --gateway-api-experimental-features
5760
{{- end }}

deploy/helm-chart/templates/rbac.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,43 @@ rules:
3939
- get
4040
- list
4141
- watch
42-
# FIXME(bjee19): make nodes, pods, replicasets permission dependent on telemetry being enabled.
43-
# https://github.com/nginxinc/nginx-gateway-fabric/issues/1317.
42+
{{- if .Values.nginxGateway.productTelemetry.enable }}
4443
- apiGroups:
4544
- ""
4645
resources:
4746
- pods
4847
verbs:
4948
- get
49+
- apiGroups:
50+
- apps
51+
resources:
52+
- replicasets
53+
verbs:
54+
- get
55+
{{- end }}
56+
{{- if .Values.nginx.plus }}
57+
- apiGroups:
58+
- apps
59+
resources:
60+
- replicasets
61+
verbs:
62+
- list
63+
{{- end }}
64+
{{- if or .Values.nginxGateway.productTelemetry.enable .Values.nginx.plus }}
5065
- apiGroups:
5166
- ""
5267
resources:
5368
- nodes
5469
verbs:
5570
- list
71+
{{- end }}
5672
- apiGroups:
5773
- ""
5874
resources:
5975
- events
6076
verbs:
6177
- create
6278
- patch
63-
- apiGroups:
64-
- apps
65-
resources:
66-
- replicasets
67-
verbs:
68-
- get
69-
- list
7079
- apiGroups:
7180
- discovery.k8s.io
7281
resources:

deploy/helm-chart/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ nginxGateway:
4545
## Some environments may need this set to true in order for the control plane to successfully reload NGINX.
4646
allowPrivilegeEscalation: false
4747

48+
productTelemetry:
49+
## Enable the collection of product telemetry.
50+
enable: true
51+
4852
## The lifecycle of the nginx-gateway container.
4953
lifecycle: {}
5054

deploy/manifests/nginx-gateway-experimental.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ rules:
3737
- get
3838
- list
3939
- watch
40-
# FIXME(bjee19): make nodes, pods, replicasets permission dependent on telemetry being enabled.
41-
# https://github.com/nginxinc/nginx-gateway-fabric/issues/1317.
4240
- apiGroups:
4341
- ""
4442
resources:
4543
- pods
4644
verbs:
4745
- get
46+
- apiGroups:
47+
- apps
48+
resources:
49+
- replicasets
50+
verbs:
51+
- get
4852
- apiGroups:
4953
- ""
5054
resources:
@@ -58,13 +62,6 @@ rules:
5862
verbs:
5963
- create
6064
- patch
61-
- apiGroups:
62-
- apps
63-
resources:
64-
- replicasets
65-
verbs:
66-
- get
67-
- list
6865
- apiGroups:
6966
- discovery.k8s.io
7067
resources:

deploy/manifests/nginx-gateway.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ rules:
3636
- get
3737
- list
3838
- watch
39-
# FIXME(bjee19): make nodes, pods, replicasets permission dependent on telemetry being enabled.
40-
# https://github.com/nginxinc/nginx-gateway-fabric/issues/1317.
4139
- apiGroups:
4240
- ""
4341
resources:
4442
- pods
4543
verbs:
4644
- get
45+
- apiGroups:
46+
- apps
47+
resources:
48+
- replicasets
49+
verbs:
50+
- get
4751
- apiGroups:
4852
- ""
4953
resources:
@@ -57,13 +61,6 @@ rules:
5761
verbs:
5862
- create
5963
- patch
60-
- apiGroups:
61-
- apps
62-
resources:
63-
- replicasets
64-
verbs:
65-
- get
66-
- list
6764
- apiGroups:
6865
- discovery.k8s.io
6966
resources:

deploy/manifests/nginx-plus-gateway-experimental.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,24 @@ rules:
3737
- get
3838
- list
3939
- watch
40-
# FIXME(bjee19): make nodes, pods, replicasets permission dependent on telemetry being enabled.
41-
# https://github.com/nginxinc/nginx-gateway-fabric/issues/1317.
4240
- apiGroups:
4341
- ""
4442
resources:
4543
- pods
4644
verbs:
4745
- get
46+
- apiGroups:
47+
- apps
48+
resources:
49+
- replicasets
50+
verbs:
51+
- get
52+
- apiGroups:
53+
- apps
54+
resources:
55+
- replicasets
56+
verbs:
57+
- list
4858
- apiGroups:
4959
- ""
5060
resources:
@@ -58,13 +68,6 @@ rules:
5868
verbs:
5969
- create
6070
- patch
61-
- apiGroups:
62-
- apps
63-
resources:
64-
- replicasets
65-
verbs:
66-
- get
67-
- list
6871
- apiGroups:
6972
- discovery.k8s.io
7073
resources:

deploy/manifests/nginx-plus-gateway.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,24 @@ rules:
3636
- get
3737
- list
3838
- watch
39-
# FIXME(bjee19): make nodes, pods, replicasets permission dependent on telemetry being enabled.
40-
# https://github.com/nginxinc/nginx-gateway-fabric/issues/1317.
4139
- apiGroups:
4240
- ""
4341
resources:
4442
- pods
4543
verbs:
4644
- get
45+
- apiGroups:
46+
- apps
47+
resources:
48+
- replicasets
49+
verbs:
50+
- get
51+
- apiGroups:
52+
- apps
53+
resources:
54+
- replicasets
55+
verbs:
56+
- list
4757
- apiGroups:
4858
- ""
4959
resources:
@@ -57,13 +67,6 @@ rules:
5767
verbs:
5868
- create
5969
- patch
60-
- apiGroups:
61-
- apps
62-
resources:
63-
- replicasets
64-
verbs:
65-
- get
66-
- list
6770
- apiGroups:
6871
- discovery.k8s.io
6972
resources:

internal/mode/static/config/config.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ type Config struct {
3636
MetricsConfig MetricsConfig
3737
// HealthConfig specifies the health probe config.
3838
HealthConfig HealthConfig
39-
// TelemetryReportPeriod is the period at which telemetry reports are sent.
40-
TelemetryReportPeriod time.Duration
39+
// ProductTelemetryConfig contains the configuration for collecting product telemetry.
40+
ProductTelemetryConfig ProductTelemetryConfig
4141
// UpdateGatewayClassStatus enables updating the status of the GatewayClass resource.
4242
UpdateGatewayClassStatus bool
4343
// Plus indicates whether NGINX Plus is being used.
@@ -86,6 +86,14 @@ type LeaderElectionConfig struct {
8686
Enabled bool
8787
}
8888

89+
// ProductTelemetryConfig contains the configuration for collecting product telemetry.
90+
type ProductTelemetryConfig struct {
91+
// TelemetryReportPeriod is the period at which telemetry reports are sent.
92+
TelemetryReportPeriod time.Duration
93+
// Enabled is the flag for toggling the collection of product telemetry.
94+
Enabled bool
95+
}
96+
8997
// UsageReportConfig contains the configuration for NGINX Plus usage reporting.
9098
type UsageReportConfig struct {
9199
// SecretNsName is the namespaced name of the Secret containing the server credentials.

0 commit comments

Comments
 (0)