Skip to content

Commit

Permalink
Merge pull request #82 from saswatamcode/queryfrontend
Browse files Browse the repository at this point in the history
Add Thanos Query frontend in Query CRD and deployment
  • Loading branch information
saswatamcode committed Sep 4, 2024
2 parents 9a98f94 + dab9ab2 commit d5ae508
Show file tree
Hide file tree
Showing 12 changed files with 4,543 additions and 20 deletions.
48 changes: 48 additions & 0 deletions api/v1alpha1/thanosquery_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -44,13 +45,60 @@ type ThanosQuerySpec struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default:={matchLabels:{"operator.thanos.io/store-api": "true"}}
StoreLabelSelector *metav1.LabelSelector `json:"customStoreLabelSelector,omitempty"`
// QueryFrontend is the configuration for the Query Frontend
// If you specify this, the operator will create a Query Frontend in front of your
// Querier deployment.
// +kubebuilder:validation:Optional
QueryFrontend *QueryFrontendSpec `json:"queryFrontend,omitempty"`
// Additional configuration for the Thanos components. Allows you to add
// additional args, containers, volumes, and volume mounts to Thanos Deployments,
// and StatefulSets. Ideal to use for things like sidecars.
// +kubebuilder:validation:Optional
Additional `json:",inline"`
}

// QueryFrontendSpec defines the desired state of ThanosQueryFrontend
type QueryFrontendSpec struct {
CommonThanosFields `json:",inline"`
// +kubebuilder:validation:Minimum=1
// +kubebuilder:default=1
Replicas int32 `json:"replicas,omitempty"`
// CompressResponses enables response compression
// +kubebuilder:default=true
CompressResponses bool `json:"compressResponses,omitempty"`
// By default, the operator will add the first discoverable Query API to the
// Query Frontend, if they have query labels. You can optionally choose to override default
// Query selector labels, to select a subset of QueryAPIs to query.
// +kubebuilder:validation:Optional
// +kubebuilder:default:={matchLabels:{"operator.thanos.io/query-api": "true"}}
QueryLabelSelector *metav1.LabelSelector `json:"queryLabelSelector,omitempty"`
// LogQueriesLongerThan sets the duration threshold for logging long queries
// +kubebuilder:validation:Optional
LogQueriesLongerThan *Duration `json:"logQueriesLongerThan,omitempty"`
// QueryRangeResponseCacheConfig holds the configuration for the query range response cache
// +kubebuilder:validation:Optional
QueryRangeResponseCacheConfig *corev1.ConfigMapKeySelector `json:"queryRangeResponseCacheConfig,omitempty"`
// QueryRangeSplitInterval sets the split interval for query range
// +kubebuilder:validation:Optional
QueryRangeSplitInterval *Duration `json:"queryRangeSplitInterval,omitempty"`
// LabelsSplitInterval sets the split interval for labels
// +kubebuilder:validation:Optional
LabelsSplitInterval *Duration `json:"labelsSplitInterval,omitempty"`
// QueryRangeMaxRetries sets the maximum number of retries for query range requests
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=5
QueryRangeMaxRetries int `json:"queryRangeMaxRetries,omitempty"`
// LabelsMaxRetries sets the maximum number of retries for label requests
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=5
LabelsMaxRetries int `json:"labelsMaxRetries,omitempty"`
// LabelsDefaultTimeRange sets the default time range for label queries
// +kubebuilder:validation:Optional
LabelsDefaultTimeRange *Duration `json:"labelsDefaultTimeRange,omitempty"`
// Additional configuration for the Thanos components
Additional `json:",inline"`
}

// ThanosQueryStatus defines the observed state of ThanosQuery
type ThanosQueryStatus struct {
// Conditions represent the latest available observations of the state of the Querier.
Expand Down
52 changes: 52 additions & 0 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: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "ThanosRuler")
os.Exit(1)
}

//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading

0 comments on commit d5ae508

Please sign in to comment.