config

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate added in v0.3.0

func Validate(srvCfg Serving, timeoutsCfg Timeouts) error

Types

type Metrics added in v0.8.0

type Metrics struct {
	// Sets whether or not to enable the Prometheus metrics exporter
	OtelPrometheusExporterEnabled bool `envconfig:"OTEL_PROM_EXPORTER_ENABLED" default:"true"`
	// Sets the port which the Prometheus compatible metrics endpoint should be served on
	OtelPrometheusExporterPort int `envconfig:"OTEL_PROM_EXPORTER_PORT" default:"2223"`
	// Sets whether or not to enable the OTEL metrics exporter
	OtelHTTPExporterEnabled bool `envconfig:"OTEL_EXPORTER_OTLP_METRICS_ENABLED" default:"false"`
}

Metrics is the configuration for configuring metrics in the interceptor.

func MustParseMetrics added in v0.8.0

func MustParseMetrics() *Metrics

Parse parses standard configs using envconfig and returns a pointer to the newly created config. Returns nil and a non-nil error if parsing failed

type Serving

type Serving struct {
	// CurrentNamespace is the namespace that the interceptor is
	// currently running in
	CurrentNamespace string `envconfig:"KEDA_HTTP_CURRENT_NAMESPACE" required:"true"`
	// WatchNamespace is the namespace to watch for new HTTPScaledObjects.
	// Leave this empty to watch HTTPScaledObjects in all namespaces.
	WatchNamespace string `envconfig:"KEDA_HTTP_WATCH_NAMESPACE" default:""`
	// ProxyPort is the port that the public proxy should run on
	ProxyPort int `envconfig:"KEDA_HTTP_PROXY_PORT" required:"true"`
	// AdminPort is the port that the internal admin server should run on.
	// This is the server that the external scaler will issue metrics
	// requests to
	AdminPort int `envconfig:"KEDA_HTTP_ADMIN_PORT" required:"true"`
	// CacheSyncPeriod is the time interval for the controller-runtime cache to resync.
	// TODO: consider removing this to use the default value, otherwise align the env var name
	CacheSyncPeriod time.Duration `envconfig:"KEDA_HTTP_SCALER_CONFIG_MAP_INFORMER_RSYNC_PERIOD" default:"60m"`
	// The interceptor has an internal process that periodically fetches the state
	// of endpoints that is running the servers it forwards to.
	//
	// This is the interval (in milliseconds) representing how often to do a fetch
	// TODO: this is actually the informer resync period, not a poll interval, default is too aggressive
	EndpointsCachePollIntervalMS int `envconfig:"KEDA_HTTP_ENDPOINTS_CACHE_POLLING_INTERVAL_MS" default:"1000"`
	// ProxyTLSEnabled is a flag to specify whether the interceptor proxy should
	// be running using a TLS enabled server
	ProxyTLSEnabled bool `envconfig:"KEDA_HTTP_PROXY_TLS_ENABLED" default:"false"`
	// TLSCertPath is the path to read the certificate file from for the TLS server
	TLSCertPath string `envconfig:"KEDA_HTTP_PROXY_TLS_CERT_PATH" default:"/certs/tls.crt"`
	// TLSKeyPath is the path to read the private key file from for the TLS server
	TLSKeyPath string `envconfig:"KEDA_HTTP_PROXY_TLS_KEY_PATH" default:"/certs/tls.key"`
	// TLSCertStorePaths is a comma separated list of paths to read the certificate/key pairs for the TLS server
	TLSCertStorePaths string `envconfig:"KEDA_HTTP_PROXY_TLS_CERT_STORE_PATHS" default:""`
	// TLSSkipVerify is a boolean flag to specify whether the interceptor should skip TLS verification for upstreams
	TLSSkipVerify bool `envconfig:"KEDA_HTTP_PROXY_TLS_SKIP_VERIFY" default:"false"`
	// TLSPort is the port that the server should serve on if TLS is enabled
	TLSPort int `envconfig:"KEDA_HTTP_PROXY_TLS_PORT" default:"8443"`
	// ProfilingAddr if not empty, pprof will be available on this address, assuming host:port here
	ProfilingAddr string `envconfig:"PROFILING_BIND_ADDRESS" default:""`
	// EnableColdStartHeader enables/disables the X-KEDA-HTTP-Cold-Start response header
	EnableColdStartHeader bool `envconfig:"KEDA_HTTP_ENABLE_COLD_START_HEADER" default:"true"`
	// LogRequests enables/disables logging of incoming requests
	LogRequests bool `envconfig:"KEDA_HTTP_LOG_REQUESTS" default:"false"`
}

