Skip to content

Commit 1a0a729

Browse files
swiatekmjaronoff97
andauthored
Enable controller and webhook for TargetAllocator CR (#3426)
* Enable controller and webhook for TargetAllocator CR # Conflicts: # bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml # bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml # Conflicts: # bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml # bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml * Add documentation about the TA CRD * Update controllers/targetallocator_controller.go Co-authored-by: Jacob Aronoff <[email protected]> * Apply suggestions from code review Co-authored-by: Jacob Aronoff <[email protected]> * Fix e2e test * Use TA CRD only if it's available This way we won't break installations which don't have the new CRD yet for whatever reason. --------- Co-authored-by: Jacob Aronoff <[email protected]>
1 parent 2977e64 commit 1a0a729

35 files changed

+22710
-285
lines changed

.chloggen/feat_enable-ta-crd.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: new_component
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, 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: Introduce TargetAllocator CRD
9+
10+
# One or more tracking issues related to the change
11+
issues: [2422]
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: See the [CRD changelog](./docs/crd-changelog.md) for more information.

PROJECT

+12
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,16 @@ resources:
4242
defaulting: true
4343
validation: true
4444
webhookVersion: v1
45+
- api:
46+
crdVersion: v1
47+
namespaced: true
48+
controller: true
49+
domain: opentelemetry.io
50+
kind: TargetAllocator
51+
path: github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1
52+
version: v1alpha1
53+
webhooks:
54+
defaulting: true
55+
validation: true
56+
webhookVersion: v1
4557
version: "3"

apis/v1alpha1/targetallocator_types.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ func init() {
2424
SchemeBuilder.Register(&TargetAllocator{}, &TargetAllocatorList{})
2525
}
2626

27-
//+kubebuilder:object:root=true
28-
//+kubebuilder:storageversion
29-
//+kubebuilder:subresource:status
27+
// +kubebuilder:object:root=true
28+
// +kubebuilder:subresource:status
29+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
30+
// +kubebuilder:printcolumn:name="Image",type="string",JSONPath=".status.image"
31+
// +kubebuilder:printcolumn:name="Management",type="string",JSONPath=".spec.managementState",description="Management State"
32+
// +operator-sdk:csv:customresourcedefinitions:displayName="Target Allocator"
33+
// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1},{Deployment,apps/v1},{ConfigMaps,v1},{Service,v1},{ServiceAccount,v1},{PodDisruptionBudget,policy/v1}}
3034

3135
// TargetAllocator is the Schema for the targetallocators API.
3236
type TargetAllocator struct {
@@ -37,7 +41,7 @@ type TargetAllocator struct {
3741
Status TargetAllocatorStatus `json:"status,omitempty"`
3842
}
3943

40-
//+kubebuilder:object:root=true
44+
// +kubebuilder:object:root=true
4145

4246
// TargetAllocatorList contains a list of TargetAllocator.
4347
type TargetAllocatorList struct {

apis/v1alpha1/targetallocator_webhook.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ var (
3535
_ admission.CustomDefaulter = &TargetAllocatorWebhook{}
3636
)
3737

38-
// TODO: Uncomment this webhook after enabling the TargetAllocator controller
39-
// //+kubebuilder:webhook:path=/mutate-opentelemetry-io-v1beta1-targetallocator,mutating=true,failurePolicy=fail,groups=opentelemetry.io,resources=targetallocators,verbs=create;update,versions=v1beta1,name=mtargetallocatorbeta.kb.io,sideEffects=none,admissionReviewVersions=v1
40-
// //+kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1beta1-targetallocator,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=targetallocators,versions=v1beta1,name=vtargetallocatorcreateupdatebeta.kb.io,sideEffects=none,admissionReviewVersions=v1
41-
// //+kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1beta1-targetallocator,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=targetallocators,versions=v1beta1,name=vtargetallocatordeletebeta.kb.io,sideEffects=none,admissionReviewVersions=v1
38+
// +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1beta1-targetallocator,mutating=true,failurePolicy=fail,groups=opentelemetry.io,resources=targetallocators,verbs=create;update,versions=v1beta1,name=mtargetallocatorbeta.kb.io,sideEffects=none,admissionReviewVersions=v1
39+
// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1beta1-targetallocator,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=targetallocators,versions=v1beta1,name=vtargetallocatorcreateupdatebeta.kb.io,sideEffects=none,admissionReviewVersions=v1
40+
// +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1beta1-targetallocator,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=targetallocators,versions=v1beta1,name=vtargetallocatordeletebeta.kb.io,sideEffects=none,admissionReviewVersions=v1
4241
// +kubebuilder:object:generate=false
4342

4443
type TargetAllocatorWebhook struct {

bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml

+106-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2025-01-22T10:41:17Z"
102+
createdAt: "2025-01-24T11:36:07Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
@@ -241,6 +241,52 @@ spec:
241241
displayName: Create ServiceMonitors for OpenTelemetry Collector
242242
path: targetAllocator.observability.metrics.enableMetrics
243243
version: v1beta1
244+
- description: TargetAllocator is the Schema for the targetallocators API.
245+
displayName: Target Allocator
246+
kind: TargetAllocator
247+
name: targetallocators.opentelemetry.io
248+
resources:
249+
- kind: ConfigMaps
250+
name: ""
251+
version: v1
252+
- kind: Deployment
253+
name: ""
254+
version: apps/v1
255+
- kind: Pod
256+
name: ""
257+
version: v1
258+
- kind: PodDisruptionBudget
259+
name: ""
260+
version: policy/v1
261+
- kind: Service
262+
name: ""
263+
version: v1
264+
- kind: ServiceAccount
265+
name: ""
266+
version: v1
267+
specDescriptors:
268+
- description: ObservabilitySpec defines how telemetry data gets handled.
269+
displayName: Observability
270+
path: observability
271+
- description: Metrics defines the metrics configuration for operands.
272+
displayName: Metrics Config
273+
path: observability.metrics
274+
- description: Metrics defines the metrics configuration for operands.
275+
displayName: Metrics Config
276+
path: observability.metrics
277+
- description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar
278+
mode) should be created for the service managed by the OpenTelemetry Operator.
279+
The operator.observability.prometheus feature gate must be enabled to use
280+
this feature.
281+
displayName: Create ServiceMonitors for OpenTelemetry Collector
282+
path: observability.metrics.enableMetrics
283+
- description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar
284+
mode) should be created for the service managed by the OpenTelemetry Operator.
285+
The operator.observability.prometheus feature gate must be enabled to use
286+
this feature.
287+
displayName: Create ServiceMonitors for OpenTelemetry Collector
288+
path: observability.metrics.enableMetrics
289+
version: v1alpha1
244290
description: |-
245291
OpenTelemetry is a collection of tools, APIs, and SDKs. You use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.
246292
@@ -684,6 +730,26 @@ spec:
684730
targetPort: 9443
685731
type: MutatingAdmissionWebhook
686732
webhookPath: /mutate-v1-pod
733+
- admissionReviewVersions:
734+
- v1
735+
containerPort: 443
736+
deploymentName: opentelemetry-operator-controller-manager
737+
failurePolicy: Fail
738+
generateName: mtargetallocatorbeta.kb.io
739+
rules:
740+
- apiGroups:
741+
- opentelemetry.io
742+
apiVersions:
743+
- v1beta1
744+
operations:
745+
- CREATE
746+
- UPDATE
747+
resources:
748+
- targetallocators
749+
sideEffects: None
750+
targetPort: 9443
751+
type: MutatingAdmissionWebhook
752+
webhookPath: /mutate-opentelemetry-io-v1beta1-targetallocator
687753
- admissionReviewVersions:
688754
- v1
689755
containerPort: 443
@@ -801,3 +867,42 @@ spec:
801867
targetPort: 9443
802868
type: ValidatingAdmissionWebhook
803869
webhookPath: /validate-opentelemetry-io-v1beta1-opentelemetrycollector
870+
- admissionReviewVersions:
871+
- v1
872+
containerPort: 443
873+
deploymentName: opentelemetry-operator-controller-manager
874+
failurePolicy: Fail
875+
generateName: vtargetallocatorcreateupdatebeta.kb.io
876+
rules:
877+
- apiGroups:
878+
- opentelemetry.io
879+
apiVersions:
880+
- v1beta1
881+
operations:
882+
- CREATE
883+
- UPDATE
884+
resources:
885+
- targetallocators
886+
sideEffects: None
887+
targetPort: 9443
888+
type: ValidatingAdmissionWebhook
889+
webhookPath: /validate-opentelemetry-io-v1beta1-targetallocator
890+
- admissionReviewVersions:
891+
- v1
892+
containerPort: 443
893+
deploymentName: opentelemetry-operator-controller-manager
894+
failurePolicy: Ignore
895+
generateName: vtargetallocatordeletebeta.kb.io
896+
rules:
897+
- apiGroups:
898+
- opentelemetry.io
899+
apiVersions:
900+
- v1beta1
901+
operations:
902+
- DELETE
903+
resources:
904+
- targetallocators
905+
sideEffects: None
906+
targetPort: 9443
907+
type: ValidatingAdmissionWebhook
908+
webhookPath: /validate-opentelemetry-io-v1beta1-targetallocator

0 commit comments

Comments
 (0)