-
Notifications
You must be signed in to change notification settings - Fork 132
feat: add flag to enable anonymous metrics access #3110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -80,22 +80,23 @@ import ( | |||||
| ) | ||||||
|
|
||||||
| const ( | ||||||
| spocCmd string = "spoc" | ||||||
| jsonFlag string = "json" | ||||||
| nodeStatusControllerFlag string = "with-nodestatus-controller" | ||||||
| spodControllerFlag string = "with-spod-controller" | ||||||
| workloadAnnotatorFlag string = "with-workload-annotator" | ||||||
| recordingMergerFlag string = "with-recording-merger" | ||||||
| recordingFlag string = "with-recording" | ||||||
| seccompFlag string = "with-seccomp" | ||||||
| selinuxFlag string = "with-selinux" | ||||||
| apparmorFlag string = "with-apparmor" | ||||||
| webhookFlag string = "webhook" | ||||||
| memOptimFlag string = "with-mem-optim" | ||||||
| defaultWebhookPort int = 9443 | ||||||
| auditLogIntervalSecondsParam string = "audit-log-interval-seconds" | ||||||
| auditLogPathParam string = "audit-log-path" | ||||||
| auditLogMaxSizeParam string = "audit-log-maxsize" | ||||||
| spocCmd string = "spoc" | ||||||
| jsonFlag string = "json" | ||||||
| nodeStatusControllerFlag string = "with-nodestatus-controller" | ||||||
| spodControllerFlag string = "with-spod-controller" | ||||||
| workloadAnnotatorFlag string = "with-workload-annotator" | ||||||
| recordingMergerFlag string = "with-recording-merger" | ||||||
| recordingFlag string = "with-recording" | ||||||
| seccompFlag string = "with-seccomp" | ||||||
| selinuxFlag string = "with-selinux" | ||||||
| apparmorFlag string = "with-apparmor" | ||||||
| webhookFlag string = "webhook" | ||||||
| memOptimFlag string = "with-mem-optim" | ||||||
| enableInsecureMetricsAccessFlag string = "enable-insecure-metrics-access" | ||||||
| defaultWebhookPort int = 9443 | ||||||
| auditLogIntervalSecondsParam string = "audit-log-interval-seconds" | ||||||
| auditLogPathParam string = "audit-log-path" | ||||||
| auditLogMaxSizeParam string = "audit-log-maxsize" | ||||||
| // The plural form is not used for audit-log-file-maxbackup to match the k8s api server audit log options. | ||||||
| auditLogMaxBackupParam string = "audit-log-maxbackup" | ||||||
| auditLogMaxAgeParam string = "audit-log-maxage" | ||||||
|
|
@@ -384,6 +385,11 @@ func main() { | |||||
| Value: config.DefaultProfilingPort, | ||||||
| EnvVars: []string{config.ProfilingPortEnvKey}, | ||||||
| }, | ||||||
| &cli.BoolFlag{ | ||||||
| Name: enableInsecureMetricsAccessFlag, | ||||||
| Usage: "enable insecure metrics access (disables TLS and authentication)", | ||||||
| EnvVars: []string{config.EnableInsecureMetricsAccessEnvKey}, | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
| if err := app.Run(os.Args); err != nil { | ||||||
|
|
@@ -665,20 +671,29 @@ func runDaemon(ctx *cli.Context, info *version.Info) error { | |||||
| c.NextProtos = []string{"http/1.1"} | ||||||
| } | ||||||
|
|
||||||
| metricsOptions := metricsserver.Options{ | ||||||
| BindAddress: fmt.Sprintf(":%d", bindata.ContainerPort), | ||||||
| ExtraHandlers: map[string]http.Handler{ | ||||||
| metrics.HandlerPath: met.Handler(), | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
| if ctx.Bool(enableInsecureMetricsAccessFlag) { | ||||||
| setupLog.Info("Insecure metrics access allowed (TLS and authentication disabled)") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up from the previous round: since there's no warning level on
Suggested change
|
||||||
|
|
||||||
| metricsOptions.SecureServing = false | ||||||
|
saschagrunert marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag is defined and consumed in The established pattern (see
Without this integration, the flag is unusable in a standard SPO deployment. |
||||||
| } else { | ||||||
| metricsOptions.SecureServing = true | ||||||
| metricsOptions.CertDir = bindata.MetricsCertPath | ||||||
| metricsOptions.FilterProvider = metricsfilters.WithAuthenticationAndAuthorization | ||||||
| metricsOptions.TLSOpts = []func(*tls.Config){disableHTTP2} | ||||||
| } | ||||||
|
|
||||||
| ctrlOpts := ctrl.Options{ | ||||||
| Cache: cache.Options{SyncPeriod: &sync}, | ||||||
| HealthProbeBindAddress: fmt.Sprintf(":%d", config.HealthProbePort), | ||||||
| NewCache: newMemoryOptimizedCache(ctx), | ||||||
| Metrics: metricsserver.Options{ | ||||||
| BindAddress: fmt.Sprintf(":%d", bindata.ContainerPort), | ||||||
| CertDir: bindata.MetricsCertPath, | ||||||
| SecureServing: true, | ||||||
| FilterProvider: metricsfilters.WithAuthenticationAndAuthorization, | ||||||
| ExtraHandlers: map[string]http.Handler{ | ||||||
| metrics.HandlerPath: met.Handler(), | ||||||
| }, | ||||||
| TLSOpts: []func(*tls.Config){disableHTTP2}, | ||||||
| }, | ||||||
| Metrics: metricsOptions, | ||||||
| } | ||||||
|
|
||||||
| setControllerOptionsForNamespaces(&ctrlOpts) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -94,6 +94,10 @@ const ( | |||||||||
| // EnableRecordingEnvKey is the environment variable key to enabling profile recording. | ||||||||||
| EnableRecordingEnvKey = "ENABLE_RECORDING" | ||||||||||
|
|
||||||||||
| // EnableInsecureMetricsAccessEnvKey is the environment variable key for enabling insecure | ||||||||||
| // metrics access(disables TLS and authentication). | ||||||||||
|
Comment on lines
+97
to
+98
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space before parenthesis.
Suggested change
|
||||||||||
| EnableInsecureMetricsAccessEnvKey = "ENABLE_INSECURE_METRICS_ACCESS" | ||||||||||
|
|
||||||||||
| // VerboseLevel is the increased verbosity log level. | ||||||||||
| VerboseLevel = 1 | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag is only consumed in
runDaemonbut is registered as a global flag. All other daemon-specific feature flags (seccompFlag,selinuxFlag,recordingFlag,memOptimFlag) are registered under thedaemonsubcommand's flags (lines 185-212). Move it there for consistency.