Serving is configuration for how the interceptor serves the proxy and admin server

func MustParseServing

func MustParseServing() Serving

MustParseServing parses standard configs using envconfig and returns the newly created config. It panics if parsing fails.

type Timeouts

type Timeouts struct {
	// Connect is the per-attempt TCP dial timeout (net.Dialer.Timeout)
	Connect time.Duration `envconfig:"KEDA_HTTP_CONNECT_TIMEOUT" default:"500ms"`
	// KeepAlive is the interval between keepalive probes
	KeepAlive time.Duration `envconfig:"KEDA_HTTP_KEEP_ALIVE" default:"1s"`
	// ResponseHeaderTimeout is how long to wait between when the HTTP request
	// is sent to the backing app and when response headers need to arrive
	ResponseHeader time.Duration `envconfig:"KEDA_RESPONSE_HEADER_TIMEOUT" default:"500ms"`
	// WorkloadReplicas is how long to wait for the backing workload
	// to have 1 or more replicas before connecting and sending the HTTP request.
	WorkloadReplicas time.Duration `envconfig:"KEDA_CONDITION_WAIT_TIMEOUT" default:"20s"`
	// ForceHTTP2 toggles whether to try to force HTTP2 for all requests
	ForceHTTP2 bool `envconfig:"KEDA_HTTP_FORCE_HTTP2" default:"false"`
	// MaxIdleConns is the max number of idle connections to keep in the
	// interceptor's internal connection pool across all backend services.
	// Increase this if you proxy to many unique backend services.
	MaxIdleConns int `envconfig:"KEDA_HTTP_MAX_IDLE_CONNS" default:"1000"`
	// MaxIdleConnsPerHost is the max number of idle connections to keep per backend service.
	// Increase this if you observe many new connection establishments under load.
	MaxIdleConnsPerHost int `envconfig:"KEDA_HTTP_MAX_IDLE_CONNS_PER_HOST" default:"200"`
	// IdleConnTimeout is the timeout after which a connection in the interceptor's
	// internal connection pool will be closed
	IdleConnTimeout time.Duration `envconfig:"KEDA_HTTP_IDLE_CONN_TIMEOUT" default:"90s"`
	// TLSHandshakeTimeout is the max amount of time the interceptor will
	// wait to establish a TLS connection
	TLSHandshakeTimeout time.Duration `envconfig:"KEDA_HTTP_TLS_HANDSHAKE_TIMEOUT" default:"10s"`
	// ExpectContinueTimeout is the max amount of time the interceptor will wait
	// for a 100 Continue response from the backend after sending request headers
	// with Expect: 100-continue
	ExpectContinueTimeout time.Duration `envconfig:"KEDA_HTTP_EXPECT_CONTINUE_TIMEOUT" default:"1s"`
	// DialRetryTimeout caps the total time spent retrying failed dial attempts.
	DialRetryTimeout time.Duration `envconfig:"KEDA_HTTP_DIAL_RETRY_TIMEOUT" default:"15s"`
}

Timeouts is the configuration for connection and HTTP timeouts

func MustParseTimeouts

func MustParseTimeouts() Timeouts

MustParseTimeouts parses standard configs using envconfig and returns the newly created config. It panics if parsing fails.

type Tracing added in v0.11.0

type Tracing struct {
	// States whether tracing should be enabled, False by default
	Enabled bool `envconfig:"OTEL_EXPORTER_OTLP_TRACES_ENABLED" default:"false"`
	// Sets what tracing export to use, must be one of: console,http/protobuf, grpc
	Exporter string `envconfig:"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL" default:"console"`
}

Tracing is the configuration for configuring tracing through the interceptor.

func MustParseTracing added in v0.11.0

func MustParseTracing() Tracing

MustParseTracing parses standard configs using envconfig and returns the newly created config. It panics if parsing fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL