operator

package
v0.59.2-rhobs1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAlertmanagerVersion is a default image tag for the prometheus alertmanager
	DefaultAlertmanagerVersion = "v0.24.0"
	// 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.28.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
)
View Source
const MaxSecretDataSizeBytes = v1.MaxSecretSize - 50_000

MaxSecretDataSizeBytes is the maximum data size that a single secret shard may use. This is lower than v1.MaxSecretSize in order to reserve space for metadata and the rest of the secret k8s object.

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/rhobs/obo-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",
		"v2.30.0",
		"v2.30.1",
		"v2.30.2",
		"v2.30.3",
		"v2.31.0",
		"v2.31.1",
		"v2.32.0",
		"v2.32.1",
		"v2.33.0",
		"v2.33.1",
		"v2.33.2",
		"v2.33.3",
		"v2.33.4",
		"v2.33.5",
		"v2.34.0",
		"v2.35.0",
		"v2.36.0",
		"v2.37.0",
		"v2.38.0",
	}
)

Functions

func BuildImagePath

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 CompareScrapeTimeoutToScrapeInterval

func CompareScrapeTimeoutToScrapeInterval(scrapeTimeout, scrapeInterval monitoringv1.Duration) error

CompareScrapeTimeoutToScrapeInterval validates value of scrapeTimeout based on scrapeInterval

func CreateConfigReloader

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

CreateConfigReloader returns the definition of the config-reloader container.

func CurlProber

func CurlProber(u string) string

func GunzipConfig

func GunzipConfig(b []byte) (string, error)

func GzipConfig

func GzipConfig(w io.Writer, conf []byte) error

func MakeHostAliases

func MakeHostAliases(input []monitoringv1.HostAlias) []v1.HostAlias

MakeHostAliases converts array of monitoringv1 HostAlias to array of corev1 HostAlias

func SanitizeSTS

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

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

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 ValidateDurationField

func ValidateDurationField(durationField string) error

func ValidateSizeField

func ValidateSizeField(sizeField string) error

func WaitForNamedCacheSync

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/rhobs/obo-prometheus-operator/issues/3347.

func WgetProber

func WgetProber(u string) string

Types

type Config

type Config struct {
	Host                         string
	ClusterDomain                string
	KubeletObject                string
	ListenAddress                string
	TLSInsecure                  bool
	TLSConfig                    rest.TLSClientConfig
	ServerTLSConfig              server.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

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

ConfigReloader contains the options to configure a config-reloader container

type Labels

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

func (*Labels) Merge

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

Merge labels create a new map with labels merged.

func (*Labels) Set

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

Set implements the flag.Set interface.

func (*Labels) String

func (labels *Labels) String() string

Implement the flag.Value interface

type Metrics

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

Metrics represents metrics associated to an operator.

func NewMetrics

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

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

Collect implements the prometheus.Collector interface.

func (*Metrics) Describe

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

Describe implements the prometheus.Collector interface.

func (*Metrics) MustRegister

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

MustRegister registers metrics with the Metrics registerer.

func (*Metrics) NewInstrumentedListerWatcher

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

NewInstrumentedListerWatcher returns a cache.ListerWatcher with instrumentation.

func (*Metrics) Ready

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

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

func (*Metrics) ReconcileCounter

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

ReconcileCounter returns a counter to track attempted reconciliations.

func (*Metrics) ReconcileDurationHistogram

func (m *Metrics) ReconcileDurationHistogram() prometheus.Histogram

ReconcileDurationHistogram returns a histogram to track the duration of reconciliations.

func (*Metrics) ReconcileErrorsCounter

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

ReconcileErrorsCounter returns a counter to track reconciliation errors.

func (*Metrics) SetRejectedResources

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

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) StsDeleteCreateCounter

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

StsDeleteCreateCounter returns a counter to track statefulset's recreations.

func (*Metrics) TriggerByCounter

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

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, AlertmanagerConfigAllowList, ThanosRulerAllowList map[string]struct{}
}

