manifests

package
v0.0.0-...-5e131ef Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameLabel      = "app.kubernetes.io/name"
	ComponentLabel = "app.kubernetes.io/component"
	PartOfLabel    = "app.kubernetes.io/part-of"
	ManagedByLabel = "app.kubernetes.io/managed-by"
	InstanceLabel  = "app.kubernetes.io/instance"

	DefaultPartOfLabel    = "thanos"
	DefaultManagedByLabel = "thanos-operator"

	// The following label is used to identify StoreAPIs and will be set on the resources created by the operator.
	DefaultStoreAPILabel = "operator.thanos.io/store-api"
	DefaultStoreAPIValue = "true"

	// The following label is used to identify Query APIs and will be set on the resources created by the operator.
	DefaultQueryAPILabel = "operator.thanos.io/query-api"
	DefaultQueryAPIValue = "true"

	// The following label is used to identify Rule Configs and will be set on the resources created by the operator.
	DefaultRuleConfigLabel = "operator.thanos.io/rule-file"
	DefaultRuleConfigValue = "true"

	// DefaultPrometheusRuleLabel is the default label key for PrometheusRule CRDs
	DefaultPrometheusRuleLabel = "operator.thanos.io/prometheus-rule"
	// DefaultPrometheusRuleValue is the default label value for PrometheusRule CRDs
	DefaultPrometheusRuleValue = "true"

	// OwnerLabel is the label used to identify the owner of the object.
	// This relates to the CustomResource or entity that created the object.
	OwnerLabel = "operator.thanos.io/owner"
)
View Source
const (
	DefaultThanosImage   = "quay.io/thanos/thanos"
	DefaultThanosVersion = "v0.35.1"
)

Variables

This section is empty.

Functions

func AugmentWithOptions

func AugmentWithOptions(obj client.Object, opts Options)

AugmentWithOptions augments the object with the options. Supported objects are Deployment and StatefulSet.

func BuildLabelSelectorFrom

func BuildLabelSelectorFrom(labelSelector *metav1.LabelSelector, requiredLabels map[string]string) (labels.Selector, error)

BuildLabelSelectorFrom builds a label selector from the provided label selector and required labels. The required labels will be added to the MatchLabels of the provided label selector. labelSelector is DeepCopied to avoid modifying the original object.

func BuildServiceAccount

func BuildServiceAccount(name, namespace string, labels, annotations map[string]string) client.Object

BuildServiceAccount returns a new ServiceAccount from Options.

func BuildServiceMonitor

func BuildServiceMonitor(name, namespace string, objectMetaLabels, selectorLabels map[string]string, opts ServiceMonitorOptions) *monitoringv1.ServiceMonitor

func GetLabelSelectorForOwner

func GetLabelSelectorForOwner(opts Buildable) client.ListOption

GetLabelSelectorForOwner is a convenience function to enable building a ListOption for the Owner label. This strips out the instance label and returns a ListOption that can be used to select resources that were built by Buildable and owned by a given object.

func HasPrometheusRuleEnabled

func HasPrometheusRuleEnabled(in *v1alpha1.FeatureGates) bool

func HasRequiredLabels

func HasRequiredLabels(obj client.Object, requiredLabels map[string]string) bool

HasRequiredLabels returns true if the given object has the required labels.

func HasServiceMonitorEnabled

func HasServiceMonitorEnabled(in *v1alpha1.FeatureGates) bool

func IsGrpcServiceWithLabels

func IsGrpcServiceWithLabels(obj client.Object, requiredLabels map[string]string) (int32, bool)

IsGrpcServiceWithLabels returns true if the given object is a gRPC service with required labels. The requiredLabels map is used to match the labels of the object. The function returns false if the object is not a service or if it does not have a gRPC port. The function returns true, alongside the port if the object is a service with a gRPC port and has the required labels.

func IsNamespacedResource

func IsNamespacedResource(obj client.Object) bool

IsNamespacedResource returns true if the given object is namespaced.

func MergeLabels

func MergeLabels(baseLabels map[string]string, mergeWithPriority map[string]string) map[string]string

MergeLabels merges the provided labels with the default labels for a component. Returns a new map with the merged labels leaving the original maps unchanged.

func MutateFuncFor

