-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TargetAllocator CRD #2516
Merged
Merged
Add TargetAllocator CRD #2516
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v1alpha2 | ||
|
||
type ( | ||
// TargetAllocatorAllocationStrategy represent a strategy Target Allocator uses to distribute targets to each collector | ||
// +kubebuilder:validation:Enum=least-weighted;consistent-hashing | ||
TargetAllocatorAllocationStrategy string | ||
// TargetAllocatorFilterStrategy represent a filtering strategy for targets before they are assigned to collectors | ||
// +kubebuilder:validation:Enum="";relabel-config | ||
TargetAllocatorFilterStrategy string | ||
) | ||
|
||
const ( | ||
// TargetAllocatorAllocationStrategyLeastWeighted targets will be distributed to collector with fewer targets currently assigned. | ||
TargetAllocatorAllocationStrategyLeastWeighted TargetAllocatorAllocationStrategy = "least-weighted" | ||
|
||
// TargetAllocatorAllocationStrategyConsistentHashing targets will be consistently added to collectors, which allows a high-availability setup. | ||
TargetAllocatorAllocationStrategyConsistentHashing TargetAllocatorAllocationStrategy = "consistent-hashing" | ||
|
||
// TargetAllocatorFilterStrategyRelabelConfig targets will be consistently drops targets based on the relabel_config. | ||
TargetAllocatorFilterStrategyRelabelConfig TargetAllocatorFilterStrategy = "consistent-hashing" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +kubebuilder:skip | ||
|
||
package v1alpha2 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// TargetAllocatorSpec defines the desired state of TargetAllocator. | ||
type TargetAllocatorSpec struct { | ||
// Common defines fields that are common to all OpenTelemetry CRD workloads. | ||
OpenTelemetryCommonFields `json:",inline"` | ||
// AllocationStrategy determines which strategy the target allocator should use for allocation. | ||
// The current options are least-weighted and consistent-hashing. The default option is consistent-hashing | ||
// +optional | ||
// +kubebuilder:default:=consistent-hashing | ||
AllocationStrategy TargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"` | ||
// FilterStrategy determines how to filter targets before allocating them among the collectors. | ||
// The only current option is relabel-config (drops targets based on prom relabel_config). | ||
// The default is relabel-config. | ||
// +optional | ||
// +kubebuilder:default:=relabel-config | ||
FilterStrategy TargetAllocatorFilterStrategy `json:"filterStrategy,omitempty"` | ||
// ServiceAccount indicates the name of an existing service account to use with this instance. When set, | ||
// the operator will not automatically create a ServiceAccount for the TargetAllocator. | ||
// +optional | ||
PrometheusCR TargetAllocatorPrometheusCR `json:"prometheusCR,omitempty"` | ||
} | ||
|
||
// TargetAllocatorPrometheusCR configures Prometheus CustomResource handling in the Target Allocator. | ||
type TargetAllocatorPrometheusCR struct { | ||
// Enabled indicates whether to use a PrometheusOperator custom resources as targets or not. | ||
// +optional | ||
Enabled bool `json:"enabled,omitempty"` | ||
// Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. | ||
//Equivalent to the same setting on the Prometheus CR. | ||
// | ||
// Default: "30s" | ||
// +kubebuilder:default:="30s" | ||
// +kubebuilder:validation:Format:=duration | ||
ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"` | ||
// PodMonitors to be selected for target discovery. | ||
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a | ||
// PodMonitor's meta labels. The requirements are ANDed. | ||
// +optional | ||
PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"` | ||
// ServiceMonitors to be selected for target discovery. | ||
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a | ||
// ServiceMonitor's meta labels. The requirements are ANDed. | ||
// +optional | ||
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` | ||
} | ||
|
||
// TargetAllocatorStatus defines the observed state of Target Allocator. | ||
type TargetAllocatorStatus struct { | ||
// Version of the managed Target Allocator (operand) | ||
// +optional | ||
Version string `json:"version,omitempty"` | ||
|
||
// Image indicates the container image to use for the Target Allocator. | ||
// +optional | ||
Image string `json:"image,omitempty"` | ||
|
||
// Messages about actions performed by the operator on this resource. | ||
// +optional | ||
// +listType=atomic | ||
// Deprecated: use Kubernetes events instead. | ||
Messages []string `json:"messages,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// TargetAllocator is the Schema for the targetallocators API. | ||
type TargetAllocator struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec TargetAllocatorSpec `json:"spec,omitempty"` | ||
Status TargetAllocatorStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// TargetAllocatorList contains a list of TargetAllocator. | ||
type TargetAllocatorList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []OpenTelemetryCollector `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&TargetAllocator{}, &TargetAllocatorList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for the future, it would be REALLY cool if we could add some info here like number of jobs, collectors discovered, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cool to book a ticket for it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how difficult it is to actually do this. We'd have to get the target allocator metrics, which while not exactly difficult, seems not very robust to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
certainly something to figure out in the future. #2549