type ReconciliationStatus

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

func (ReconciliationStatus) Message

func (rs ReconciliationStatus) Message() string

func (ReconciliationStatus) Ok

func (rs ReconciliationStatus) Ok() bool

func (ReconciliationStatus) Reason

func (rs ReconciliationStatus) Reason() string

type ReconciliationTracker

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

ReconciliationTracker tracks reconciliation status per object. The zero ReconciliationTracker is ready to use.

func (*ReconciliationTracker) Collect

func (rt *ReconciliationTracker) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*ReconciliationTracker) Describe

func (rt *ReconciliationTracker) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

func (*ReconciliationTracker) ForgetObject

func (rt *ReconciliationTracker) ForgetObject(k string)

ForgetObject removes the given object from the tracker. It should be called when the controller detects that the object has been deleted.

func (*ReconciliationTracker) GetStatus

GetStatus returns the last reconciliation status for the given object. The second value indicates whether the object is known or not.

func (*ReconciliationTracker) SetStatus

func (rt *ReconciliationTracker) SetStatus(k string, err error)

SetStatus updates the last reconciliation status for the given object.

type ReloaderConfig

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

type ReloaderOption

type ReloaderOption = func(*ConfigReloader)

func ConfigEnvsubstFile

func ConfigEnvsubstFile(configEnvsubstFile string) ReloaderOption

ConfigEnvsubstFile sets the configEnvsubstFile option for the config-reloader container

func ConfigFile

func ConfigFile(configFile string) ReloaderOption

ConfigFile sets the configFile option for the config-reloader container

func ListenLocal

func ListenLocal(listenLocal bool) ReloaderOption

ListenLocal sets the listenLocal option for the config-reloader container

func LocalHost

func LocalHost(localHost string) ReloaderOption

LocalHost sets the localHost option for the config-reloader container

func LogFormat

func LogFormat(logFormat string) ReloaderOption

LogFormat sets the logFormat option for the config-reloader container

func LogLevel

func LogLevel(logLevel string) ReloaderOption

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

func ReloaderResources

func ReloaderResources(rc ReloaderConfig) ReloaderOption

ReloaderResources sets the config option for the config-reloader container

func ReloaderRunOnce

func ReloaderRunOnce() ReloaderOption

ReloaderRunOnce sets the runOnce option for the config-reloader container

func ReloaderURL

func ReloaderURL(reloadURL url.URL) ReloaderOption

ReloaderURL sets the reloaderURL option for the config-reloader container

func Shard

func Shard(shard int32) ReloaderOption

Shard sets the shard option for the config-reloader container

func VolumeMounts

func VolumeMounts(mounts []v1.VolumeMount) ReloaderOption

VolumeMounts sets the volumeMounts option for the config-reloader container

func WatchedDirectories

func WatchedDirectories(watchedDirectories []string) ReloaderOption

WatchedDirectories sets the watchedDirectories option for the config-reloader container

type ShardedSecret

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

ShardedSecret is k8s secret data that is sharded across multiple enumerated k8s secrets. This is used to circumvent the size limitation of k8s secrets.

func NewShardedSecret

func NewShardedSecret(template *v1.Secret, namePrefix string) *ShardedSecret

NewShardedSecret takes a v1.Secret as template and a secret name prefix and returns a new ShardedSecret.

func (*ShardedSecret) AppendData

func (s *ShardedSecret) AppendData(key string, data []byte)

AppendData adds data to the secrets data portion. Already existing keys get overwritten.

func (*ShardedSecret) ShardNames

func (s *ShardedSecret) ShardNames() []string

ShardNames returns the names of the secret shards. This only returns something after StoreSecrets was called and the actual sharding took place.

func (*ShardedSecret) StoreSecrets

func (s *ShardedSecret) StoreSecrets(ctx context.Context, sClient corev1.SecretInterface) error

StoreSecrets creates the individual secret shards and stores it via sClient.

Jump to

Keyboard shortcuts

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