func MutateFuncFor(existing, desired client.Object) controllerutil.MutateFn

MutateFuncFor returns a mutate function based on the existing resource's concrete type. It currently supports the following types and will return an error for other types:

  • ConfigMap
  • Secret
  • Service
  • ServiceAccount
  • Deployment
  • StatefulSet
  • ServiceMonitor

func NewPodDisruptionBudget

func NewPodDisruptionBudget(name, namespace string, selectorLabels, objectMetaLabels, annotations map[string]string, opts PodDisruptionBudgetOptions) *policyv1.PodDisruptionBudget

NewPodDisruptionBudget creates a new PodDisruptionBudget object. It sets the object name, namespace, selector labels, object meta labels, and maxUnavailable. The maxUnavailable is a pointer to an int32 value. If the maxUnavailable is nil, it defaults to 1.

func OptionalToString

func OptionalToString[T any](ptr *T) string

OptionalToString returns the string representation of the given pointer or an empty string if the pointer is nil. Helps avoid bunch of typecasts and nil-checks throughout. Works only for basic types and not complex ones like slices, structs and maps.

func PruneEmptyArgs

func PruneEmptyArgs(args []string) []string

PruneEmptyArgs removes empty or empty value arguments from the given slice.

func SanitizeName

func SanitizeName(name string) string

SanitizeName sanitizes the name to make it clean for writing kubernetes objects The core of this function was copied from https://github.com/solo-io/k8s-utils

func SanitizeStoreAPIEndpointLabels

func SanitizeStoreAPIEndpointLabels(baseLabels map[string]string) map[string]string

SanitizeStoreAPIEndpointLabels ensures StoreAPI has only a single type of endpoint label. If multiple endpoint types are set, the function will remove the conflicting labels based on priority.

func ValidateAndSanitizeNameToValidLabelValue

func ValidateAndSanitizeNameToValidLabelValue(value string) string

ValidateAndSanitizeNameToValidLabelValue sanitizes the provided name to a valid label value. The core of this function was copied from https://github.com/solo-io/k8s-utils

func ValidateAndSanitizeResourceName

func ValidateAndSanitizeResourceName(name string) string

ValidateAndSanitizeResourceName sanitizes the provided name to a valid DNS-1123 subdomain.

Types

type Additional

type Additional struct {
	// Additional arguments to pass to the Thanos components.
	Args []string
	// Additional containers to add to the Thanos components.
	Containers []corev1.Container
	// Additional volumes to add to the Thanos components.
	Volumes []corev1.Volume
	// Additional volume mounts to add to the Thanos component container in a Deployment or StatefulSet
	// controlled by the operator.
	VolumeMounts []corev1.VolumeMount
	// Additional ports to expose on the Thanos component container in a Deployment or StatefulSet
	// controlled by the operator.
	Ports []corev1.ContainerPort
	// Additional environment variables to add to the Thanos component container in a Deployment or StatefulSet
	// controlled by the operator.
	Env []corev1.EnvVar
	// AdditionalServicePorts are additional ports to expose on the Service for the Thanos component.
	ServicePorts []corev1.ServicePort
}

type Buildable

type Buildable interface {
	Build() []client.Object
	// GetGeneratedResourceName is the name of the objects that will be generated by BuildServiceMonitor.
	// Implementations should use this value to populate the InstanceLabel after it has been
	// run through ValidateAndSanitizeNameToValidLabelValue.
	// In many cases, implementations will require just Name and Owner to generate this value.
	// In some cases, particularly where sharded resources are built, an implementation may require additional
	// information to generate this value. This should be documented in the implementation.
	GetGeneratedResourceName() string
	// GetSelectorLabels returns the labels that should be used to select the object
	// Implementations must ensure that the following labels are set:
	// - NameLabel
	// - ComponentLabel
	// - PartOfLabel
	// - ManagedByLabel
	// - InstanceLabel
	// - OwnerLabel
	GetSelectorLabels() map[string]string
}

type CacheConfig

type CacheConfig struct {
	InMemoryCacheConfig *InMemoryCacheConfig
	FromSecret          *corev1.SecretKeySelector
}

type Duration

type Duration string

type EndpointType

type EndpointType string

EndpointType is the type of endpoint flag to be used for attaching the StoreAPI to Querier.

