operator

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 27 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// DefaultAlertmanagerVersion is a default image tag for the prometheus alertmanager
	DefaultAlertmanagerVersion = "v0.22.2"
	// DefaultAlertmanagerBaseImage is a base container registry address for the prometheus alertmanager
	DefaultAlertmanagerBaseImage = "quay.io/prometheus/alertmanager"
	// DefaultAlertmanagerImage is a default image pulling address for the prometheus alertmanager
	DefaultAlertmanagerImage = DefaultAlertmanagerBaseImage + ":" + DefaultAlertmanagerVersion

	// DefaultThanosVersion is a default image tag for the Thanos long-term prometheus storage collector
	DefaultThanosVersion = "v0.22.0"
	// DefaultThanosBaseImage is a base container registry address for the Thanos long-term prometheus
	// storage collector
	DefaultThanosBaseImage = "quay.io/thanos/thanos"
	// DefaultThanosImage is a default image pulling address for the Thanos long-term prometheus storage collector
	DefaultThanosImage = DefaultThanosBaseImage + ":" + DefaultThanosVersion
)

Variables

View Source
var (
	// DefaultPrometheusVersion is a default image tag for the prometheus
	DefaultPrometheusVersion = PrometheusCompatibilityMatrix[len(PrometheusCompatibilityMatrix)-1]
	// DefaultPrometheusBaseImage is a base container registry address for the prometheus
	DefaultPrometheusBaseImage = "quay.io/prometheus/prometheus"
	// DefaultPrometheusImage is a default image pulling address for the prometheus
	DefaultPrometheusImage = DefaultPrometheusBaseImage + ":" + DefaultPrometheusVersion

	// DefaultPrometheusConfigReloaderImage is an image that will be used as a sidecar to provide dynamic prometheus
	// configuration reloading
	DefaultPrometheusConfigReloaderImage = "quay.io/prometheus-operator/prometheus-config-reloader:v" + version.Version

	// PrometheusCompatibilityMatrix is a list of supported prometheus version
	PrometheusCompatibilityMatrix = []string{
		"v2.0.0",
		"v2.2.1",
		"v2.3.1",
		"v2.3.2",
		"v2.4.0",
		"v2.4.1",
		"v2.4.2",
		"v2.4.3",
		"v2.5.0",
		"v2.6.0",
		"v2.6.1",
		"v2.7.0",
		"v2.7.1",
		"v2.7.2",
		"v2.8.1",
		"v2.9.2",
		"v2.10.0",
		"v2.11.0",
		"v2.14.0",
		"v2.15.2",
		"v2.16.0",
		"v2.17.2",
		"v2.18.0",
		"v2.18.1",
		"v2.18.2",
		"v2.19.0",
		"v2.19.1",
		"v2.19.2",
		"v2.19.3",
		"v2.20.0",
		"v2.20.1",
		"v2.21.0",
		"v2.22.0",
		"v2.22.1",
		"v2.22.2",
		"v2.23.0",
		"v2.24.0",
		"v2.24.1",
		"v2.25.0",
		"v2.25.1",
		"v2.25.2",
		"v2.26.0",
		"v2.26.1",
		"v2.27.0",
		"v2.27.1",
		"v2.28.0",
		"v2.28.1",
		"v2.29.0",
		"v2.29.1",
	}
)

Functions

func BuildImagePath added in v0.42.0

func BuildImagePath(specImage, image, version, tag, sha string) (string, error)

BuildImagePath builds a container image path based on the given parameters. Return specImage if not empty. If image contains a tag or digest then image will be returned. Otherwise, return image suffixed by either SHA, tag or version(in that order). Inspired by kubernetes code handling of image building.

func CreateConfigReloader added in v0.43.0

func CreateConfigReloader(name string, options ...ReloaderOption) v1.Container

CreateConfigReloader returns the definition of the config-reloader container.

func MakeVolumeClaimTemplate added in v0.42.0

func NewTLSConfig added in v0.42.0

func NewTLSConfig(logger log.Logger, certFile, keyFile, clientCAFile, minVersion string, cipherSuites []string) (*tls.Config, error)

NewTLSConfig provides new server TLS configuration.

func SanitizeSTS added in v0.42.0

