server

package
v0.17.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 1,683

Documentation

Overview

Package server provides the metrics server implementation.

Index

Constants

This section is empty.

Variables

View Source
var DefaultBindAddress = ":8080"

DefaultBindAddress is the default bind address for the metrics server.

Functions

This section is empty.

Types

type Filter

type Filter func(log logr.Logger, handler http.Handler) (http.Handler, error)

Filter is a func that is added around metrics and extra handlers on the metrics server.

type Options

type Options struct {
	// SecureServing enables serving metrics via https.
	// Per default metrics will be served via http.
	SecureServing bool

	// BindAddress is the bind address for the metrics server.
	// It will be defaulted to ":8080" if unspecified.
	// Set this to "0" to disable the metrics server.
	BindAddress string

	// ExtraHandlers contains a map of handlers (by path) which will be added to the metrics server.
	// This might be useful to register diagnostic endpoints e.g. pprof.
	// Note that pprof endpoints are meant to be sensitive and shouldn't be exposed publicly.
	// If the simple path -> handler mapping offered here is not enough, a new http
	// server/listener should be added as Runnable to the manager via the Add method.
	ExtraHandlers map[string]http.Handler

	// FilterProvider provides a filter which is a func that is added around
	// the metrics and the extra handlers on the metrics server.
	// This can be e.g. used to enforce authentication and authorization on the handlers
	// endpoint by setting this field to filters.WithAuthenticationAndAuthorization.
	FilterProvider func(c *rest.Config, httpClient *http.Client) (Filter, error)

	// CertDir is the directory that contains the server key and certificate. Defaults to
	// <temp-dir>/k8s-metrics-server/serving-certs.
	//
	// Note: This option is only used when TLSOpts does not set GetCertificate.
	// Note: If certificate or key doesn't exist a self-signed certificate will be used.
	CertDir string

	// CertName is the server certificate name. Defaults to tls.crt.
	//
	// Note: This option is only used when TLSOpts does not set GetCertificate.
	// Note: If certificate or key doesn't exist a self-signed certificate will be used.
	CertName string

	// KeyName is the server key name. Defaults to tls.key.
	//
	// Note: This option is only used when TLSOpts does not set GetCertificate.
	// Note: If certificate or key doesn't exist a self-signed certificate will be used.
	KeyName string

	// TLSOpts is used to allow configuring the TLS config used for the server.
	// This also allows providing a certificate via GetCertificate.
	TLSOpts []func(*tls.Config)
}

Options are all available options for the metrics.Server

type Server

type Server interface {
	// AddExtraHandler adds extra handler served on path to the http server that serves metrics.
	AddExtraHandler(path string, handler http.Handler) error

	// NeedLeaderElection implements the LeaderElectionRunnable interface, which indicates
	// the metrics server doesn't need leader election.
	NeedLeaderElection() bool

	// Start runs the server.
	// It will install the metrics related resources depending on the server configuration.
	Start(ctx context.Context) error
}

Server is a server that serves metrics.

func NewServer

func NewServer(o Options, config *rest.Config, httpClient *http.Client) (Server, error)

NewServer constructs a new metrics.Server from the provided options.

Jump to

Keyboard shortcuts

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