Skip to content

Commit

Permalink
Merge pull request #23 from philipgough/rec-safe
Browse files Browse the repository at this point in the history
Adds routing logic for Thanos receive
  • Loading branch information
philipgough authored Jun 21, 2024
2 parents 30c6cd6 + 5a89f52 commit 0be3c49
Show file tree
Hide file tree
Showing 20 changed files with 1,577 additions and 225 deletions.
7 changes: 5 additions & 2 deletions api/v1alpha1/thanosreceive_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type RouterSpec struct {
ReplicationFactor int32 `json:"replicationFactor,omitempty"`
// ExternalLabels set and forwarded by the router to the ingesters.
// +kubebuilder:default={receive: "true"}
// +kubebuilder:validation:Required
ExternalLabels ExternalLabels `json:"externalLabels,omitempty"`
}

Expand Down Expand Up @@ -73,6 +74,7 @@ type IngestorHashringSpec struct {
Labels map[string]string `json:"labels,omitempty"`
// ExternalLabels to add to the ingesters tsdb blocks.
// +kubebuilder:default={replica: "$(POD_NAME)"}
// +kubebuilder:validation:Required
ExternalLabels ExternalLabels `json:"externalLabels,omitempty"`
// Replicas is the number of replicas/members of the hashring to add to the Thanos Receive StatefulSet.
// +kubebuilder:validation:Minimum=1
Expand All @@ -81,8 +83,8 @@ type IngestorHashringSpec struct {
Replicas int32 `json:"replicas,omitempty"`
// Retention is the duration for which the Thanos Receive StatefulSet will retain data.
// +kubebuilder:default="2h"
// +kubebuilder:validation:Optional
Retention *Duration `json:"retention,omitempty"`
// +kubebuilder:validation:Required
Retention Duration `json:"retention,omitempty"`
// ObjectStorageConfig is the secret that contains the object storage configuration for the hashring.
// +kubebuilder:validation:Optional
ObjectStorageConfig *ObjectStorageConfig `json:"objectStorageConfig,omitempty"`
Expand All @@ -104,6 +106,7 @@ type IngestorHashringSpec struct {
// +kubebuilder:validation:XValidation:rule="self.ingestor.hashrings.all(h, h.replicas >= self.router.replicationFactor )", message=" Ingester replicas must be greater than or equal to the Router replicas"
type ThanosReceiveSpec struct {
// CommonThanosFields are the options available to all Thanos components.
// +kubebuilder:validation:Optional
CommonThanosFields `json:",inline"`
// Router is the configuration for the router.
// +kubebuilder:validation:Required
Expand Down
17 changes: 9 additions & 8 deletions api/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,30 @@ type CommonThanosFields struct {
// Container image to use for the Thanos components.
// +kubebuilder:validation:Optional
Image *string `json:"image,omitempty"`

// Image pull policy for the Thanos containers.
// See https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy for more details.
// +kubebuilder:validation:Enum=Always;Never;IfNotPresent
// +kubebuilder:default:=IfNotPresent
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
// +kubebuilder:validation:Optional
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
// An optional list of references to Secrets in the same namespace
// to use for pulling images from registries.
// See http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
// +kubebuilder:validation:Optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// When a resource is paused, no actions except for deletion
// will be performed on the underlying objects.
Paused bool `json:"paused,omitempty"`

// +kubebuilder:validation:Optional
Paused *bool `json:"paused,omitempty"`
// Log level for Thanos.
// +kubebuilder:validation:Enum=debug;info;warn;error
// +kubebuilder:default:=info
LogLevel string `json:"logLevel,omitempty" opt:"log.level"`
// +kubebuilder:validation:Optional
LogLevel *string `json:"logLevel,omitempty"`
// Log format for Thanos.
// +kubebuilder:validation:Enum=logfmt;json
// +kubebuilder:default:=logfmt
LogFormat string `json:"logFormat,omitempty" opt:"log.format"`
// +kubebuilder:validation:Optional
LogFormat *string `json:"logFormat,omitempty"`
}

func (osc *ObjectStorageConfig) ToSecretKeySelector() corev1.SecretKeySelector {
Expand Down
25 changes: 20 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config/crd/bases/monitoring.thanos.io_thanoscompacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ spec:
- json
type: string
logLevel:
default: info
description: Log level for Thanos.
enum:
- debug
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/monitoring.thanos.io_thanosqueries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ spec:
- json
type: string
logLevel:
default: info
description: Log level for Thanos.
enum:
- debug
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/monitoring.thanos.io_thanosreceives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ spec:
- json
type: string
logLevel:
default: info
description: Log level for Thanos.
enum:
- debug
Expand Down
2 changes: 1 addition & 1 deletion config/samples/v1alpha1_thanosreceive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: thanosreceive-sample
spec:
# TODO(user): Add fields here

36 changes: 35 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ go 1.21

require (
github.com/go-logr/logr v1.4.1
github.com/golang/snappy v0.0.4
github.com/imdario/mergo v0.3.16
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/prometheus/client_golang v1.19.0
github.com/prometheus/common v0.53.0
github.com/prometheus/prometheus v0.52.1
github.com/stretchr/testify v1.9.0
k8s.io/api v0.29.3
Expand All @@ -18,19 +20,31 @@ require (
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
github.com/aws/aws-sdk-go v1.51.25 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
Expand All @@ -39,20 +53,38 @@ require (
github.com/google/pprof v0.0.0-20240416155748-26353dc0451f // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/collector/featuregate v1.5.0 // indirect
go.opentelemetry.io/collector/pdata v1.5.0 // indirect
go.opentelemetry.io/collector/semconv v0.98.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
Expand All @@ -62,6 +94,8 @@ require (
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 0be3c49

Please sign in to comment.