From 4cefa04e1b471ecc79fd57cba471fccfb284477c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?=
 <mail+sumo@mikolajswiatek.com>
Date: Tue, 16 Apr 2024 11:14:53 +0200
Subject: [PATCH] Add missing per-node strategy to TA CRD

---
 apis/v1beta1/allocation_strategy.go                          | 5 ++++-
 .../manifests/opentelemetry.io_opentelemetrycollectors.yaml  | 1 +
 .../crd/bases/opentelemetry.io_opentelemetrycollectors.yaml  | 1 +
 config/crd/bases/opentelemetry.io_targetallocators.yaml      | 1 +
 docs/api.md                                                  | 2 +-
 5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/apis/v1beta1/allocation_strategy.go b/apis/v1beta1/allocation_strategy.go
index b66c4f2cfe..1cbc90c19d 100644
--- a/apis/v1beta1/allocation_strategy.go
+++ b/apis/v1beta1/allocation_strategy.go
@@ -16,7 +16,7 @@ package v1beta1
 
 type (
 	// TargetAllocatorAllocationStrategy represent a strategy Target Allocator uses to distribute targets to each collector
-	// +kubebuilder:validation:Enum=least-weighted;consistent-hashing
+	// +kubebuilder:validation:Enum=least-weighted;consistent-hashing;per-node
 	TargetAllocatorAllocationStrategy string
 	// TargetAllocatorFilterStrategy represent a filtering strategy for targets before they are assigned to collectors
 	// +kubebuilder:validation:Enum="";relabel-config
@@ -30,6 +30,9 @@ const (
 	// TargetAllocatorAllocationStrategyConsistentHashing targets will be consistently added to collectors, which allows a high-availability setup.
 	TargetAllocatorAllocationStrategyConsistentHashing TargetAllocatorAllocationStrategy = "consistent-hashing"
 
+	// TargetAllocatorAllocationStrategyPerNode targets will be assigned to the collector on the node they reside on (use only with daemon set).
+	TargetAllocatorAllocationStrategyPerNode TargetAllocatorAllocationStrategy = "per-node"
+
 	// TargetAllocatorFilterStrategyRelabelConfig targets will be consistently drops targets based on the relabel_config.
 	TargetAllocatorFilterStrategyRelabelConfig TargetAllocatorFilterStrategy = "relabel-config"
 )
diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
index 8a8773c852..9facf2f1aa 100644
--- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
@@ -7146,6 +7146,7 @@ spec:
                     enum:
                     - least-weighted
                     - consistent-hashing
+                    - per-node
                     type: string
                   enabled:
                     type: boolean
diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
index 1241162ae0..b17a8dede1 100644
--- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
@@ -7132,6 +7132,7 @@ spec:
                     enum:
                     - least-weighted
                     - consistent-hashing
+                    - per-node
                     type: string
                   enabled:
                     type: boolean
diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml
index 08e015d8bd..1504510fba 100644
--- a/config/crd/bases/opentelemetry.io_targetallocators.yaml
+++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml
@@ -1072,6 +1072,7 @@ spec:
                 enum:
                 - least-weighted
                 - consistent-hashing
+                - per-node
                 type: string
               args:
                 additionalProperties:
diff --git a/docs/api.md b/docs/api.md
index 842764eab1..8235f45406 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -40460,7 +40460,7 @@ The current options are least-weighted, consistent-hashing and per-node. The def
 consistent-hashing.
 WARNING: The per-node strategy currently ignores targets without a Node, like control plane components.<br/>
           <br/>
-            <i>Enum</i>: least-weighted, consistent-hashing<br/>
+            <i>Enum</i>: least-weighted, consistent-hashing, per-node<br/>
             <i>Default</i>: consistent-hashing<br/>
         </td>
         <td>false</td>