diff --git a/apis/v1beta1/opentelemetrycollector_types.go b/apis/v1beta1/opentelemetrycollector_types.go
index dd20af943d..5cc366a10e 100644
--- a/apis/v1beta1/opentelemetrycollector_types.go
+++ b/apis/v1beta1/opentelemetrycollector_types.go
@@ -77,6 +77,8 @@ type OpenTelemetryCollectorStatus struct {
}
// OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector.
+// +kubebuilder:validation:XValidation:rule="!(self.Mode != 'statefulset' && size(self.VolumeClaimTemplates) > 0)",message="the OpenTelemetry Collector attribute 'volumeClaimTemplates' is only supported if mode is set to 'statefulset'"
+// +kubebuilder:validation:XValidation:rule="!(self.Mode != 'statefulset' && has(self.persistentVolumeClaimRetentionPolicy))",message="the OpenTelemetry Collector attribute 'persistentVolumeClaimRetentionPolicy' is only supported if mode is set to 'statefulset'"
type OpenTelemetryCollectorSpec struct {
// OpenTelemetryCommonFields are fields that are on all OpenTelemetry CRD workloads.
OpenTelemetryCommonFields `json:",inline"`
@@ -90,9 +92,11 @@ type OpenTelemetryCollectorSpec struct {
// +optional
TargetAllocator TargetAllocatorEmbedded `json:"targetAllocator,omitempty"`
// Mode represents how the collector should be deployed (deployment, daemonset, statefulset or sidecar)
+ // +kubebuilder:default:=deployment
// +optional
Mode Mode `json:"mode,omitempty"`
// UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed
+ // +kubebuilder:default:=automatic
// +optional
UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy"`
// Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details.
diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml
index 3086cedb57..4428342eee 100644
--- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml
+++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml
@@ -99,7 +99,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
- createdAt: "2024-12-19T16:56:26Z"
+ createdAt: "2024-12-30T04:31:52Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml
index 54034ecd2e..43e3206648 100644
--- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml
@@ -6943,6 +6943,7 @@ spec:
- unmanaged
type: string
mode:
+ default: deployment
enum:
- daemonset
- deployment
@@ -8247,6 +8248,7 @@ spec:
type: object
type: array
upgradeStrategy:
+ default: automatic
enum:
- automatic
- none
@@ -9261,6 +9263,14 @@ spec:
- config
- managementState
type: object
+ x-kubernetes-validations:
+ - message: the OpenTelemetry Collector attribute 'volumeClaimTemplates'
+ is only supported if mode is set to 'statefulset'
+ rule: '!(self.Mode != ''statefulset'' && size(self.VolumeClaimTemplates)
+ > 0)'
+ - message: the OpenTelemetry Collector attribute 'persistentVolumeClaimRetentionPolicy'
+ is only supported if mode is set to 'statefulset'
+ rule: '!(self.Mode != ''statefulset'' && has(self.persistentVolumeClaimRetentionPolicy))'
status:
properties:
image:
diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml
index 54034ecd2e..43e3206648 100644
--- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml
@@ -6943,6 +6943,7 @@ spec:
- unmanaged
type: string
mode:
+ default: deployment
enum:
- daemonset
- deployment
@@ -8247,6 +8248,7 @@ spec:
type: object
type: array
upgradeStrategy:
+ default: automatic
enum:
- automatic
- none
@@ -9261,6 +9263,14 @@ spec:
- config
- managementState
type: object
+ x-kubernetes-validations:
+ - message: the OpenTelemetry Collector attribute 'volumeClaimTemplates'
+ is only supported if mode is set to 'statefulset'
+ rule: '!(self.Mode != ''statefulset'' && size(self.VolumeClaimTemplates)
+ > 0)'
+ - message: the OpenTelemetry Collector attribute 'persistentVolumeClaimRetentionPolicy'
+ is only supported if mode is set to 'statefulset'
+ rule: '!(self.Mode != ''statefulset'' && has(self.persistentVolumeClaimRetentionPolicy))'
status:
properties:
image:
diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
index 9142b75a58..3a0c43f85a 100644
--- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
+++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
@@ -6929,6 +6929,7 @@ spec:
- unmanaged
type: string
mode:
+ default: deployment
enum:
- daemonset
- deployment
@@ -8233,6 +8234,7 @@ spec:
type: object
type: array
upgradeStrategy:
+ default: automatic
enum:
- automatic
- none
@@ -9247,6 +9249,14 @@ spec:
- config
- managementState
type: object
+ x-kubernetes-validations:
+ - message: the OpenTelemetry Collector attribute 'volumeClaimTemplates'
+ is only supported if mode is set to 'statefulset'
+ rule: '!(self.Mode != ''statefulset'' && size(self.VolumeClaimTemplates)
+ > 0)'
+ - message: the OpenTelemetry Collector attribute 'persistentVolumeClaimRetentionPolicy'
+ is only supported if mode is set to 'statefulset'
+ rule: '!(self.Mode != ''statefulset'' && has(self.persistentVolumeClaimRetentionPolicy))'
status:
properties:
image:
diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml
index 372a75ae43..5c5f0b84cb 100644
--- a/config/manager/kustomization.yaml
+++ b/config/manager/kustomization.yaml
@@ -1,3 +1,2 @@
resources:
- manager.yaml
-
diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml
index 173e2f7420..412267b37d 100644
--- a/config/webhook/manifests.yaml
+++ b/config/webhook/manifests.yaml
@@ -83,6 +83,26 @@ webhooks:
resources:
- pods
sideEffects: None
+- admissionReviewVersions:
+ - v1
+ clientConfig:
+ service:
+ name: webhook-service
+ namespace: system
+ path: /mutate-opentelemetry-io-v1beta1-opentelemetrycollector
+ failurePolicy: Fail
+ name: mopentelemetrycollectorbeta.kb.io
+ rules:
+ - apiGroups:
+ - opentelemetry.io
+ apiVersions:
+ - v1beta1
+ operations:
+ - CREATE
+ - UPDATE
+ resources:
+ - opentelemetrycollectors
+ sideEffects: None
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
@@ -206,3 +226,42 @@ webhooks:
resources:
- opampbridges
sideEffects: None
+- admissionReviewVersions:
+ - v1
+ clientConfig:
+ service:
+ name: webhook-service
+ namespace: system
+ path: /validate-opentelemetry-io-v1beta1-opentelemetrycollector
+ failurePolicy: Fail
+ name: vopentelemetrycollectorcreateupdatebeta.kb.io
+ rules:
+ - apiGroups:
+ - opentelemetry.io
+ apiVersions:
+ - v1beta1
+ operations:
+ - CREATE
+ - UPDATE
+ resources:
+ - opentelemetrycollectors
+ sideEffects: None
+- admissionReviewVersions:
+ - v1
+ clientConfig:
+ service:
+ name: webhook-service
+ namespace: system
+ path: /validate-opentelemetry-io-v1beta1-opentelemetrycollector
+ failurePolicy: Ignore
+ name: vopentelemetrycollectordeletebeta.kb.io
+ rules:
+ - apiGroups:
+ - opentelemetry.io
+ apiVersions:
+ - v1beta1
+ operations:
+ - DELETE
+ resources:
+ - opentelemetrycollectors
+ sideEffects: None
diff --git a/docs/api.md b/docs/api.md
index e0c219d54d..3c8a43430a 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -34462,6 +34462,7 @@ It is only effective when healthcheckextension is configured in the OpenTelemetr
Mode represents how the collector should be deployed (deployment, daemonset, statefulset or sidecar)
Enum: daemonset, deployment, sidecar, statefulset
+ Default: deployment