Documentation
¶
Index ¶
- Constants
- Variables
- func BuildImagePath(specImage, image, version, tag, sha string) (string, error)
- func CompareScrapeTimeoutToScrapeInterval(scrapeTimeout, scrapeInterval monitoringv1.Duration) error
- func CreateConfigReloader(name string, options ...ReloaderOption) v1.Container
- func CurlProber(u string) string
- func GunzipConfig(b []byte) (string, error)
- func GzipConfig(w io.Writer, conf []byte) error
- func MakeHostAliases(input []monitoringv1.HostAlias) []v1.HostAlias
- func MakeVolumeClaimTemplate(e monitoringv1.EmbeddedPersistentVolumeClaim) *v1.PersistentVolumeClaim
- func SanitizeSTS(sts *appsv1.StatefulSet)
- func StringPtrValOrDefault(val *string, defaultVal string) string
- func StringValOrDefault(val, defaultVal string) string
- func ValidateDurationField(durationField string) error
- func ValidateSizeField(sizeField string) error
- func WaitForNamedCacheSync(ctx context.Context, controllerName string, logger log.Logger, ...) bool
- func WgetProber(u string) string
- type Config
- type ConfigReloader
- type Labels
- type Metrics
- func (m *Metrics) Collect(ch chan<- prometheus.Metric)
- func (m *Metrics) Describe(ch chan<- *prometheus.Desc)
- func (m *Metrics) MustRegister(metrics ...prometheus.Collector)
- func (m *Metrics) NewInstrumentedListerWatcher(lw cache.ListerWatcher) cache.ListerWatcher
- func (m *Metrics) Ready() prometheus.Gauge
- func (m *Metrics) ReconcileCounter() prometheus.Counter
- func (m *Metrics) ReconcileDurationHistogram() prometheus.Histogram
- func (m *Metrics) ReconcileErrorsCounter() prometheus.Counter
- func (m *Metrics) SetRejectedResources(objKey, resource string, v int)
- func (m *Metrics) SetSelectedResources(objKey, resource string, v int)
- func (m *Metrics) StsDeleteCreateCounter() prometheus.Counter
- func (m *Metrics) TriggerByCounter(triggeredBy, action string) prometheus.Counter
- type Namespaces
- type ReconciliationStatus
- type ReconciliationTracker
- func (rt *ReconciliationTracker) Collect(ch chan<- prometheus.Metric)
- func (rt *ReconciliationTracker) Describe(ch chan<- *prometheus.Desc)
- func (rt *ReconciliationTracker) ForgetObject(k string)
- func (rt *ReconciliationTracker) GetStatus(k string) (ReconciliationStatus, bool)
- func (rt *ReconciliationTracker) SetStatus(k string, err error)
- type ReloaderConfig
- type ReloaderOption
- func ConfigEnvsubstFile(configEnvsubstFile string) ReloaderOption
- func ConfigFile(configFile string) ReloaderOption
- func ListenLocal(listenLocal bool) ReloaderOption
- func LocalHost(localHost string) ReloaderOption
- func LogFormat(logFormat string) ReloaderOption
- func LogLevel(logLevel string) ReloaderOption
- func ReloaderResources(rc ReloaderConfig) ReloaderOption
- func ReloaderRunOnce() ReloaderOption
- func ReloaderURL(reloadURL url.URL) ReloaderOption
- func Shard(shard int32) ReloaderOption
- func VolumeMounts(mounts []v1.VolumeMount) ReloaderOption
- func WatchedDirectories(watchedDirectories []string) ReloaderOption
- type ShardedSecret
Constants ¶
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 )
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 ¶
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", "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 ¶ added in v0.42.0
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 ¶ added in v0.54.0
func CompareScrapeTimeoutToScrapeInterval(scrapeTimeout, scrapeInterval monitoringv1.Duration) error
CompareScrapeTimeoutToScrapeInterval validates value of scrapeTimeout based on scrapeInterval
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 CurlProber ¶ added in v0.57.0
func GunzipConfig ¶ added in v0.59.0
func MakeHostAliases ¶ added in v0.57.0
func MakeHostAliases(input []monitoringv1.HostAlias) []v1.HostAlias
MakeHostAliases converts array of monitoringv1 HostAlias to array of corev1 HostAlias
func MakeVolumeClaimTemplate ¶ added in v0.42.0
func MakeVolumeClaimTemplate(e monitoringv1.EmbeddedPersistentVolumeClaim) *v1.PersistentVolumeClaim
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
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
StringValOrDefault returns the default val if the given string is empty/whitespace. Otherwise returns the value of the string..
func ValidateDurationField ¶ added in v0.52.0
func ValidateSizeField ¶ added in v0.52.0
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.
func WgetProber ¶ added in v0.57.0
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 ¶ 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 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) 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) ReconcileDurationHistogram ¶ added in v0.56.0
func (m *Metrics) ReconcileDurationHistogram() prometheus.Histogram
ReconcileDurationHistogram returns a histogram to track the duration of 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
SetRejectedResources sets the number of resources that the controller rejected for the given object's key.
func (*Metrics) SetSelectedResources ¶ added in v0.43.0
SetSelectedResources sets the number of resources that the controller selected for the given object's key.
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 ReconciliationStatus ¶ added in v0.56.0
type ReconciliationStatus struct {
// contains filtered or unexported fields
}
func (ReconciliationStatus) Message ¶ added in v0.56.0
func (rs ReconciliationStatus) Message() string
func (ReconciliationStatus) Ok ¶ added in v0.56.0
func (rs ReconciliationStatus) Ok() bool
func (ReconciliationStatus) Reason ¶ added in v0.56.0
func (rs ReconciliationStatus) Reason() string
type ReconciliationTracker ¶ added in v0.56.0
type ReconciliationTracker struct {
// contains filtered or unexported fields
}
ReconciliationTracker tracks reconciliation status per object. The zero ReconciliationTracker is ready to use.
func (*ReconciliationTracker) Collect ¶ added in v0.56.0
func (rt *ReconciliationTracker) Collect(ch chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*ReconciliationTracker) Describe ¶ added in v0.56.0
func (rt *ReconciliationTracker) Describe(ch chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
func (*ReconciliationTracker) ForgetObject ¶ added in v0.56.0
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 ¶ added in v0.56.0
func (rt *ReconciliationTracker) GetStatus(k string) (ReconciliationStatus, bool)
GetStatus returns the last reconciliation status for the given object. The second value indicates whether the object is known or not.
func (*ReconciliationTracker) SetStatus ¶ added in v0.56.0
func (rt *ReconciliationTracker) SetStatus(k string, err error)
SetStatus updates the last reconciliation status for the given object.
type ReloaderConfig ¶ added in v0.43.0
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 ShardedSecret ¶ added in v0.53.0
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 ¶ added in v0.53.0
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 ¶ added in v0.53.0
func (s *ShardedSecret) AppendData(key string, data []byte)
AppendData adds data to the secrets data portion. Already existing keys get overwritten.
func (*ShardedSecret) ShardNames ¶ added in v0.53.0
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 ¶ added in v0.53.0
func (s *ShardedSecret) StoreSecrets(ctx context.Context, sClient corev1.SecretInterface) error
StoreSecrets creates the individual secret shards and stores it via sClient.