Skip to content

Commit

Permalink
feat: add thanos querier CRD (#52)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
  • Loading branch information
jan--f authored Oct 29, 2021
1 parent e971bf7 commit 0dd9499
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 0 deletions.
123 changes: 123 additions & 0 deletions deploy/crds/common/monitoring.rhobs_thanosqueriers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: thanosqueriers.monitoring.rhobs
spec:
group: monitoring.rhobs
names:
kind: ThanosQuerier
listKind: ThanosQuerierList
plural: thanosqueriers
singular: thanosquerier
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ThanosQuerier outlines the Thanos querier components, managed
by this stack
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ThanosQuerierSpec defines a single Thanos Querier instance.
This means a label selector by which Monitoring Stack instances to query
are selected, and an optional namespace selector and a list of replica
labels by which to deduplicate.
properties:
namespaceSelector:
description: Selector to select which namespaces the Monitoring Stack
objects are discovered from.
properties:
any:
description: Boolean describing whether all namespaces are selected
in contrast to a list restricting them.
type: boolean
matchNames:
description: List of namespace names.
items:
type: string
type: array
type: object
replicaLabels:
items:
type: string
type: array
selector:
description: Selector to select Monitoring stacks to unify
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
required:
- selector
type: object
status:
description: ThanosQuerierStatus defines the observed state of ThanosQuerier.
It should always be reconstructable from the state of the cluster and/or
outside world.
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
49 changes: 49 additions & 0 deletions pkg/apis/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,52 @@ type MonitoringStackStatus struct {
// TODO(sthaha): INSERT ADDITIONAL STATUS FIELDS -- observed state of prometheus
// ??
}

// NamespaceSelector is a selector for selecting either all namespaces or a
// list of namespaces.
// +k8s:openapi-gen=true
type NamespaceSelector struct {
// Boolean describing whether all namespaces are selected in contrast to a
// list restricting them.
Any bool `json:"any,omitempty"`
// List of namespace names.
MatchNames []string `json:"matchNames,omitempty"`
}

// ThanosQuerier outlines the Thanos querier components, managed by this stack
// +k8s:openapi-gen=true
// +kubebuilder:resource
// +kubebuilder:subresource:status
type ThanosQuerier struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ThanosQuerierSpec `json:"spec,omitempty"`
Status ThanosQuerierStatus `json:"status,omitempty"`
}

// ThanosQuerierList contains a list of ThanosQuerier
// +kubebuilder:resource
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ThanosQuerierList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ThanosQuerier `json:"items"`
}

// ThanosQuerierSpec defines a single Thanos Querier instance. This means a
// label selector by which Monitoring Stack instances to query are selected, and
// an optional namespace selector and a list of replica labels by which to
// deduplicate.
type ThanosQuerierSpec struct {
// Selector to select Monitoring stacks to unify
Selector metav1.LabelSelector `json:"selector"`
// Selector to select which namespaces the Monitoring Stack objects are discovered from.
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
ReplicaLabels []string `json:"replicaLabels,omitempty"`
}

// ThanosQuerierStatus defines the observed state of ThanosQuerier.
// It should always be reconstructable from the state of the cluster and/or outside world.
type ThanosQuerierStatus struct {
}
108 changes: 108 additions & 0 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

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

0 comments on commit 0dd9499

Please sign in to comment.