operator

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: Apache-2.0 Imports: 26 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultAlertmanagerVersion   = "v0.21.0"
	DefaultAlertmanagerBaseImage = "quay.io/prometheus/alertmanager"
	DefaultAlertmanagerImage     = DefaultAlertmanagerBaseImage + ":" + DefaultAlertmanagerVersion
	DefaultThanosVersion         = "v0.19.0"
	DefaultThanosBaseImage       = "quay.io/thanos/thanos"
	DefaultThanosImage           = DefaultThanosBaseImage + ":" + DefaultThanosVersion
)

Variables

View Source
var (
	DefaultPrometheusConfigReloaderImage = "quay.io/prometheus-operator/prometheus-config-reloader:v" + version.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",
	}
	DefaultPrometheusVersion   = PrometheusCompatibilityMatrix[len(PrometheusCompatibilityMatrix)-1]
	DefaultPrometheusBaseImage = "quay.io/prometheus/prometheus"
	DefaultPrometheusImage     = DefaultPrometheusBaseImage + ":" + DefaultPrometheusVersion
)

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(
	config ReloaderConfig,
	reloadURL url.URL,
	listenLocal bool,
	localHost string,
	logFormat, logLevel string,
	additionalArgs []string,
	volumeMounts []v1.VolumeMount,
	shard int32,
) v1.Container

CreateConfigReloader returns the definition of the config-reloader container. No shard environment variable will be passed to the reloader container if `-1` is passed to the shards parameter.

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

WaitForCacheSync synchronizes the informer's cache and will log a warning every minute if the operation hasn't completed yet. 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 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 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