func SanitizeSTS(sts *appsv1.StatefulSet)

SanitizeSTS removes values for APIVersion and Kind from the VolumeClaimTemplates. This prevents update failures due to these fields changing when applied. See https://github.com/kubernetes/kubernetes/issues/87583

func StringPtrValOrDefault added in v0.42.0

func StringPtrValOrDefault(val *string, defaultVal string) string

StringPtrValOrDefault returns the default val if the given string pointer is nil points to an empty/whitespace string. Otherwise returns the value of the string.

func StringValOrDefault added in v0.42.0

func StringValOrDefault(val, defaultVal string) string

StringValOrDefault returns the default val if the given string is empty/whitespace. Otherwise returns the value of the string..

func WaitForNamedCacheSync added in v0.43.1

func WaitForNamedCacheSync(ctx context.Context, controllerName string, logger log.Logger, inf cache.SharedIndexInformer) bool

WaitForNamedCacheSync synchronizes the informer's cache and will log a warning every minute if the operation hasn't completed yet, until it reaches a timeout of 10 minutes. Under normal circumstances, the cache sync should be fast. If it takes more than 1 minute, it means that something is stuck and the message will indicate to the admin which informer is the culprit. See https://github.com/prometheus-operator/prometheus-operator/issues/3347.

Types

type Config

type Config struct {
	Host                         string
	ClusterDomain                string
	KubeletObject                string
	ListenAddress                string
	TLSInsecure                  bool
	TLSConfig                    rest.TLSClientConfig
	ServerTLSConfig              TLSServerConfig
	ReloaderConfig               ReloaderConfig
	AlertmanagerDefaultBaseImage string
	PrometheusDefaultBaseImage   string
	ThanosDefaultBaseImage       string
	Namespaces                   Namespaces
	Labels                       Labels
	LocalHost                    string
	LogLevel                     string
	LogFormat                    string
	PromSelector                 string
	AlertManagerSelector         string
	ThanosRulerSelector          string
	SecretListWatchSelector      string
}

Config defines configuration parameters for the Operator.

type ConfigReloader added in v0.49.0

type ConfigReloader struct {
	// contains filtered or unexported fields
}

ConfigReloader contains the options to configure a config-reloader container

type Labels added in v0.43.0

type Labels struct {
	LabelsString string
	LabelsMap    map[string]string
}

func (*Labels) Merge added in v0.43.0

func (labels *Labels) Merge(otherLabels map[string]string) map[string]string

Merge labels create a new map with labels merged.

func (*Labels) Set added in v0.43.0

func (labels *Labels) Set(value string) error

Set implements the flag.Set interface.

func (*Labels) String added in v0.43.0

func (labels *Labels) String() string

Implement the flag.Value interface

type Metrics added in v0.42.0

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics represents metrics associated to an operator.

func NewMetrics added in v0.42.0

func NewMetrics(name string, r prometheus.Registerer) *Metrics

NewMetrics initializes operator metrics and registers them with the given registerer. All metrics have a "controller=<name>" label.

func (*Metrics) Collect added in v0.43.0

func (m *Metrics) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Metrics) Describe added in v0.43.0

func (m *Metrics) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

func (*Metrics) ForgetObject added in v0.43.0

func (m *Metrics) ForgetObject(objKey string)

ForgetObject removes the metrics tracked for the given object's key. It should be called when the controller detects that the object has been deleted.

func (*Metrics) MustRegister added in v0.42.0

func (m *Metrics) MustRegister(metrics ...prometheus.Collector)

MustRegister registers metrics with the Metrics registerer.

func (*Metrics) NewInstrumentedListerWatcher added in v0.42.0

func (m *Metrics) NewInstrumentedListerWatcher(lw cache.ListerWatcher) cache.ListerWatcher

NewInstrumentedListerWatcher returns a cache.ListerWatcher with instrumentation.

func (*Metrics) Ready added in v0.43.0

func (m *Metrics) Ready() prometheus.Gauge

Ready returns a gauge to track whether the controller is ready or not.

func (*Metrics) ReconcileCounter added in v0.42.0

func (m *Metrics) ReconcileCounter() prometheus.Counter

ReconcileCounter returns a counter to track attempted reconciliations.