const (
	RegularLabel     EndpointType = "operator.thanos.io/endpoint"
	StrictLabel      EndpointType = "operator.thanos.io/endpoint-strict"
	GroupLabel       EndpointType = "operator.thanos.io/endpoint-group"
	GroupStrictLabel EndpointType = "operator.thanos.io/endpoint-group-strict"
)

type InMemoryCacheConfig

type InMemoryCacheConfig struct {
	MaxSize     string
	MaxItemSize string
}

func (InMemoryCacheConfig) String

func (ic InMemoryCacheConfig) String() string

type Options

type Options struct {
	Additional
	// Owner is the name of the owner of the object. This relates to the CustomResource or entity that created the object.
	// This value will be used to populate the OwnerLabel after it has been run through ValidateAndSanitizeResourceName.
	// This should be set to the name of the CustomResource that is creating the object and is a required field.
	Owner string
	// Namespace is the namespace for the object
	Namespace string
	// Replicas is the number of replicas for the object.
	// Specific build functions may override this value.
	Replicas int32
	// Labels is the labels for the object
	// Labels will be merged with the default labels for the component.
	// The builders should ensure that the default labels are set on the object.
	// The builders will overwrite the default labels if they are set in the Labels.
	Labels map[string]string
	// Annotations is the annotations for the object
	Annotations map[string]string
	// Image is the image to use for the component
	// If not set, DefaultThanosImage will be used
	Image *string
	// Version is the version of Thanos
	// If not set, DefaultThanosVersion will be used
	Version *string
	// ResourceRequirements for the component
	ResourceRequirements *corev1.ResourceRequirements
	// LogLevel is the log level for the component
	LogLevel *string
	// LogFormat is the log format for the component
	LogFormat *string
	//ServiceMonitorConfig is the configuration for the ServiceMonitor
	ServiceMonitorConfig ServiceMonitorConfig
	// PodDisruptionConfig is the configuration for the PodDisruptionBudget
	// If not set, the PodDisruptionBudget will not be created.
	PodDisruptionConfig *PodDisruptionBudgetOptions
}

Options is a struct that holds the options for the common manifests

func (Options) GetContainerImage

func (o Options) GetContainerImage() string

GetContainerImage for the Options

func (Options) ToFlags

func (o Options) ToFlags() []string

ToFlags returns the flags for the Options

type PodDisruptionBudgetOptions

type PodDisruptionBudgetOptions struct {
	// MaxUnavailable is the maximum number of pods that can be unavailable during the disruption.
	// Defaults to 1 if not specified.
	MaxUnavailable *int32
	// MinAvailable is the minimum number of pods that must still be available during the disruption.
	// Defaults to nil if not specified.
	MinAvailable *int32
}

PodDisruptionBudgetOptions defines the available options for creating a PodDisruptionBudget object.

type RelabelConfig

type RelabelConfig struct {
	Action      string
	SourceLabel string
	TargetLabel string
	// Modulus is relevant for the hashmod action.
	Modulus int
	// Regex is relevant for non-hashmod actions.
	Regex string
}

RelabelConfig is a struct that holds the relabel configuration

func (RelabelConfig) String

func (r RelabelConfig) String() string

String returns the string representation of the RelabelConfig

type RelabelConfigs

type RelabelConfigs []RelabelConfig

RelabelConfigs is a slice of RelabelConfig

func (RelabelConfigs) String

func (rc RelabelConfigs) String() string

String returns the string representation of the RelabelConfigs

func (RelabelConfigs) ToFlags

func (rc RelabelConfigs) ToFlags() string

ToFlags returns the flags for the RelabelConfigs

type ServiceMonitorConfig

type ServiceMonitorConfig struct {
	Enabled   bool
	Namespace string
	Interval  *Duration
	Labels    map[string]string
}

type ServiceMonitorOptions

type ServiceMonitorOptions struct {
	// Port is the name of the port on the target service to scrape.
	// Defaults to "http" if not specified.
	Port *string
	// Interval at which metrics should be scraped.
	// Defaults to 30s if not specified.
	Interval *Duration
	// Path is the path on the target service to scrape for metrics.
	// Defaults to "/metrics" if not specified.
	Path *string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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