Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ var (
templates string
promMetricsListenAddress string
resourceLockNamespace string
tlsCipherSuites []string
tlsMinVersion string
tlsCurvePreferences []int32
streamsCache string
}
)
Expand All @@ -56,9 +53,6 @@ func init() {
startCmd.PersistentFlags().StringVar(&startOpts.kubeconfig, "kubeconfig", "", "Kubeconfig file to access a remote cluster (testing only)")
startCmd.PersistentFlags().StringVar(&startOpts.resourceLockNamespace, "resourcelock-namespace", metav1.NamespaceSystem, "Path to the template files used for creating MachineConfig objects")
startCmd.PersistentFlags().StringVar(&startOpts.promMetricsListenAddress, "metrics-listen-address", "127.0.0.1:8797", "Listen address for prometheus metrics listener")
startCmd.PersistentFlags().StringSliceVar(&startOpts.tlsCipherSuites, "tls-cipher-suites", nil, "Comma-separated list of cipher suites for the metrics server")
startCmd.PersistentFlags().StringVar(&startOpts.tlsMinVersion, "tls-min-version", "VersionTLS12", "Minimum TLS version supported for the metrics server")
startCmd.PersistentFlags().Int32SliceVar(&startOpts.tlsCurvePreferences, "tls-curve-preferences", nil, "TLS curve preferences as numeric curve IDs for the metrics server")
startCmd.PersistentFlags().StringVar(&startOpts.streamsCache, "streams-cache", "/var/cache/mcc", "Directory to use as cache for streams discovery")
}

Expand Down Expand Up @@ -151,7 +145,7 @@ func runStartCmd(_ *cobra.Command, _ []string) {
inspectionCache.RegisterEvicter(cacheWarmer)
}

go ctrlcommon.StartMetricsListener(startOpts.promMetricsListenAddress, ctx.Done(), ctrlcommon.RegisterMCCMetrics, startOpts.tlsMinVersion, startOpts.tlsCipherSuites, startOpts.tlsCurvePreferences)
go ctrlcommon.StartMetricsListener(startOpts.promMetricsListenAddress, ctx.Done(), ctrlcommon.RegisterMCCMetrics)

controllers := createControllers(ctrlctx, inspectionCache, inspectorFactory, cacheWarmer)
draincontroller := drain.New(
Expand Down
8 changes: 1 addition & 7 deletions cmd/machine-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ var (
kubeletHealthzEnabled bool
kubeletHealthzEndpoint string
promMetricsURL string
tlsCipherSuites []string
tlsMinVersion string
tlsCurvePreferences []int32
}
)

Expand All @@ -59,9 +56,6 @@ func init() {
startCmd.PersistentFlags().BoolVar(&startOpts.kubeletHealthzEnabled, "kubelet-healthz-enabled", true, "kubelet healthz endpoint monitoring")
startCmd.PersistentFlags().StringVar(&startOpts.kubeletHealthzEndpoint, "kubelet-healthz-endpoint", "http://localhost:10248/healthz", "healthz endpoint to check health")
startCmd.PersistentFlags().StringVar(&startOpts.promMetricsURL, "metrics-url", "127.0.0.1:8797", "URL for prometheus metrics listener")
startCmd.PersistentFlags().StringSliceVar(&startOpts.tlsCipherSuites, "tls-cipher-suites", nil, "Comma-separated list of cipher suites for the metrics server")
startCmd.PersistentFlags().StringVar(&startOpts.tlsMinVersion, "tls-min-version", "VersionTLS12", "Minimum TLS version supported for the metrics server")
startCmd.PersistentFlags().Int32SliceVar(&startOpts.tlsCurvePreferences, "tls-curve-preferences", nil, "TLS curve preferences as numeric curve IDs for the metrics server")
}

//nolint:gocritic
Expand Down Expand Up @@ -182,7 +176,7 @@ func runStartCmd(_ *cobra.Command, _ []string) {
}

// Start local metrics listener
go ctrlcommon.StartMetricsListener(startOpts.promMetricsURL, stopCh, daemon.RegisterMCDMetrics, startOpts.tlsMinVersion, startOpts.tlsCipherSuites, startOpts.tlsCurvePreferences)
go ctrlcommon.StartMetricsListener(startOpts.promMetricsURL, stopCh, daemon.RegisterMCDMetrics)

ctrlctx := ctrlcommon.CreateControllerContext(ctx, cb)