func (*Metrics) ReconcileErrorsCounter added in v0.42.0

func (m *Metrics) ReconcileErrorsCounter() prometheus.Counter

ReconcileErrorsCounter returns a counter to track reconciliation errors.

func (*Metrics) SetRejectedResources added in v0.43.0

func (m *Metrics) SetRejectedResources(objKey, resource string, v int)

SetRejectedResources sets the number of resources that the controller rejected for the given object's key.

func (*Metrics) SetSelectedResources added in v0.43.0

func (m *Metrics) SetSelectedResources(objKey, resource string, v int)

SetSelectedResources sets the number of resources that the controller selected for the given object's key.

func (*Metrics) SetSyncStatus added in v0.43.0

func (m *Metrics) SetSyncStatus(objKey string, success bool)

SetSyncStatus tracks the status of the last sync operation for the given object.

func (*Metrics) StsDeleteCreateCounter added in v0.42.0

func (m *Metrics) StsDeleteCreateCounter() prometheus.Counter

StsDeleteCreateCounter returns a counter to track statefulset's recreations.

func (*Metrics) TriggerByCounter added in v0.42.0

func (m *Metrics) TriggerByCounter(triggeredBy, action string) prometheus.Counter

TriggerByCounter returns a counter to track operator actions by operation (add/delete/update) and action.

type Namespaces added in v0.43.0

type Namespaces struct {
	// Allow list/deny list for common custom resources.
	AllowList, DenyList map[string]struct{}
	// Allow list for prometheus/alertmanager custom resources.
	PrometheusAllowList, AlertmanagerAllowList, ThanosRulerAllowList map[string]struct{}
}

type ReloaderConfig added in v0.43.0

type ReloaderConfig struct {
	CPURequest    string
	CPULimit      string
	MemoryRequest string
	MemoryLimit   string
	Image         string
}

type ReloaderOption added in v0.49.0

type ReloaderOption = func(*ConfigReloader)

func ConfigEnvsubstFile added in v0.49.0

func ConfigEnvsubstFile(configEnvsubstFile string) ReloaderOption

ConfigEnvsubstFile sets the configEnvsubstFile option for the config-reloader container

func ConfigFile added in v0.49.0

func ConfigFile(configFile string) ReloaderOption

ConfigFile sets the configFile option for the config-reloader container

func ListenLocal added in v0.49.0

func ListenLocal(listenLocal bool) ReloaderOption

ListenLocal sets the listenLocal option for the config-reloader container

func LocalHost added in v0.49.0

func LocalHost(localHost string) ReloaderOption

LocalHost sets the localHost option for the config-reloader container

func LogFormat added in v0.49.0

func LogFormat(logFormat string) ReloaderOption

LogFormat sets the logFormat option for the config-reloader container

func LogLevel added in v0.49.0

func LogLevel(logLevel string) ReloaderOption

LogLevel sets the logLevel option for the config-reloader container\

func ReloaderResources added in v0.49.0

func ReloaderResources(rc ReloaderConfig) ReloaderOption

ReloaderResources sets the config option for the config-reloader container

func ReloaderRunOnce added in v0.49.0

func ReloaderRunOnce() ReloaderOption

ReloaderRunOnce sets the runOnce option for the config-reloader container

func ReloaderURL added in v0.49.0

func ReloaderURL(reloadURL url.URL) ReloaderOption

ReloaderURL sets the reloaderURL option for the config-reloader container

func Shard added in v0.49.0

func Shard(shard int32) ReloaderOption

Shard sets the shard option for the config-reloader container

func VolumeMounts added in v0.49.0

func VolumeMounts(mounts []v1.VolumeMount) ReloaderOption

VolumeMounts sets the volumeMounts option for the config-reloader container

func WatchedDirectories added in v0.49.0

func WatchedDirectories(watchedDirectories []string) ReloaderOption

WatchedDirectories sets the watchedDirectories option for the config-reloader container

type TLSServerConfig added in v0.42.0

type TLSServerConfig struct {
	CertFile       string
	KeyFile        string
	ClientCAFile   string
	MinVersion     string
	CipherSuites   []string
	ReloadInterval time.Duration
}

TLSServerConfig contains the necessary fields to configure web server TLS

Jump to

Keyboard shortcuts

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