Skip to content

Commit 0c8239e

Browse files
authored
Merge branch 'main' into per-node-strategy
2 parents 0e09fc8 + 2910ea9 commit 0c8239e

24 files changed

+644
-294
lines changed

.chloggen/target-allocator-pdb.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: target allocator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: PDB support for target allocator
9+
10+
# One or more tracking issues related to the change
11+
issues: [2261]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

apis/v1alpha1/collector_webhook.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (c CollectorWebhook) defaulter(r *OpenTelemetryCollector) error {
126126
}
127127
}
128128

129-
// if pod isn't provided, we set MaxUnavailable 1,
129+
// if pdb isn't provided, we set MaxUnavailable 1,
130130
// which will work even if there is just one replica,
131131
// not blocking node drains but preventing out-of-the-box
132132
// from disruption generated by them with replicas > 1
@@ -139,6 +139,22 @@ func (c CollectorWebhook) defaulter(r *OpenTelemetryCollector) error {
139139
}
140140
}
141141

142+
// if pdb isn't provided for target allocator and it's enabled
143+
// using a valid strategy (consistent-hashing),
144+
// we set MaxUnavailable 1, which will work even if there is
145+
// just one replica, not blocking node drains but preventing
146+
// out-of-the-box from disruption generated by them with replicas > 1
147+
if r.Spec.TargetAllocator.Enabled &&
148+
r.Spec.TargetAllocator.AllocationStrategy == OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing &&
149+
r.Spec.TargetAllocator.PodDisruptionBudget == nil {
150+
r.Spec.TargetAllocator.PodDisruptionBudget = &PodDisruptionBudgetSpec{
151+
MaxUnavailable: &intstr.IntOrString{
152+
Type: intstr.Int,
153+
IntVal: 1,
154+
},
155+
}
156+
}
157+
142158
if r.Spec.Ingress.Type == IngressTypeRoute && r.Spec.Ingress.Route.Termination == "" {
143159
r.Spec.Ingress.Route.Termination = TLSRouteTerminationTypeEdge
144160
}

apis/v1alpha1/collector_webhook_test.go

+128-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func TestOTELColDefaultingWebhook(t *testing.T) {
242242
},
243243
},
244244
{
245-
name: "Defined PDB",
245+
name: "Defined PDB for collector",
246246
otelcol: OpenTelemetryCollector{
247247
Spec: OpenTelemetryCollectorSpec{
248248
Mode: ModeDeployment,
@@ -274,6 +274,133 @@ func TestOTELColDefaultingWebhook(t *testing.T) {
274274
},
275275
},
276276
},
277+
{
278+
name: "Defined PDB for target allocator",
279+
otelcol: OpenTelemetryCollector{
280+
Spec: OpenTelemetryCollectorSpec{
281+
Mode: ModeDeployment,
282+
TargetAllocator: OpenTelemetryTargetAllocator{
283+
Enabled: true,
284+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing,
285+
PodDisruptionBudget: &PodDisruptionBudgetSpec{
286+
MinAvailable: &intstr.IntOrString{
287+
Type: intstr.String,
288+
StrVal: "10%",
289+
},
290+
},
291+
},
292+
},
293+
},
294+
expected: OpenTelemetryCollector{
295+
ObjectMeta: metav1.ObjectMeta{
296+
Labels: map[string]string{
297+
"app.kubernetes.io/managed-by": "opentelemetry-operator",
298+
},
299+
},
300+
Spec: OpenTelemetryCollectorSpec{
301+
Mode: ModeDeployment,
302+
Replicas: &one,
303+
UpgradeStrategy: UpgradeStrategyAutomatic,
304+
ManagementState: ManagementStateManaged,
305+
PodDisruptionBudget: &PodDisruptionBudgetSpec{
306+
MaxUnavailable: &intstr.IntOrString{
307+
Type: intstr.Int,
308+
IntVal: 1,
309+
},
310+
},
311+
TargetAllocator: OpenTelemetryTargetAllocator{
312+
Enabled: true,
313+
Replicas: &one,
314+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing,
315+
PodDisruptionBudget: &PodDisruptionBudgetSpec{
316+
MinAvailable: &intstr.IntOrString{
317+
Type: intstr.String,
318+
StrVal: "10%",
319+
},
320+
},
321+
},
322+
},
323+
},
324+
},
325+
{
326+
name: "Undefined PDB for target allocator and consistent-hashing strategy",
327+
otelcol: OpenTelemetryCollector{
328+
Spec: OpenTelemetryCollectorSpec{
329+
Mode: ModeDeployment,
330+
TargetAllocator: OpenTelemetryTargetAllocator{
331+
Enabled: true,
332+
Replicas: &one,
333+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing,
334+
},
335+
},
336+
},
337+
expected: OpenTelemetryCollector{
338+
ObjectMeta: metav1.ObjectMeta{
339+
Labels: map[string]string{
340+
"app.kubernetes.io/managed-by": "opentelemetry-operator",
341+
},
342+
},
343+
Spec: OpenTelemetryCollectorSpec{
344+
Mode: ModeDeployment,
345+
Replicas: &one,
346+
UpgradeStrategy: UpgradeStrategyAutomatic,
347+
ManagementState: ManagementStateManaged,
348+
PodDisruptionBudget: &PodDisruptionBudgetSpec{
349+
MaxUnavailable: &intstr.IntOrString{
350+
Type: intstr.Int,
351+
IntVal: 1,
352+
},
353+
},
354+
TargetAllocator: OpenTelemetryTargetAllocator{
355+
Enabled: true,
356+
Replicas: &one,
357+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing,
358+
PodDisruptionBudget: &PodDisruptionBudgetSpec{
359+
MaxUnavailable: &intstr.IntOrString{
360+
Type: intstr.Int,
361+
IntVal: 1,
362+
},
363+
},
364+
},
365+
},
366+
},
367+
},
368+
{
369+
name: "Undefined PDB for target allocator and not consistent-hashing strategy",
370+
otelcol: OpenTelemetryCollector{
371+
Spec: OpenTelemetryCollectorSpec{
372+
Mode: ModeDeployment,
373+
TargetAllocator: OpenTelemetryTargetAllocator{
374+
Enabled: true,
375+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted,
376+
},
377+
},
378+
},
379+
expected: OpenTelemetryCollector{
380+
ObjectMeta: metav1.ObjectMeta{
381+
Labels: map[string]string{
382+
"app.kubernetes.io/managed-by": "opentelemetry-operator",
383+
},
384+
},
385+
Spec: OpenTelemetryCollectorSpec{
386+
Mode: ModeDeployment,
387+
Replicas: &one,
388+
UpgradeStrategy: UpgradeStrategyAutomatic,
389+
ManagementState: ManagementStateManaged,
390+
PodDisruptionBudget: &PodDisruptionBudgetSpec{
391+
MaxUnavailable: &intstr.IntOrString{
392+
Type: intstr.Int,
393+
IntVal: 1,
394+
},
395+
},
396+
TargetAllocator: OpenTelemetryTargetAllocator{
397+
Enabled: true,
398+
Replicas: &one,
399+
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted,
400+
},
401+
},
402+
},
403+
},
277404
}
278405

