Skip to content
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

Move validation to be part of the CRD #3321

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apis/v1beta1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ type OpenTelemetryCollectorSpec struct {
// +optional
TargetAllocator TargetAllocatorEmbedded `json:"targetAllocator,omitempty"`
// Mode represents how the collector should be deployed (deployment, daemonset, statefulset or sidecar)
// +optional
// +kubebuilder:validation:Enum=ModeDeployment;ModeDaemonSet;ModeStatefulSet;ModeSidecar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific change is superfluous. If you look at the generated CRD, this validation is already there. If we look at what's missing compared to the webhook, we should add a marker here to set the default to deployment.

Keep in mind that the markers deal with raw values of the field as they appear in the resource in K8s, not the aliases we have for them in Go code. So you should use deployment instead of ModeDeployment.

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
// +optional
// +kubebuilder:validation:Enum=UpgradeStrategyAutomatic
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.
// The empty objects e.g. batch: should be written as batch: {} otherwise they won't work with kustomize or kubectl edit.
Expand All @@ -110,14 +110,17 @@ type OpenTelemetryCollectorSpec struct {
// functionality is only available if one of the valid modes is set.
// Valid modes are: deployment, daemonset and statefulset.
// +optional
// +kubebuilder:validation:Enum=ModeDeployment;ModeDaemonSet;ModeStatefulSet;
Ingress Ingress `json:"ingress,omitempty"`
// Liveness config for the OpenTelemetry Collector except the probe handler which is auto generated from the health extension of the collector.
// It is only effective when healthcheckextension is configured in the OpenTelemetry Collector pipeline.
// +optional
// +kubebuilder:validation:Required
LivenessProbe *Probe `json:"livenessProbe,omitempty"`
// Readiness config for the OpenTelemetry Collector except the probe handler which is auto generated from the health extension of the collector.
// It is only effective when healthcheckextension is configured in the OpenTelemetry Collector pipeline.
// +optional
// +kubebuilder:validation:Required
ReadinessProbe *Probe `json:"readinessProbe,omitempty"`

// ObservabilitySpec defines how telemetry data gets handled.
Expand All @@ -135,11 +138,13 @@ type OpenTelemetryCollectorSpec struct {
// https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/daemon-set-v1/#DaemonSetSpec
// This is only applicable to Daemonset mode.
// +optional
// +kubebuilder:validation:Enum=ModeDaemonset
DaemonSetUpdateStrategy appsv1.DaemonSetUpdateStrategy `json:"daemonSetUpdateStrategy,omitempty"`
// UpdateStrategy represents the strategy the operator will take replacing existing Deployment pods with new pods
// https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/#DeploymentSpec
// This is only applicable to Deployment mode.
// +optional
// +kubebuilder:validation:Enum=ModeDeployment
DeploymentUpdateStrategy appsv1.DeploymentStrategy `json:"deploymentUpdateStrategy,omitempty"`
}

Expand Down