Expand Down
8 changes: 1 addition & 7 deletions cmd/machine-os-builder/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ var (
startOpts struct {
kubeconfig string
promMetricsListenAddress string
tlsCipherSuites []string
tlsMinVersion string
tlsCurvePreferences []int32
}
)

func init() {
rootCmd.AddCommand(startCmd)
startCmd.PersistentFlags().StringVar(&startOpts.kubeconfig, "kubeconfig", "", "Kubeconfig file to access a remote cluster (testing only)")
startCmd.PersistentFlags().StringVar(&startOpts.promMetricsListenAddress, "metrics-listen-address", "127.0.0.1:8797", "Listen address for prometheus metrics listener")
startCmd.PersistentFlags().StringSliceVar(&startOpts.tlsCipherSuites, "tls-cipher-suites", nil, "Comma-separated list of cipher suites for the metrics server")
startCmd.PersistentFlags().StringVar(&startOpts.tlsMinVersion, "tls-min-version", "VersionTLS12", "Minimum TLS version supported for the metrics server")
startCmd.PersistentFlags().Int32SliceVar(&startOpts.tlsCurvePreferences, "tls-curve-preferences", nil, "TLS curve preferences as numeric curve IDs for the metrics server")
}

func runStartCmd(_ *cobra.Command, _ []string) {
Expand Down Expand Up @@ -70,7 +64,7 @@ func runStartCmd(_ *cobra.Command, _ []string) {
ctrlCtx := ctrlcommon.CreateControllerContext(ctx, cb)

// Start the metrics listener for OCL telemetry
go ctrlcommon.StartMetricsListener(startOpts.promMetricsListenAddress, ctrlCtx.Stop, build.RegisterOCLMetrics, startOpts.tlsMinVersion, startOpts.tlsCipherSuites, startOpts.tlsCurvePreferences)
go ctrlcommon.StartMetricsListener(startOpts.promMetricsListenAddress, ctrlCtx.Stop, build.RegisterOCLMetrics)

ctrl := build.NewOSBuildControllerFromControllerContext(ctrlCtx)

Expand Down
5 changes: 0 additions & 5 deletions manifests/machineconfigcontroller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ spec:
- "--resourcelock-namespace={{.TargetNamespace}}"
- "--v={{.LogLevel}}"
- "--payload-version={{.ReleaseVersion}}"
- "--tls-cipher-suites={{join .TLSCipherSuites ","}}"
- "--tls-min-version={{.TLSMinVersion}}"
{{- if .TLSGroups }}
- "--tls-curve-preferences={{join .TLSGroups ","}}"
{{- end }}
- "--streams-cache=/var/cache/mcc"
resources:
requests:
Expand Down
5 changes: 0 additions & 5 deletions manifests/machineconfigdaemon/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ spec:
- "start"
- "--payload-version={{.ReleaseVersion}}"
- "--v={{.LogLevel}}"
- "--tls-cipher-suites={{join .TLSCipherSuites ","}}"
- "--tls-min-version={{.TLSMinVersion}}"
{{- if .TLSGroups }}
- "--tls-curve-preferences={{join .TLSGroups ","}}"
{{- end }}
resources:
requests:
cpu: 20m
Expand Down
14 changes: 4 additions & 10 deletions pkg/controller/common/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package common

import (
"context"
"crypto/tls"
"fmt"
"net/http"

Expand Down Expand Up @@ -136,7 +135,7 @@ func RegisterMetrics(metrics []prometheus.Collector) error {
}

// StartMetricsListener is metrics listener via http on localhost
func StartMetricsListener(addr string, stopCh <-chan struct{}, registerFunc func() error, tlsMinVersion string, tlsCipherSuites []string, curvePreferences []int32) {
func StartMetricsListener(addr string, stopCh <-chan struct{}, registerFunc func() error) {
if addr == "" {
addr = DefaultBindAddress
}
Expand All @@ -148,17 +147,12 @@ func StartMetricsListener(addr string, stopCh <-chan struct{}, registerFunc func
return
}

// Get TLS config from provided settings, or use defaults
tlsConfig := GetGoTLSConfig(tlsMinVersion, tlsCipherSuites, curvePreferences)

klog.Infof("Starting metrics listener on %s with TLS min version: %s", addr, tlsMinVersion)
klog.Infof("Starting metrics listener on %s", addr)
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())
s := http.Server{
TLSConfig: tlsConfig,
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
Addr: addr,
Handler: mux}
Addr: addr,
Handler: mux}

go func() {
if err := s.ListenAndServe(); err != nil && err != http.ErrServerClosed {
Expand Down