279406
for _, test := range tests {

apis/v1alpha1/opentelemetrycollector_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ type OpenTelemetryTargetAllocator struct {
341341
// consumed in the config file for the TargetAllocator.
342342
// +optional
343343
Env []v1.EnvVar `json:"env,omitempty"`
344+
// PodDisruptionBudget specifies the pod disruption budget configuration to use
345+
// for the target allocator workload.
346+
//
347+
// +optional
348+
PodDisruptionBudget *PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
344349
}
345350

346351
type OpenTelemetryTargetAllocatorPrometheusCR struct {

apis/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -5161,6 +5161,27 @@ spec:
51615161
description: NodeSelector to schedule OpenTelemetry TargetAllocator
51625162
pods.
51635163
type: object
5164+
podDisruptionBudget:
5165+
description: PodDisruptionBudget specifies the pod disruption
5166+
budget configuration to use for the target allocator workload.
5167+
properties:
5168+
maxUnavailable:
5169+
anyOf:
5170+
- type: integer
5171+
- type: string
5172+
description: An eviction is allowed if at most "maxUnavailable"
5173+
pods selected by "selector" are unavailable after the eviction,
5174+
i.e. even in absence of the evicted pod.
5175+
x-kubernetes-int-or-string: true
5176+
minAvailable:
5177+
anyOf:
5178+
- type: integer
5179+
- type: string
5180+
description: An eviction is allowed if at least "minAvailable"
5181+
pods selected by "selector" will still be available after
5182+
the eviction, i.e. even in the absence of the evicted pod.
5183+
x-kubernetes-int-or-string: true
5184+
type: object
51645185
prometheusCR:
51655186
description: PrometheusCR defines the configuration for the retrieval
51665187
of PrometheusOperator CRDs ( servicemonitor.monitoring.coreos.com/v1

cmd/otel-allocator/go.mod

+21-25
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module github.com/open-telemetry/opentelemetry-operator/cmd/otel-allocator
22

33
go 1.21
44

5-
toolchain go1.21.3
6-
75
require (
86
github.com/buraksezer/consistent v0.10.0
97
github.com/cespare/xxhash/v2 v2.2.0
@@ -13,12 +11,12 @@ require (
1311
github.com/go-logr/logr v1.3.0
1412
github.com/json-iterator/go v1.1.12
1513
github.com/oklog/run v1.1.0
16-
github.com/prometheus-operator/prometheus-operator v0.69.1
17-
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.69.1
18-
github.com/prometheus-operator/prometheus-operator/pkg/client v0.69.1
14+
github.com/prometheus-operator/prometheus-operator v0.70.0
15+
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.70.0
16+
github.com/prometheus-operator/prometheus-operator/pkg/client v0.70.0
1917
github.com/prometheus/client_golang v1.17.0
2018
github.com/prometheus/common v0.45.0
21-
github.com/prometheus/prometheus v0.48.0
19+
github.com/prometheus/prometheus v0.48.1
2220
github.com/spf13/pflag v1.0.5
2321
github.com/stretchr/testify v1.8.4
2422
gopkg.in/yaml.v2 v2.4.0
@@ -62,7 +60,7 @@ require (
6260
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
6361
github.com/envoyproxy/go-control-plane v0.11.1 // indirect
6462
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
65-
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
63+
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
6664
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
6765
github.com/fatih/color v1.15.0 // indirect
6866
github.com/fsnotify/fsnotify v1.7.0 // indirect
@@ -97,7 +95,7 @@ require (
9795
github.com/google/go-querystring v1.1.0 // indirect
9896
github.com/google/gofuzz v1.2.0 // indirect
9997
github.com/google/s2a-go v0.1.7 // indirect
100-
github.com/google/uuid v1.3.1 // indirect
98+
github.com/google/uuid v1.4.0 // indirect
10199
github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect
102100
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
103101
github.com/gophercloud/gophercloud v1.7.0 // indirect
@@ -117,7 +115,6 @@ require (
117115
github.com/hashicorp/serf v0.10.1 // indirect
118116
github.com/hetznercloud/hcloud-go/v2 v2.4.0 // indirect
119117
github.com/imdario/mergo v0.3.16 // indirect
120-
github.com/inconshreveable/mousetrap v1.1.0 // indirect
121118
github.com/ionos-cloud/sdk-go/v6 v6.1.9 // indirect
122119
github.com/jmespath/go-jmespath v0.4.0 // indirect
123120
github.com/josharian/intern v1.0.0 // indirect
@@ -155,7 +152,6 @@ require (
155152
github.com/prometheus/common/sigv4 v0.1.0 // indirect
156153
github.com/prometheus/procfs v0.11.1 // indirect
157154
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21 // indirect
158-
github.com/spf13/cobra v1.7.0 // indirect
159155
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
160156
github.com/ugorji/go/codec v1.2.11 // indirect
161157
github.com/vultr/govultr/v2 v2.17.2 // indirect
@@ -169,17 +165,17 @@ require (
169165
go.uber.org/multierr v1.11.0 // indirect
170166
go.uber.org/zap v1.25.0 // indirect
171167
golang.org/x/arch v0.3.0 // indirect
172-
golang.org/x/crypto v0.14.0 // indirect
173-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
174-
golang.org/x/mod v0.13.0 // indirect
175-
golang.org/x/net v0.17.0 // indirect
176-
golang.org/x/oauth2 v0.13.0 // indirect
177-
golang.org/x/sync v0.4.0 // indirect
178-
golang.org/x/sys v0.13.0 // indirect
179-
golang.org/x/term v0.13.0 // indirect
180-
golang.org/x/text v0.13.0 // indirect
181-
golang.org/x/time v0.3.0 // indirect
182-
golang.org/x/tools v0.14.0 // indirect
168+
golang.org/x/crypto v0.16.0 // indirect
169+
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
170+
golang.org/x/mod v0.14.0 // indirect
171+
golang.org/x/net v0.19.0 // indirect
172+
golang.org/x/oauth2 v0.15.0 // indirect
173+
golang.org/x/sync v0.5.0 // indirect
174+
golang.org/x/sys v0.15.0 // indirect
175+
golang.org/x/term v0.15.0 // indirect
176+
golang.org/x/text v0.14.0 // indirect
177+
golang.org/x/time v0.5.0 // indirect
178+
golang.org/x/tools v0.16.0 // indirect
183179
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
184180
google.golang.org/api v0.147.0 // indirect
185181
google.golang.org/appengine v1.6.8 // indirect
@@ -190,10 +186,10 @@ require (
190186
google.golang.org/protobuf v1.31.0 // indirect
191187
gopkg.in/inf.v0 v0.9.1 // indirect
192188
gopkg.in/ini.v1 v1.67.0 // indirect
193-
k8s.io/apiextensions-apiserver v0.28.3 // indirect
194-
k8s.io/component-base v0.28.3 // indirect
195-
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
196-
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
189+
k8s.io/apiextensions-apiserver v0.28.4 // indirect
190+
k8s.io/component-base v0.28.4 // indirect
191+
k8s.io/kube-openapi v0.0.0-20231129212854-f0671cc7e66a // indirect
192+
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
197193
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
198194
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
199195
sigs.k8s.io/yaml v1.4.0 // indirect

0 commit comments

Comments
 (0)