diff --git a/apis/v1alpha2/allocation_strategy.go b/apis/v1beta1/allocation_strategy.go similarity index 99% rename from apis/v1alpha2/allocation_strategy.go rename to apis/v1beta1/allocation_strategy.go index 9b710920de..b66c4f2cfe 100644 --- a/apis/v1alpha2/allocation_strategy.go +++ b/apis/v1beta1/allocation_strategy.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 type ( // TargetAllocatorAllocationStrategy represent a strategy Target Allocator uses to distribute targets to each collector diff --git a/apis/v1alpha2/collector_webhook.go b/apis/v1beta1/collector_webhook.go similarity index 99% rename from apis/v1alpha2/collector_webhook.go rename to apis/v1beta1/collector_webhook.go index 8bdf145fa0..67082a02cd 100644 --- a/apis/v1alpha2/collector_webhook.go +++ b/apis/v1beta1/collector_webhook.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 import ( "context" diff --git a/apis/v1alpha2/collector_webhook_test.go b/apis/v1beta1/collector_webhook_test.go similarity index 99% rename from apis/v1alpha2/collector_webhook_test.go rename to apis/v1beta1/collector_webhook_test.go index b6f9210745..9b7647cca5 100644 --- a/apis/v1alpha2/collector_webhook_test.go +++ b/apis/v1beta1/collector_webhook_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 import ( "testing" diff --git a/apis/v1alpha2/common.go b/apis/v1beta1/common.go similarity index 99% rename from apis/v1alpha2/common.go rename to apis/v1beta1/common.go index 209ade803b..2c7531b92d 100644 --- a/apis/v1alpha2/common.go +++ b/apis/v1beta1/common.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 import ( autoscalingv2 "k8s.io/api/autoscaling/v2" diff --git a/apis/v1alpha2/config.go b/apis/v1beta1/config.go similarity index 99% rename from apis/v1alpha2/config.go rename to apis/v1beta1/config.go index b437ac3f7f..a34a8cacfd 100644 --- a/apis/v1alpha2/config.go +++ b/apis/v1beta1/config.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 import ( "bytes" diff --git a/apis/v1alpha2/config_test.go b/apis/v1beta1/config_test.go similarity index 99% rename from apis/v1alpha2/config_test.go rename to apis/v1beta1/config_test.go index a8ebd29b4c..ac067f9ea1 100644 --- a/apis/v1alpha2/config_test.go +++ b/apis/v1beta1/config_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 import ( "encoding/json" diff --git a/apis/v1alpha2/groupversion_info.go b/apis/v1beta1/groupversion_info.go similarity index 90% rename from apis/v1alpha2/groupversion_info.go rename to apis/v1beta1/groupversion_info.go index 4a5c2ac8c6..2995664a09 100644 --- a/apis/v1alpha2/groupversion_info.go +++ b/apis/v1beta1/groupversion_info.go @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package v1alpha2 contains API Schema definitions for the v1alpha2 API group +// Package v1beta1 contains API Schema definitions for the v1beta1 API group // +kubebuilder:object:generate=true // +groupName=opentelemetry.io -package v1alpha2 +package v1beta1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -24,7 +24,7 @@ import ( var ( // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1alpha2"} + GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme. SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/apis/v1alpha2/ingress_type.go b/apis/v1beta1/ingress_type.go similarity index 99% rename from apis/v1alpha2/ingress_type.go rename to apis/v1beta1/ingress_type.go index 8808d09339..7d248a30d2 100644 --- a/apis/v1alpha2/ingress_type.go +++ b/apis/v1beta1/ingress_type.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 type ( // IngressType represents how a collector should be exposed (ingress vs route). diff --git a/apis/v1alpha2/mode.go b/apis/v1beta1/mode.go similarity index 98% rename from apis/v1alpha2/mode.go rename to apis/v1beta1/mode.go index 8cd8a46cf8..68d661c24d 100644 --- a/apis/v1alpha2/mode.go +++ b/apis/v1beta1/mode.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 type ( // Mode represents how the collector should be deployed (deployment vs. daemonset) diff --git a/apis/v1alpha2/opentelemetrycollector_types.go b/apis/v1beta1/opentelemetrycollector_types.go similarity index 99% rename from apis/v1alpha2/opentelemetrycollector_types.go rename to apis/v1beta1/opentelemetrycollector_types.go index 3521afcdaf..c93cc7af34 100644 --- a/apis/v1alpha2/opentelemetrycollector_types.go +++ b/apis/v1beta1/opentelemetrycollector_types.go @@ -14,7 +14,7 @@ // +kubebuilder:skip -package v1alpha2 +package v1beta1 import ( appsv1 "k8s.io/api/apps/v1" diff --git a/apis/v1alpha2/targetallocator_types.go b/apis/v1beta1/targetallocator_types.go similarity index 99% rename from apis/v1alpha2/targetallocator_types.go rename to apis/v1beta1/targetallocator_types.go index 74885ca1f7..05e06f7c23 100644 --- a/apis/v1alpha2/targetallocator_types.go +++ b/apis/v1beta1/targetallocator_types.go @@ -14,7 +14,7 @@ // +kubebuilder:skip -package v1alpha2 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/apis/v1alpha2/testdata/otelcol-connectors.yaml b/apis/v1beta1/testdata/otelcol-connectors.yaml similarity index 100% rename from apis/v1alpha2/testdata/otelcol-connectors.yaml rename to apis/v1beta1/testdata/otelcol-connectors.yaml diff --git a/apis/v1alpha2/testdata/otelcol-couchbase.yaml b/apis/v1beta1/testdata/otelcol-couchbase.yaml similarity index 100% rename from apis/v1alpha2/testdata/otelcol-couchbase.yaml rename to apis/v1beta1/testdata/otelcol-couchbase.yaml diff --git a/apis/v1alpha2/testdata/otelcol-demo.yaml b/apis/v1beta1/testdata/otelcol-demo.yaml similarity index 100% rename from apis/v1alpha2/testdata/otelcol-demo.yaml rename to apis/v1beta1/testdata/otelcol-demo.yaml diff --git a/apis/v1alpha2/testdata/otelcol-extensions.yaml b/apis/v1beta1/testdata/otelcol-extensions.yaml similarity index 100% rename from apis/v1alpha2/testdata/otelcol-extensions.yaml rename to apis/v1beta1/testdata/otelcol-extensions.yaml diff --git a/apis/v1alpha2/testdata/otelcol-filelog.yaml b/apis/v1beta1/testdata/otelcol-filelog.yaml similarity index 100% rename from apis/v1alpha2/testdata/otelcol-filelog.yaml rename to apis/v1beta1/testdata/otelcol-filelog.yaml diff --git a/apis/v1alpha2/testdata/otelcol-null-values.yaml b/apis/v1beta1/testdata/otelcol-null-values.yaml similarity index 100% rename from apis/v1alpha2/testdata/otelcol-null-values.yaml rename to apis/v1beta1/testdata/otelcol-null-values.yaml diff --git a/apis/v1alpha2/upgrade_strategy.go b/apis/v1beta1/upgrade_strategy.go similarity index 98% rename from apis/v1alpha2/upgrade_strategy.go rename to apis/v1beta1/upgrade_strategy.go index 5f26b4b3db..25ccc7eff0 100644 --- a/apis/v1alpha2/upgrade_strategy.go +++ b/apis/v1beta1/upgrade_strategy.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha2 +package v1beta1 type ( // UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go similarity index 99% rename from apis/v1alpha2/zz_generated.deepcopy.go rename to apis/v1beta1/zz_generated.deepcopy.go index c36fd46d2d..f6b298811f 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -17,7 +17,7 @@ // Code generated by controller-gen. DO NOT EDIT. -package v1alpha2 +package v1beta1 import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" diff --git a/controllers/builder_test.go b/controllers/builder_test.go index 7b69e16962..8dd0bcfa21 100644 --- a/controllers/builder_test.go +++ b/controllers/builder_test.go @@ -34,7 +34,7 @@ import ( colfeaturegate "go.opentelemetry.io/collector/featuregate" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" @@ -87,12 +87,12 @@ service: exporters: [logging] ` - goodConfig := v1alpha2.Config{} + goodConfig := v1beta1.Config{} err := go_yaml.Unmarshal([]byte(goodConfigYaml), &goodConfig) require.NoError(t, err) one := int32(1) type args struct { - instance v1alpha2.OpenTelemetryCollector + instance v1beta1.OpenTelemetryCollector } tests := []struct { name string @@ -103,13 +103,13 @@ service: { name: "base case", args: args{ - instance: v1alpha2.OpenTelemetryCollector{ + instance: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "test", Replicas: &one, }, @@ -342,19 +342,19 @@ service: { name: "ingress", args: args{ - instance: v1alpha2.OpenTelemetryCollector{ + instance: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "test", Replicas: &one, }, Mode: "deployment", - Ingress: v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeNginx, + Ingress: v1beta1.Ingress{ + Type: v1beta1.IngressTypeNginx, Hostname: "example.com", Annotations: map[string]string{ "something": "true", @@ -627,13 +627,13 @@ service: { name: "specified service account case", args: args{ - instance: v1alpha2.OpenTelemetryCollector{ + instance: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "test", Replicas: &one, ServiceAccount: "my-special-sa", @@ -1121,12 +1121,12 @@ service: exporters: [logging] ` - goodConfig := v1alpha2.Config{} + goodConfig := v1beta1.Config{} err := go_yaml.Unmarshal([]byte(goodConfigYaml), &goodConfig) require.NoError(t, err) one := int32(1) type args struct { - instance v1alpha2.OpenTelemetryCollector + instance v1beta1.OpenTelemetryCollector } tests := []struct { name string @@ -1138,22 +1138,22 @@ service: { name: "base case", args: args{ - instance: v1alpha2.OpenTelemetryCollector{ + instance: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "test", Replicas: &one, }, Mode: "statefulset", Config: goodConfig, - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, FilterStrategy: "relabel-config", - PrometheusCR: v1alpha2.TargetAllocatorPrometheusCR{ + PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ Enabled: true, }, }, @@ -1530,21 +1530,21 @@ prometheus_cr: { name: "enable metrics case", args: args{ - instance: v1alpha2.OpenTelemetryCollector{ + instance: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "test", Namespace: "test", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "test", Replicas: &one, }, Mode: "statefulset", Config: goodConfig, - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, - PrometheusCR: v1alpha2.TargetAllocatorPrometheusCR{ + PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ Enabled: true, }, FilterStrategy: "relabel-config", diff --git a/internal/api/convert/v1alpha.go b/internal/api/convert/v1alpha.go index 4c5331086b..53e37ebd7e 100644 --- a/internal/api/convert/v1alpha.go +++ b/internal/api/convert/v1alpha.go @@ -21,37 +21,37 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) -func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryCollector, error) { +func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error) { copy := in.DeepCopy() - out := v1alpha2.OpenTelemetryCollector{ + out := v1beta1.OpenTelemetryCollector{ TypeMeta: copy.TypeMeta, ObjectMeta: copy.ObjectMeta, } - cfg := &v1alpha2.Config{} + cfg := &v1beta1.Config{} if err := yaml.Unmarshal([]byte(in.Spec.Config), cfg); err != nil { - return v1alpha2.OpenTelemetryCollector{}, errors.New("could not convert config json to v1alpha2.Config") + return v1beta1.OpenTelemetryCollector{}, errors.New("could not convert config json to v1beta1.Config") } out.Spec.Config = *cfg - out.Spec.OpenTelemetryCommonFields.ManagementState = v1alpha2.ManagementStateType(copy.Spec.ManagementState) + out.Spec.OpenTelemetryCommonFields.ManagementState = v1beta1.ManagementStateType(copy.Spec.ManagementState) out.Spec.OpenTelemetryCommonFields.Resources = copy.Spec.Resources out.Spec.OpenTelemetryCommonFields.NodeSelector = copy.Spec.NodeSelector out.Spec.OpenTelemetryCommonFields.Args = copy.Spec.NodeSelector out.Spec.OpenTelemetryCommonFields.Replicas = copy.Spec.Replicas if copy.Spec.Autoscaler != nil { - metrics := make([]v1alpha2.MetricSpec, len(copy.Spec.Autoscaler.Metrics)) + metrics := make([]v1beta1.MetricSpec, len(copy.Spec.Autoscaler.Metrics)) for i, m := range copy.Spec.Autoscaler.Metrics { - metrics[i] = v1alpha2.MetricSpec{ + metrics[i] = v1beta1.MetricSpec{ Type: m.Type, Pods: m.Pods, } } - out.Spec.OpenTelemetryCommonFields.Autoscaler = &v1alpha2.AutoscalerSpec{ + out.Spec.OpenTelemetryCommonFields.Autoscaler = &v1beta1.AutoscalerSpec{ MinReplicas: copy.Spec.Autoscaler.MinReplicas, MaxReplicas: copy.Spec.Autoscaler.MaxReplicas, Behavior: copy.Spec.Autoscaler.Behavior, @@ -62,7 +62,7 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryColl } if copy.Spec.PodDisruptionBudget != nil { - out.Spec.OpenTelemetryCommonFields.PodDisruptionBudget = &v1alpha2.PodDisruptionBudgetSpec{ + out.Spec.OpenTelemetryCommonFields.PodDisruptionBudget = &v1beta1.PodDisruptionBudgetSpec{ MinAvailable: copy.Spec.PodDisruptionBudget.MinAvailable, MaxUnavailable: copy.Spec.PodDisruptionBudget.MaxUnavailable, } @@ -96,18 +96,18 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryColl out.Spec.TargetAllocator = TargetAllocatorEmbedded(copy.Spec.TargetAllocator) - out.Spec.Mode = v1alpha2.Mode(copy.Spec.Mode) - out.Spec.UpgradeStrategy = v1alpha2.UpgradeStrategy(copy.Spec.UpgradeStrategy) - out.Spec.Ingress.Type = v1alpha2.IngressType(copy.Spec.Ingress.Type) - out.Spec.Ingress.RuleType = v1alpha2.IngressRuleType(copy.Spec.Ingress.RuleType) + out.Spec.Mode = v1beta1.Mode(copy.Spec.Mode) + out.Spec.UpgradeStrategy = v1beta1.UpgradeStrategy(copy.Spec.UpgradeStrategy) + out.Spec.Ingress.Type = v1beta1.IngressType(copy.Spec.Ingress.Type) + out.Spec.Ingress.RuleType = v1beta1.IngressRuleType(copy.Spec.Ingress.RuleType) out.Spec.Ingress.Hostname = copy.Spec.Ingress.Hostname out.Spec.Ingress.Annotations = copy.Spec.Ingress.Annotations out.Spec.Ingress.TLS = copy.Spec.Ingress.TLS out.Spec.Ingress.IngressClassName = copy.Spec.Ingress.IngressClassName - out.Spec.Ingress.Route.Termination = v1alpha2.TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination) + out.Spec.Ingress.Route.Termination = v1beta1.TLSRouteTerminationType(copy.Spec.Ingress.Route.Termination) if copy.Spec.LivenessProbe != nil { - out.Spec.LivenessProbe = &v1alpha2.Probe{ + out.Spec.LivenessProbe = &v1beta1.Probe{ InitialDelaySeconds: copy.Spec.LivenessProbe.InitialDelaySeconds, TimeoutSeconds: copy.Spec.LivenessProbe.TimeoutSeconds, PeriodSeconds: copy.Spec.LivenessProbe.PeriodSeconds, @@ -127,13 +127,13 @@ func V1Alpha1to2(in v1alpha1.OpenTelemetryCollector) (v1alpha2.OpenTelemetryColl return out, nil } -func TargetAllocatorEmbedded(in v1alpha1.OpenTelemetryTargetAllocator) v1alpha2.TargetAllocatorEmbedded { - out := v1alpha2.TargetAllocatorEmbedded{} +func TargetAllocatorEmbedded(in v1alpha1.OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedded { + out := v1beta1.TargetAllocatorEmbedded{} out.Replicas = in.Replicas out.NodeSelector = in.NodeSelector out.Resources = in.Resources - out.AllocationStrategy = v1alpha2.TargetAllocatorAllocationStrategy(in.AllocationStrategy) - out.FilterStrategy = v1alpha2.TargetAllocatorFilterStrategy(in.FilterStrategy) + out.AllocationStrategy = v1beta1.TargetAllocatorAllocationStrategy(in.AllocationStrategy) + out.FilterStrategy = v1beta1.TargetAllocatorFilterStrategy(in.FilterStrategy) out.ServiceAccount = in.ServiceAccount out.Image = in.Image out.Enabled = in.Enabled @@ -158,7 +158,7 @@ func TargetAllocatorEmbedded(in v1alpha1.OpenTelemetryTargetAllocator) v1alpha2. MatchLabels: in.PrometheusCR.ServiceMonitorSelector, } if in.PodDisruptionBudget != nil { - out.PodDisruptionBudget = &v1alpha2.PodDisruptionBudgetSpec{ + out.PodDisruptionBudget = &v1beta1.PodDisruptionBudgetSpec{ MinAvailable: in.PodDisruptionBudget.MinAvailable, MaxUnavailable: in.PodDisruptionBudget.MaxUnavailable, } diff --git a/internal/api/convert/v1alpha_test.go b/internal/api/convert/v1alpha_test.go index 3d7f959336..0859cb5a48 100644 --- a/internal/api/convert/v1alpha_test.go +++ b/internal/api/convert/v1alpha_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) func Test_V1Alpha1to2(t *testing.T) { @@ -72,7 +72,7 @@ service: } _, err := V1Alpha1to2(cfgV1) - assert.ErrorContains(t, err, "could not convert config json to v1alpha2.Config") + assert.ErrorContains(t, err, "could not convert config json to v1beta1.Config") }) } @@ -174,17 +174,17 @@ func Test_TargetAllocator(t *testing.T) { }, } - expected := v1alpha2.TargetAllocatorEmbedded{ + expected := v1beta1.TargetAllocatorEmbedded{ Replicas: input.Replicas, NodeSelector: input.NodeSelector, Resources: input.Resources, - AllocationStrategy: v1alpha2.TargetAllocatorAllocationStrategyConsistentHashing, - FilterStrategy: v1alpha2.TargetAllocatorFilterStrategyRelabelConfig, + AllocationStrategy: v1beta1.TargetAllocatorAllocationStrategyConsistentHashing, + FilterStrategy: v1beta1.TargetAllocatorFilterStrategyRelabelConfig, ServiceAccount: input.ServiceAccount, Image: input.Image, Enabled: input.Enabled, Affinity: input.Affinity, - PrometheusCR: v1alpha2.TargetAllocatorPrometheusCR{ + PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ Enabled: input.PrometheusCR.Enabled, ScrapeInterval: input.PrometheusCR.ScrapeInterval, PodMonitorSelector: &metav1.LabelSelector{ @@ -200,7 +200,7 @@ func Test_TargetAllocator(t *testing.T) { Tolerations: input.Tolerations, Env: input.Env, Observability: input.Observability, - PodDisruptionBudget: &v1alpha2.PodDisruptionBudgetSpec{ + PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{ MinAvailable: input.PodDisruptionBudget.MinAvailable, MaxUnavailable: input.PodDisruptionBudget.MaxUnavailable, }, diff --git a/internal/manifests/collector/annotations.go b/internal/manifests/collector/annotations.go index 32201ea412..5f4c7c41be 100644 --- a/internal/manifests/collector/annotations.go +++ b/internal/manifests/collector/annotations.go @@ -19,11 +19,11 @@ import ( "encoding/json" "fmt" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) // Annotations return the annotations for OpenTelemetryCollector pod. -func Annotations(instance v1alpha2.OpenTelemetryCollector) (map[string]string, error) { +func Annotations(instance v1beta1.OpenTelemetryCollector) (map[string]string, error) { // new map every time, so that we don't touch the instance's annotations annotations := map[string]string{} @@ -54,7 +54,7 @@ func Annotations(instance v1alpha2.OpenTelemetryCollector) (map[string]string, e } // PodAnnotations return the spec annotations for OpenTelemetryCollector pod. -func PodAnnotations(instance v1alpha2.OpenTelemetryCollector) (map[string]string, error) { +func PodAnnotations(instance v1beta1.OpenTelemetryCollector) (map[string]string, error) { // new map every time, so that we don't touch the instance's annotations podAnnotations := map[string]string{} @@ -84,7 +84,7 @@ func PodAnnotations(instance v1alpha2.OpenTelemetryCollector) (map[string]string return podAnnotations, nil } -func getConfigMapSHA(config v1alpha2.Config) (string, error) { +func getConfigMapSHA(config v1beta1.Config) (string, error) { b, err := json.Marshal(&config) if err != nil { return "", err diff --git a/internal/manifests/collector/annotations_test.go b/internal/manifests/collector/annotations_test.go index 9119bbda0a..ec773f195a 100644 --- a/internal/manifests/collector/annotations_test.go +++ b/internal/manifests/collector/annotations_test.go @@ -22,19 +22,19 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) func TestDefaultAnnotations(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-ns", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - Config: v1alpha2.Config{ - Service: v1alpha2.Service{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ Extensions: func() *[]string { res := []string{"test"} return &res @@ -64,12 +64,12 @@ func TestDefaultAnnotations(t *testing.T) { func TestNonDefaultPodAnnotation(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-ns", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Observability: v1alpha1.ObservabilitySpec{ Metrics: v1alpha1.MetricsConfigSpec{ DisablePrometheusAnnotations: true, @@ -98,7 +98,7 @@ func TestNonDefaultPodAnnotation(t *testing.T) { func TestUserAnnotations(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-ns", @@ -108,9 +108,9 @@ func TestUserAnnotations(t *testing.T) { "opentelemetry-operator-config/sha256": "shouldBeOverwritten", }, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - Config: v1alpha2.Config{ - Service: v1alpha2.Service{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{ + Service: v1beta1.Service{ Extensions: func() *[]string { res := []string{"test2"} return &res @@ -136,12 +136,12 @@ func TestUserAnnotations(t *testing.T) { func TestAnnotationsPropagateDown(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{"myapp": "mycomponent"}, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodAnnotations: map[string]string{"pod_annotation": "pod_annotation_value"}, }, }, diff --git a/internal/manifests/collector/collector.go b/internal/manifests/collector/collector.go index e673b168aa..3b984d6918 100644 --- a/internal/manifests/collector/collector.go +++ b/internal/manifests/collector/collector.go @@ -17,7 +17,7 @@ package collector import ( "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -31,15 +31,15 @@ func Build(params manifests.Params) ([]client.Object, error) { var resourceManifests []client.Object var manifestFactories []manifests.K8sManifestFactory switch params.OtelCol.Spec.Mode { - case v1alpha2.ModeDeployment: + case v1beta1.ModeDeployment: manifestFactories = append(manifestFactories, manifests.Factory(Deployment)) manifestFactories = append(manifestFactories, manifests.Factory(PodDisruptionBudget)) - case v1alpha2.ModeStatefulSet: + case v1beta1.ModeStatefulSet: manifestFactories = append(manifestFactories, manifests.Factory(StatefulSet)) manifestFactories = append(manifestFactories, manifests.Factory(PodDisruptionBudget)) - case v1alpha2.ModeDaemonSet: + case v1beta1.ModeDaemonSet: manifestFactories = append(manifestFactories, manifests.Factory(DaemonSet)) - case v1alpha2.ModeSidecar: + case v1beta1.ModeSidecar: params.Log.V(5).Info("not building sidecar...") } manifestFactories = append(manifestFactories, []manifests.K8sManifestFactory{ @@ -53,7 +53,7 @@ func Build(params manifests.Params) ([]client.Object, error) { }...) if params.OtelCol.Spec.Observability.Metrics.EnableMetrics && featuregate.PrometheusOperatorIsAvailable.IsEnabled() { - if params.OtelCol.Spec.Mode == v1alpha2.ModeSidecar { + if params.OtelCol.Spec.Mode == v1beta1.ModeSidecar { manifestFactories = append(manifestFactories, manifests.Factory(PodMonitor)) } else { manifestFactories = append(manifestFactories, manifests.Factory(ServiceMonitor)) diff --git a/internal/manifests/collector/config_replace.go b/internal/manifests/collector/config_replace.go index 79c636b483..ddeeec172a 100644 --- a/internal/manifests/collector/config_replace.go +++ b/internal/manifests/collector/config_replace.go @@ -21,7 +21,7 @@ import ( _ "github.com/prometheus/prometheus/discovery/install" // Package install has the side-effect of registering all builtin. "gopkg.in/yaml.v3" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" ta "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -42,7 +42,7 @@ type Config struct { TargetAllocConfig *targetAllocator `yaml:"target_allocator,omitempty"` } -func ReplaceConfig(instance v1alpha2.OpenTelemetryCollector) (string, error) { +func ReplaceConfig(instance v1beta1.OpenTelemetryCollector) (string, error) { cfgStr, err := instance.Spec.Config.Yaml() if err != nil { return "", err diff --git a/internal/manifests/collector/container.go b/internal/manifests/collector/container.go index 00f6e2ee2b..d6603a98d2 100644 --- a/internal/manifests/collector/container.go +++ b/internal/manifests/collector/container.go @@ -25,7 +25,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/validation" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -36,7 +36,7 @@ import ( const maxPortLen = 15 // Container builds a container for the given collector. -func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha2.OpenTelemetryCollector, addConfig bool) corev1.Container { +func Container(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTelemetryCollector, addConfig bool) corev1.Container { image := otelcol.Spec.Image if len(image) == 0 { image = cfg.CollectorImage() @@ -226,7 +226,7 @@ func portMapToList(portMap map[string]corev1.ContainerPort) []corev1.ContainerPo return ports } -func getLivenessProbe(config map[interface{}]interface{}, probeConfig *v1alpha2.Probe) (*corev1.Probe, error) { +func getLivenessProbe(config map[interface{}]interface{}, probeConfig *v1beta1.Probe) (*corev1.Probe, error) { probe, err := adapters.ConfigToContainerProbe(config) if err != nil { return nil, err diff --git a/internal/manifests/collector/container_test.go b/internal/manifests/collector/container_test.go index 6536d81f2b..de80f962c2 100644 --- a/internal/manifests/collector/container_test.go +++ b/internal/manifests/collector/container_test.go @@ -26,7 +26,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" ) @@ -53,9 +53,9 @@ func TestContainerNewDefault(t *testing.T) { metrics: receivers: [otlp] exporters: [debug]` - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Ports: []corev1.ServicePort{ { Name: "metrics", @@ -79,9 +79,9 @@ func TestContainerNewDefault(t *testing.T) { func TestContainerWithImageOverridden(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "overridden-image", }, }, @@ -350,10 +350,10 @@ service: for _, testCase := range tests { t.Run(testCase.description, func(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Config: mustUnmarshalToConfig(t, testCase.specConfig), - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Ports: testCase.specPorts, }, }, @@ -371,9 +371,9 @@ service: func TestContainerConfigFlagIsIgnored(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Args: map[string]string{ "key": "value", "config": "/some-custom-file.yaml", @@ -394,9 +394,9 @@ func TestContainerConfigFlagIsIgnored(t *testing.T) { func TestContainerCustomVolumes(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ VolumeMounts: []corev1.VolumeMount{{ Name: "custom-volume-mount", }}, @@ -415,8 +415,8 @@ func TestContainerCustomVolumes(t *testing.T) { func TestContainerCustomConfigMapsVolumes(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ ConfigMaps: []v1alpha1.ConfigMapsSpec{{ Name: "test", MountPath: "/", @@ -441,7 +441,7 @@ func TestContainerCustomConfigMapsVolumes(t *testing.T) { func TestContainerCustomSecurityContext(t *testing.T) { // default config without security context - c1 := Container(config.New(), logger, v1alpha2.OpenTelemetryCollector{Spec: v1alpha2.OpenTelemetryCollectorSpec{}}, true) + c1 := Container(config.New(), logger, v1beta1.OpenTelemetryCollector{Spec: v1beta1.OpenTelemetryCollectorSpec{}}, true) // verify assert.Nil(t, c1.SecurityContext) @@ -451,9 +451,9 @@ func TestContainerCustomSecurityContext(t *testing.T) { uid := int64(1234) // test - c2 := Container(config.New(), logger, v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + c2 := Container(config.New(), logger, v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ SecurityContext: &corev1.SecurityContext{ Privileged: &isPrivileged, @@ -470,9 +470,9 @@ func TestContainerCustomSecurityContext(t *testing.T) { } func TestContainerEnvVarsOverridden(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Env: []corev1.EnvVar{ { Name: "foo", @@ -495,8 +495,8 @@ func TestContainerEnvVarsOverridden(t *testing.T) { } func TestContainerDefaultEnvVars(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{}, } cfg := config.New() @@ -513,8 +513,8 @@ func TestContainerProxyEnvVars(t *testing.T) { err := os.Setenv("NO_PROXY", "localhost") require.NoError(t, err) defer os.Unsetenv("NO_PROXY") - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{}, } cfg := config.New() @@ -530,9 +530,9 @@ func TestContainerProxyEnvVars(t *testing.T) { } func TestContainerResourceRequirements(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Resources: corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("100m"), @@ -560,8 +560,8 @@ func TestContainerResourceRequirements(t *testing.T) { } func TestContainerDefaultResourceRequirements(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{}, } cfg := config.New() @@ -575,9 +575,9 @@ func TestContainerDefaultResourceRequirements(t *testing.T) { func TestContainerArgs(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Args: map[string]string{ "metrics-level": "detailed", "log-level": "debug", @@ -597,9 +597,9 @@ func TestContainerArgs(t *testing.T) { func TestContainerOrderedArgs(t *testing.T) { // prepare a scenario where the debug level and a feature gate has been enabled - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Args: map[string]string{ "log-level": "debug", "feature-gates": "+random-feature", @@ -621,9 +621,9 @@ func TestContainerOrderedArgs(t *testing.T) { func TestContainerImagePullPolicy(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ ImagePullPolicy: corev1.PullIfNotPresent, }, }, @@ -653,9 +653,9 @@ func TestContainerEnvFrom(t *testing.T) { }, }, } - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ EnvFrom: []corev1.EnvFromSource{ envFrom1, envFrom2, @@ -681,13 +681,13 @@ func TestContainerProbe(t *testing.T) { successThreshold := int32(13) failureThreshold := int32(14) terminationGracePeriodSeconds := int64(15) - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Config: mustUnmarshalToConfig(t, `extensions: health_check: service: extensions: [health_check]`), - LivenessProbe: &v1alpha2.Probe{ + LivenessProbe: &v1beta1.Probe{ InitialDelaySeconds: &initialDelaySeconds, TimeoutSeconds: &timeoutSeconds, PeriodSeconds: &periodSeconds, @@ -718,13 +718,13 @@ service: func TestContainerProbeEmptyConfig(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Config: mustUnmarshalToConfig(t, `extensions: health_check: service: extensions: [health_check]`), - LivenessProbe: &v1alpha2.Probe{}, + LivenessProbe: &v1beta1.Probe{}, }, } cfg := config.New() @@ -740,8 +740,8 @@ service: func TestContainerProbeNoConfig(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Config: mustUnmarshalToConfig(t, `extensions: health_check: service: @@ -761,9 +761,9 @@ service: func TestContainerLifecycle(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Lifecycle: &corev1.Lifecycle{ PostStart: &corev1.LifecycleHandler{ Exec: &corev1.ExecAction{Command: []string{"sh", "sleep 100"}}, @@ -793,8 +793,8 @@ func TestContainerLifecycle(t *testing.T) { assert.Equal(t, expectedLifecycleHooks, *c.Lifecycle) } -func mustUnmarshalToConfig(t *testing.T, config string) v1alpha2.Config { - cfg := v1alpha2.Config{} +func mustUnmarshalToConfig(t *testing.T, config string) v1beta1.Config { + cfg := v1beta1.Config{} if err := yaml.Unmarshal([]byte(config), &cfg); err != nil { t.Fatal(err) } diff --git a/internal/manifests/collector/daemonset_test.go b/internal/manifests/collector/daemonset_test.go index da86c2afe8..17a326967c 100644 --- a/internal/manifests/collector/daemonset_test.go +++ b/internal/manifests/collector/daemonset_test.go @@ -24,7 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" @@ -34,13 +34,13 @@ func TestDaemonSetNewDefault(t *testing.T) { // prepare params := manifests.Params{ Config: config.New(), - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Tolerations: testTolerationValues, }, }, @@ -98,12 +98,12 @@ func TestDaemonSetNewDefault(t *testing.T) { func TestDaemonsetHostNetwork(t *testing.T) { params1 := manifests.Params{ Config: config.New(), - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + Spec: v1beta1.OpenTelemetryCollectorSpec{}, }, Log: logger, } @@ -116,13 +116,13 @@ func TestDaemonsetHostNetwork(t *testing.T) { // verify custom params2 := manifests.Params{ Config: config.New(), - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ HostNetwork: true, }, }, @@ -138,12 +138,12 @@ func TestDaemonsetHostNetwork(t *testing.T) { func TestDaemonsetPodAnnotations(t *testing.T) { // prepare testPodAnnotationValues := map[string]string{"annotation-key": "annotation-value"} - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodAnnotations: testPodAnnotationValues, }, }, @@ -182,12 +182,12 @@ func TestDaemonstPodSecurityContext(t *testing.T) { runAsUser := int64(1337) runasGroup := int64(1338) - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodSecurityContext: &v1.PodSecurityContext{ RunAsNonRoot: &runAsNonRoot, RunAsUser: &runAsUser, @@ -219,12 +219,12 @@ func TestDaemonsetFilterLabels(t *testing.T) { "app.foo.bar": "1", } - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Labels: excludedLabels, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + Spec: v1beta1.OpenTelemetryCollectorSpec{}, } cfg := config.New(config.WithLabelFilters([]string{"foo*", "app.*.bar"})) @@ -246,7 +246,7 @@ func TestDaemonsetFilterLabels(t *testing.T) { func TestDaemonSetNodeSelector(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -266,12 +266,12 @@ func TestDaemonSetNodeSelector(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.NodeSelector) // Test nodeSelector - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-nodeselector", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ HostNetwork: true, NodeSelector: map[string]string{ "node-key": "node-value", @@ -294,7 +294,7 @@ func TestDaemonSetNodeSelector(t *testing.T) { } func TestDaemonSetPriorityClassName(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -314,12 +314,12 @@ func TestDaemonSetPriorityClassName(t *testing.T) { priorityClassName := "test-class" - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-priortyClassName", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PriorityClassName: priorityClassName, }, }, @@ -339,7 +339,7 @@ func TestDaemonSetPriorityClassName(t *testing.T) { } func TestDaemonSetAffinity(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -357,12 +357,12 @@ func TestDaemonSetAffinity(t *testing.T) { require.NoError(t, err) assert.Nil(t, d1.Spec.Template.Spec.Affinity) - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-priortyClassName", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Affinity: testAffinityValue, }, }, @@ -384,13 +384,13 @@ func TestDaemonSetAffinity(t *testing.T) { func TestDaemonSetInitContainer(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ InitContainers: []v1.Container{ { Name: "test", @@ -420,13 +420,13 @@ func TestDaemonSetInitContainer(t *testing.T) { func TestDaemonSetAdditionalContainer(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ AdditionalContainers: []v1.Container{ { Name: "test", @@ -457,12 +457,12 @@ func TestDaemonSetAdditionalContainer(t *testing.T) { func TestDaemonSetDefaultUpdateStrategy(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ DaemonSetUpdateStrategy: appsv1.DaemonSetUpdateStrategy{ Type: "RollingUpdate", RollingUpdate: &appsv1.RollingUpdateDaemonSet{ @@ -492,12 +492,12 @@ func TestDaemonSetDefaultUpdateStrategy(t *testing.T) { func TestDaemonSetOnDeleteUpdateStrategy(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ DaemonSetUpdateStrategy: appsv1.DaemonSetUpdateStrategy{ Type: "OnDelete", RollingUpdate: &appsv1.RollingUpdateDaemonSet{ @@ -528,11 +528,11 @@ func TestDaemonSetOnDeleteUpdateStrategy(t *testing.T) { func TestDaemonsetShareProcessNamespace(t *testing.T) { params1 := manifests.Params{ Config: config.New(), - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + Spec: v1beta1.OpenTelemetryCollectorSpec{}, }, Log: logger, } @@ -544,12 +544,12 @@ func TestDaemonsetShareProcessNamespace(t *testing.T) { // verify custom params2 := manifests.Params{ Config: config.New(), - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-with-shareprocessnamespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ ShareProcessNamespace: true, }, }, diff --git a/internal/manifests/collector/deployment_test.go b/internal/manifests/collector/deployment_test.go index 8d33edabd9..662ef1de62 100644 --- a/internal/manifests/collector/deployment_test.go +++ b/internal/manifests/collector/deployment_test.go @@ -24,7 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" @@ -71,13 +71,13 @@ var testTopologySpreadConstraintValue = []v1.TopologySpreadConstraint{ func TestDeploymentNewDefault(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Tolerations: testTolerationValues, }, }, @@ -140,12 +140,12 @@ func TestDeploymentNewDefault(t *testing.T) { func TestDeploymentPodAnnotations(t *testing.T) { // prepare testPodAnnotationValues := map[string]string{"annotation-key": "annotation-value"} - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodAnnotations: testPodAnnotationValues, }, }, @@ -184,12 +184,12 @@ func TestDeploymenttPodSecurityContext(t *testing.T) { runAsUser := int64(1337) runasGroup := int64(1338) - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodSecurityContext: &v1.PodSecurityContext{ RunAsNonRoot: &runAsNonRoot, RunAsUser: &runAsUser, @@ -216,11 +216,11 @@ func TestDeploymenttPodSecurityContext(t *testing.T) { } func TestDeploymentUpdateStrategy(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ DeploymentUpdateStrategy: appsv1.DeploymentStrategy{ Type: "RollingUpdate", RollingUpdate: &appsv1.RollingUpdateDeployment{ @@ -249,7 +249,7 @@ func TestDeploymentUpdateStrategy(t *testing.T) { func TestDeploymentHostNetwork(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -270,12 +270,12 @@ func TestDeploymentHostNetwork(t *testing.T) { assert.Equal(t, d1.Spec.Template.Spec.DNSPolicy, v1.DNSClusterFirst) // Test hostNetwork=true - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-hostnetwork", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ HostNetwork: true, }, }, @@ -301,12 +301,12 @@ func TestDeploymentFilterLabels(t *testing.T) { "app.foo.bar": "1", } - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Labels: excludedLabels, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + Spec: v1beta1.OpenTelemetryCollectorSpec{}, } cfg := config.New(config.WithLabelFilters([]string{"foo*", "app.*.bar"})) @@ -328,7 +328,7 @@ func TestDeploymentFilterLabels(t *testing.T) { func TestDeploymentNodeSelector(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -348,12 +348,12 @@ func TestDeploymentNodeSelector(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.NodeSelector) // Test nodeSelector - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-nodeselector", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ HostNetwork: true, NodeSelector: map[string]string{ "node-key": "node-value", @@ -376,7 +376,7 @@ func TestDeploymentNodeSelector(t *testing.T) { } func TestDeploymentPriorityClassName(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -396,12 +396,12 @@ func TestDeploymentPriorityClassName(t *testing.T) { priorityClassName := "test-class" - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-priortyClassName", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PriorityClassName: priorityClassName, }, }, @@ -421,7 +421,7 @@ func TestDeploymentPriorityClassName(t *testing.T) { } func TestDeploymentAffinity(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -439,12 +439,12 @@ func TestDeploymentAffinity(t *testing.T) { require.NoError(t, err) assert.Nil(t, d1.Spec.Template.Spec.Affinity) - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-priortyClassName", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Affinity: testAffinityValue, }, }, @@ -465,7 +465,7 @@ func TestDeploymentAffinity(t *testing.T) { } func TestDeploymentTerminationGracePeriodSeconds(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -485,12 +485,12 @@ func TestDeploymentTerminationGracePeriodSeconds(t *testing.T) { gracePeriodSec := int64(60) - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-terminationGracePeriodSeconds", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ TerminationGracePeriodSeconds: &gracePeriodSec, }, }, @@ -512,13 +512,13 @@ func TestDeploymentTerminationGracePeriodSeconds(t *testing.T) { func TestDeploymentSetInitContainer(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ InitContainers: []v1.Container{ { Name: "test", @@ -548,7 +548,7 @@ func TestDeploymentSetInitContainer(t *testing.T) { func TestDeploymentTopologySpreadConstraints(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -567,12 +567,12 @@ func TestDeploymentTopologySpreadConstraints(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.TopologySpreadConstraints) // Test TopologySpreadConstraints - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-topologyspreadconstraint", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ TopologySpreadConstraints: testTopologySpreadConstraintValue, }, }, @@ -595,13 +595,13 @@ func TestDeploymentTopologySpreadConstraints(t *testing.T) { func TestDeploymentAdditionalContainers(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ AdditionalContainers: []v1.Container{ { Name: "test", @@ -632,7 +632,7 @@ func TestDeploymentAdditionalContainers(t *testing.T) { func TestDeploymentShareProcessNamespace(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -651,12 +651,12 @@ func TestDeploymentShareProcessNamespace(t *testing.T) { assert.False(t, *d1.Spec.Template.Spec.ShareProcessNamespace) // Test hostNetwork=true - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-with-shareprocessnamespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ ShareProcessNamespace: true, }, }, diff --git a/internal/manifests/collector/horizontalpodautoscaler_test.go b/internal/manifests/collector/horizontalpodautoscaler_test.go index 79f2074dc2..7ade5d1874 100644 --- a/internal/manifests/collector/horizontalpodautoscaler_test.go +++ b/internal/manifests/collector/horizontalpodautoscaler_test.go @@ -23,7 +23,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" @@ -41,14 +41,14 @@ func TestHPA(t *testing.T) { var cpuUtilization int32 = 66 var memoryUtilization int32 = 77 - otelcols := []v1alpha2.OpenTelemetryCollector{ + otelcols := []v1beta1.OpenTelemetryCollector{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ - Autoscaler: &v1alpha2.AutoscalerSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + Autoscaler: &v1beta1.AutoscalerSpec{ MinReplicas: &minReplicas, MaxReplicas: &maxReplicas, TargetCPUUtilization: &cpuUtilization, @@ -61,9 +61,9 @@ func TestHPA(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ - Autoscaler: &v1alpha2.AutoscalerSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + Autoscaler: &v1beta1.AutoscalerSpec{ MinReplicas: &minReplicas, MaxReplicas: &maxReplicas, TargetCPUUtilization: &cpuUtilization, @@ -80,11 +80,11 @@ func TestHPA(t *testing.T) { configuration := config.New() params := manifests.Params{ Config: configuration, - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: otelcol.ObjectMeta, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ - Autoscaler: &v1alpha2.AutoscalerSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ + Autoscaler: &v1beta1.AutoscalerSpec{ MinReplicas: otelcol.Spec.Autoscaler.MinReplicas, MaxReplicas: otelcol.Spec.Autoscaler.MaxReplicas, TargetCPUUtilization: otelcol.Spec.OpenTelemetryCommonFields.Autoscaler.TargetCPUUtilization, diff --git a/internal/manifests/collector/ingress.go b/internal/manifests/collector/ingress.go index 2992aa941f..fecd6d6a92 100644 --- a/internal/manifests/collector/ingress.go +++ b/internal/manifests/collector/ingress.go @@ -22,14 +22,14 @@ import ( networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) func Ingress(params manifests.Params) (*networkingv1.Ingress, error) { - if params.OtelCol.Spec.Ingress.Type != v1alpha2.IngressTypeNginx { + if params.OtelCol.Spec.Ingress.Type != v1beta1.IngressTypeNginx { return nil, nil } @@ -47,9 +47,9 @@ func Ingress(params manifests.Params) (*networkingv1.Ingress, error) { var rules []networkingv1.IngressRule switch params.OtelCol.Spec.Ingress.RuleType { - case v1alpha2.IngressRuleTypePath, "": + case v1beta1.IngressRuleTypePath, "": rules = []networkingv1.IngressRule{createPathIngressRules(params.OtelCol.Name, params.OtelCol.Spec.Ingress.Hostname, ports)} - case v1alpha2.IngressRuleTypeSubdomain: + case v1beta1.IngressRuleTypeSubdomain: rules = createSubdomainIngressRules(params.OtelCol.Name, params.OtelCol.Spec.Ingress.Hostname, ports) } @@ -136,7 +136,7 @@ func createSubdomainIngressRules(otelcol string, hostname string, ports []corev1 return rules } -func servicePortsFromCfg(logger logr.Logger, otelcol v1alpha2.OpenTelemetryCollector) ([]corev1.ServicePort, error) { +func servicePortsFromCfg(logger logr.Logger, otelcol v1beta1.OpenTelemetryCollector) ([]corev1.ServicePort, error) { out, err := otelcol.Spec.Config.Yaml() if err != nil { return nil, err diff --git a/internal/manifests/collector/ingress_test.go b/internal/manifests/collector/ingress_test.go index 5dbede9a93..9a7ae7ff10 100644 --- a/internal/manifests/collector/ingress_test.go +++ b/internal/manifests/collector/ingress_test.go @@ -26,7 +26,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/naming" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" ) @@ -37,10 +37,10 @@ func TestDesiredIngresses(t *testing.T) { params := manifests.Params{ Config: config.Config{}, Log: logger, - OtelCol: v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - Ingress: v1alpha2.Ingress{ - Type: v1alpha2.IngressType("unknown"), + OtelCol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Ingress: v1beta1.Ingress{ + Type: v1beta1.IngressType("unknown"), }, }, }, @@ -55,11 +55,11 @@ func TestDesiredIngresses(t *testing.T) { params := manifests.Params{ Config: config.Config{}, Log: logger, - OtelCol: v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - Config: v1alpha2.Config{}, - Ingress: v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeNginx, + OtelCol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{}, + Ingress: v1beta1.Ingress{ + Type: v1beta1.IngressTypeNginx, }, }, }, @@ -83,8 +83,8 @@ func TestDesiredIngresses(t *testing.T) { } params.OtelCol.Namespace = ns - params.OtelCol.Spec.Ingress = v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeNginx, + params.OtelCol.Spec.Ingress = v1beta1.Ingress{ + Type: v1beta1.IngressTypeNginx, Hostname: hostname, Annotations: map[string]string{"some.key": "some.value"}, IngressClassName: &ingressClassName, @@ -171,9 +171,9 @@ func TestDesiredIngresses(t *testing.T) { } params.OtelCol.Namespace = ns - params.OtelCol.Spec.Ingress = v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeNginx, - RuleType: v1alpha2.IngressRuleTypeSubdomain, + params.OtelCol.Spec.Ingress = v1beta1.Ingress{ + Type: v1beta1.IngressTypeNginx, + RuleType: v1beta1.IngressRuleTypeSubdomain, Hostname: hostname, Annotations: map[string]string{"some.key": "some.value"}, IngressClassName: &ingressClassName, diff --git a/internal/manifests/collector/poddisruptionbudget_test.go b/internal/manifests/collector/poddisruptionbudget_test.go index b759d4b677..7bf709a6be 100644 --- a/internal/manifests/collector/poddisruptionbudget_test.go +++ b/internal/manifests/collector/poddisruptionbudget_test.go @@ -22,7 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" @@ -65,7 +65,7 @@ func TestPDB(t *testing.T) { }, } - otelcols := []v1alpha2.OpenTelemetryCollector{ + otelcols := []v1beta1.OpenTelemetryCollector{ { ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", @@ -76,7 +76,7 @@ func TestPDB(t *testing.T) { for _, otelcol := range otelcols { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - otelcol.Spec.PodDisruptionBudget = &v1alpha2.PodDisruptionBudgetSpec{ + otelcol.Spec.PodDisruptionBudget = &v1beta1.PodDisruptionBudgetSpec{ MinAvailable: test.MinAvailable, MaxUnavailable: test.MaxUnavailable, } diff --git a/internal/manifests/collector/podmonitor.go b/internal/manifests/collector/podmonitor.go index f51c7c95b1..73c63bf56b 100644 --- a/internal/manifests/collector/podmonitor.go +++ b/internal/manifests/collector/podmonitor.go @@ -22,7 +22,7 @@ import ( monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -39,7 +39,7 @@ func PodMonitor(params manifests.Params) (*monitoringv1.PodMonitor, error) { } var pm monitoringv1.PodMonitor - if params.OtelCol.Spec.Mode != v1alpha2.ModeSidecar { + if params.OtelCol.Spec.Mode != v1beta1.ModeSidecar { return nil, nil } @@ -77,7 +77,7 @@ func PodMonitor(params manifests.Params) (*monitoringv1.PodMonitor, error) { return &pm, nil } -func metricsEndpointsFromConfig(logger logr.Logger, otelcol v1alpha2.OpenTelemetryCollector) []monitoringv1.PodMetricsEndpoint { +func metricsEndpointsFromConfig(logger logr.Logger, otelcol v1beta1.OpenTelemetryCollector) []monitoringv1.PodMetricsEndpoint { // TODO: https://github.com/open-telemetry/opentelemetry-operator/issues/2603 cfgStr, err := otelcol.Spec.Config.Yaml() if err != nil { diff --git a/internal/manifests/collector/podmonitor_test.go b/internal/manifests/collector/podmonitor_test.go index 2feaa996c8..c83950ea85 100644 --- a/internal/manifests/collector/podmonitor_test.go +++ b/internal/manifests/collector/podmonitor_test.go @@ -18,14 +18,14 @@ import ( "fmt" "testing" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/stretchr/testify/assert" ) func sidecarParams() manifests.Params { - return paramsWithMode(v1alpha2.ModeSidecar) + return paramsWithMode(v1beta1.ModeSidecar) } func TestDesiredPodMonitors(t *testing.T) { @@ -45,7 +45,7 @@ func TestDesiredPodMonitors(t *testing.T) { params, err = newParams("", "testdata/prometheus-exporter.yaml") assert.NoError(t, err) - params.OtelCol.Spec.Mode = v1alpha2.ModeSidecar + params.OtelCol.Spec.Mode = v1beta1.ModeSidecar params.OtelCol.Spec.Observability.Metrics.EnableMetrics = true actual, err = PodMonitor(params) assert.NoError(t, err) diff --git a/internal/manifests/collector/route.go b/internal/manifests/collector/route.go index b30fe59288..29fa385c38 100644 --- a/internal/manifests/collector/route.go +++ b/internal/manifests/collector/route.go @@ -21,31 +21,31 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/openshift" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) func Routes(params manifests.Params) ([]*routev1.Route, error) { - if params.OtelCol.Spec.Ingress.Type != v1alpha2.IngressTypeRoute || params.Config.OpenShiftRoutesAvailability() != openshift.RoutesAvailable { + if params.OtelCol.Spec.Ingress.Type != v1beta1.IngressTypeRoute || params.Config.OpenShiftRoutesAvailability() != openshift.RoutesAvailable { return nil, nil } - if params.OtelCol.Spec.Mode == v1alpha2.ModeSidecar { + if params.OtelCol.Spec.Mode == v1beta1.ModeSidecar { params.Log.V(3).Info("ingress settings are not supported in sidecar mode") return nil, nil } var tlsCfg *routev1.TLSConfig switch params.OtelCol.Spec.Ingress.Route.Termination { - case v1alpha2.TLSRouteTerminationTypeInsecure: + case v1beta1.TLSRouteTerminationTypeInsecure: // NOTE: insecure, no tls cfg. - case v1alpha2.TLSRouteTerminationTypeEdge: + case v1beta1.TLSRouteTerminationTypeEdge: tlsCfg = &routev1.TLSConfig{Termination: routev1.TLSTerminationEdge} - case v1alpha2.TLSRouteTerminationTypePassthrough: + case v1beta1.TLSRouteTerminationTypePassthrough: tlsCfg = &routev1.TLSConfig{Termination: routev1.TLSTerminationPassthrough} - case v1alpha2.TLSRouteTerminationTypeReencrypt: + case v1beta1.TLSRouteTerminationTypeReencrypt: tlsCfg = &routev1.TLSConfig{Termination: routev1.TLSTerminationReencrypt} default: // NOTE: if unsupported, end here. return nil, nil diff --git a/internal/manifests/collector/route_test.go b/internal/manifests/collector/route_test.go index 2826f2dd37..b7ec294e7b 100644 --- a/internal/manifests/collector/route_test.go +++ b/internal/manifests/collector/route_test.go @@ -25,7 +25,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -36,10 +36,10 @@ func TestDesiredRoutes(t *testing.T) { params := manifests.Params{ Config: config.Config{}, Log: logger, - OtelCol: v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - Ingress: v1alpha2.Ingress{ - Type: v1alpha2.IngressType("unknown"), + OtelCol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Ingress: v1beta1.Ingress{ + Type: v1beta1.IngressType("unknown"), }, }, }, @@ -54,13 +54,13 @@ func TestDesiredRoutes(t *testing.T) { params := manifests.Params{ Config: config.Config{}, Log: logger, - OtelCol: v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - Config: v1alpha2.Config{}, - Ingress: v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeRoute, - Route: v1alpha2.OpenShiftRoute{ - Termination: v1alpha2.TLSRouteTerminationTypeInsecure, + OtelCol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + Config: v1beta1.Config{}, + Ingress: v1beta1.Ingress{ + Type: v1beta1.IngressTypeRoute, + Route: v1beta1.OpenShiftRoute{ + Termination: v1beta1.TLSRouteTerminationTypeInsecure, }, }, }, @@ -84,12 +84,12 @@ func TestDesiredRoutes(t *testing.T) { } params.OtelCol.Namespace = ns - params.OtelCol.Spec.Ingress = v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeRoute, + params.OtelCol.Spec.Ingress = v1beta1.Ingress{ + Type: v1beta1.IngressTypeRoute, Hostname: hostname, Annotations: map[string]string{"some.key": "some.value"}, - Route: v1alpha2.OpenShiftRoute{ - Termination: v1alpha2.TLSRouteTerminationTypeInsecure, + Route: v1beta1.OpenShiftRoute{ + Termination: v1beta1.TLSRouteTerminationTypeInsecure, }, } @@ -134,11 +134,11 @@ func TestDesiredRoutes(t *testing.T) { } params.OtelCol.Namespace = "test" - params.OtelCol.Spec.Ingress = v1alpha2.Ingress{ + params.OtelCol.Spec.Ingress = v1beta1.Ingress{ Hostname: "example.com", - Type: v1alpha2.IngressTypeRoute, - Route: v1alpha2.OpenShiftRoute{ - Termination: v1alpha2.TLSRouteTerminationTypeInsecure, + Type: v1beta1.IngressTypeRoute, + Route: v1beta1.OpenShiftRoute{ + Termination: v1beta1.TLSRouteTerminationTypeInsecure, }, } @@ -156,10 +156,10 @@ func TestDesiredRoutes(t *testing.T) { } params.OtelCol.Namespace = "test" - params.OtelCol.Spec.Ingress = v1alpha2.Ingress{ - Type: v1alpha2.IngressTypeRoute, - Route: v1alpha2.OpenShiftRoute{ - Termination: v1alpha2.TLSRouteTerminationTypeInsecure, + params.OtelCol.Spec.Ingress = v1beta1.Ingress{ + Type: v1beta1.IngressTypeRoute, + Route: v1beta1.OpenShiftRoute{ + Termination: v1beta1.TLSRouteTerminationTypeInsecure, }, } diff --git a/internal/manifests/collector/service.go b/internal/manifests/collector/service.go index ffec4288c1..8ac13a3e6d 100644 --- a/internal/manifests/collector/service.go +++ b/internal/manifests/collector/service.go @@ -22,7 +22,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" @@ -120,7 +120,7 @@ func Service(params manifests.Params) (*corev1.Service, error) { // OpenShift uses HA proxy that uses appProtocol for its configuration. for i := range ports { h2c := "h2c" - if params.OtelCol.Spec.Ingress.Type == v1alpha2.IngressTypeRoute && ports[i].AppProtocol != nil && strings.EqualFold(*ports[i].AppProtocol, "grpc") { + if params.OtelCol.Spec.Ingress.Type == v1beta1.IngressTypeRoute && ports[i].AppProtocol != nil && strings.EqualFold(*ports[i].AppProtocol, "grpc") { ports[i].AppProtocol = &h2c } } @@ -152,7 +152,7 @@ func Service(params manifests.Params) (*corev1.Service, error) { } trafficPolicy := corev1.ServiceInternalTrafficPolicyCluster - if params.OtelCol.Spec.Mode == v1alpha2.ModeDaemonSet { + if params.OtelCol.Spec.Mode == v1beta1.ModeDaemonSet { trafficPolicy = corev1.ServiceInternalTrafficPolicyLocal } diff --git a/internal/manifests/collector/service_test.go b/internal/manifests/collector/service_test.go index 0878a7c03f..0498a071a8 100644 --- a/internal/manifests/collector/service_test.go +++ b/internal/manifests/collector/service_test.go @@ -24,7 +24,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" ) @@ -156,8 +156,8 @@ func TestDesiredService(t *testing.T) { params := manifests.Params{ Config: config.Config{}, Log: logger, - OtelCol: v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{Config: v1alpha2.Config{}}, + OtelCol: v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{Config: v1beta1.Config{}}, }, } @@ -195,7 +195,7 @@ func TestDesiredService(t *testing.T) { params := deploymentParams() - params.OtelCol.Spec.Ingress.Type = v1alpha2.IngressTypeRoute + params.OtelCol.Spec.Ingress.Type = v1beta1.IngressTypeRoute actual, err := Service(params) ports := append(params.OtelCol.Spec.Ports, jaegerPort) @@ -214,7 +214,7 @@ func TestDesiredService(t *testing.T) { Port: 14250, AppProtocol: &grpc, } - p := paramsWithMode(v1alpha2.ModeDaemonSet) + p := paramsWithMode(v1beta1.ModeDaemonSet) ports := append(p.OtelCol.Spec.Ports, jaegerPorts) expected := serviceWithInternalTrafficPolicy("test-collector", ports, v1.ServiceInternalTrafficPolicyLocal) @@ -256,9 +256,9 @@ func TestMonitoringService(t *testing.T) { Port: 9090, }} params := deploymentParams() - params.OtelCol.Spec.Config = v1alpha2.Config{ - Service: v1alpha2.Service{ - Telemetry: &v1alpha2.AnyConfig{ + params.OtelCol.Spec.Config = v1beta1.Config{ + Service: v1beta1.Service{ + Telemetry: &v1beta1.AnyConfig{ Object: map[string]interface{}{ "metrics": map[string]interface{}{ "level": "detailed", diff --git a/internal/manifests/collector/serviceaccount.go b/internal/manifests/collector/serviceaccount.go index d5f481dea0..4ad29bf696 100644 --- a/internal/manifests/collector/serviceaccount.go +++ b/internal/manifests/collector/serviceaccount.go @@ -18,14 +18,14 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) // ServiceAccountName returns the name of the existing or self-provisioned service account to use for the given instance. -func ServiceAccountName(instance v1alpha2.OpenTelemetryCollector) string { +func ServiceAccountName(instance v1beta1.OpenTelemetryCollector) string { if len(instance.Spec.ServiceAccount) == 0 { return naming.ServiceAccount(instance.Name) } diff --git a/internal/manifests/collector/serviceaccount_test.go b/internal/manifests/collector/serviceaccount_test.go index 7a66caf2f8..3a7c3ec351 100644 --- a/internal/manifests/collector/serviceaccount_test.go +++ b/internal/manifests/collector/serviceaccount_test.go @@ -20,13 +20,13 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" ) func TestServiceAccountNewDefault(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -41,12 +41,12 @@ func TestServiceAccountNewDefault(t *testing.T) { func TestServiceAccountOverride(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ ServiceAccount: "my-special-sa", }, }, diff --git a/internal/manifests/collector/servicemonitor.go b/internal/manifests/collector/servicemonitor.go index 02496e7898..f7cb6b9d70 100644 --- a/internal/manifests/collector/servicemonitor.go +++ b/internal/manifests/collector/servicemonitor.go @@ -22,7 +22,7 @@ import ( monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -39,7 +39,7 @@ func ServiceMonitor(params manifests.Params) (*monitoringv1.ServiceMonitor, erro } var sm monitoringv1.ServiceMonitor - if params.OtelCol.Spec.Mode == v1alpha2.ModeSidecar { + if params.OtelCol.Spec.Mode == v1beta1.ModeSidecar { return nil, nil } sm = monitoringv1.ServiceMonitor{ @@ -73,7 +73,7 @@ func ServiceMonitor(params manifests.Params) (*monitoringv1.ServiceMonitor, erro return &sm, nil } -func endpointsFromConfig(logger logr.Logger, otelcol v1alpha2.OpenTelemetryCollector) []monitoringv1.Endpoint { +func endpointsFromConfig(logger logr.Logger, otelcol v1beta1.OpenTelemetryCollector) []monitoringv1.Endpoint { // TODO: https://github.com/open-telemetry/opentelemetry-operator/issues/2603 cfgStr, err := otelcol.Spec.Config.Yaml() if err != nil { diff --git a/internal/manifests/collector/statefulset_test.go b/internal/manifests/collector/statefulset_test.go index 36df6de3e3..0a9d822f29 100644 --- a/internal/manifests/collector/statefulset_test.go +++ b/internal/manifests/collector/statefulset_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" @@ -33,14 +33,14 @@ import ( func TestStatefulSetNewDefault(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Mode: "statefulset", - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Tolerations: testTolerationValues, }, }, @@ -109,13 +109,13 @@ func TestStatefulSetNewDefault(t *testing.T) { func TestStatefulSetReplicas(t *testing.T) { // prepare replicaInt := int32(3) - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Mode: "statefulset", - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Replicas: &replicaInt, }, }, @@ -138,13 +138,13 @@ func TestStatefulSetReplicas(t *testing.T) { func TestStatefulSetVolumeClaimTemplates(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Mode: "statefulset", - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ VolumeClaimTemplates: []corev1.PersistentVolumeClaim{{ ObjectMeta: metav1.ObjectMeta{ Name: "added-volume", @@ -184,12 +184,12 @@ func TestStatefulSetVolumeClaimTemplates(t *testing.T) { func TestStatefulSetPodAnnotations(t *testing.T) { // prepare testPodAnnotationValues := map[string]string{"annotation-key": "annotation-value"} - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodAnnotations: testPodAnnotationValues, }, }, @@ -226,12 +226,12 @@ func TestStatefulSetPodSecurityContext(t *testing.T) { runAsUser := int64(1337) runasGroup := int64(1338) - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PodSecurityContext: &v1.PodSecurityContext{ RunAsNonRoot: &runAsNonRoot, RunAsUser: &runAsUser, @@ -259,7 +259,7 @@ func TestStatefulSetPodSecurityContext(t *testing.T) { func TestStatefulSetHostNetwork(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -280,12 +280,12 @@ func TestStatefulSetHostNetwork(t *testing.T) { assert.Equal(t, d1.Spec.Template.Spec.DNSPolicy, v1.DNSClusterFirst) // Test hostNetwork=true - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-hostnetwork", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ HostNetwork: true, }, }, @@ -311,12 +311,12 @@ func TestStatefulSetFilterLabels(t *testing.T) { "app.foo.bar": "1", } - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Labels: excludedLabels, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{}, + Spec: v1beta1.OpenTelemetryCollectorSpec{}, } cfg := config.New(config.WithLabelFilters([]string{"foo*", "app.*.bar"})) @@ -338,7 +338,7 @@ func TestStatefulSetFilterLabels(t *testing.T) { func TestStatefulSetNodeSelector(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -358,12 +358,12 @@ func TestStatefulSetNodeSelector(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.NodeSelector) // Test nodeSelector - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-nodeselector", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ HostNetwork: true, NodeSelector: map[string]string{ "node-key": "node-value", @@ -386,7 +386,7 @@ func TestStatefulSetNodeSelector(t *testing.T) { } func TestStatefulSetPriorityClassName(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -406,12 +406,12 @@ func TestStatefulSetPriorityClassName(t *testing.T) { priorityClassName := "test-class" - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-priortyClassName", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ PriorityClassName: priorityClassName, }, }, @@ -431,7 +431,7 @@ func TestStatefulSetPriorityClassName(t *testing.T) { } func TestStatefulSetAffinity(t *testing.T) { - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -449,12 +449,12 @@ func TestStatefulSetAffinity(t *testing.T) { require.NoError(t, err) assert.Nil(t, sts1.Spec.Template.Spec.Affinity) - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-priortyClassName", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Affinity: testAffinityValue, }, }, @@ -476,13 +476,13 @@ func TestStatefulSetAffinity(t *testing.T) { func TestStatefulSetInitContainer(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ InitContainers: []v1.Container{ { Name: "test", @@ -512,7 +512,7 @@ func TestStatefulSetInitContainer(t *testing.T) { func TestStatefulSetTopologySpreadConstraints(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -531,12 +531,12 @@ func TestStatefulSetTopologySpreadConstraints(t *testing.T) { assert.Empty(t, s1.Spec.Template.Spec.TopologySpreadConstraints) // Test TopologySpreadConstraints - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-topologyspreadconstraint", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ TopologySpreadConstraints: testTopologySpreadConstraintValue, }, }, @@ -560,13 +560,13 @@ func TestStatefulSetTopologySpreadConstraints(t *testing.T) { func TestStatefulSetAdditionalContainers(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ AdditionalContainers: []v1.Container{ { Name: "test", @@ -597,7 +597,7 @@ func TestStatefulSetAdditionalContainers(t *testing.T) { func TestStatefulSetShareProcessNamespace(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -616,12 +616,12 @@ func TestStatefulSetShareProcessNamespace(t *testing.T) { assert.False(t, *d1.Spec.Template.Spec.ShareProcessNamespace) // Test shareProcessNamespace=true - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-with-shareprocessnamespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ ShareProcessNamespace: true, }, }, diff --git a/internal/manifests/collector/suite_test.go b/internal/manifests/collector/suite_test.go index 88975a4fdb..64593c7e5b 100644 --- a/internal/manifests/collector/suite_test.go +++ b/internal/manifests/collector/suite_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/client-go/tools/record" logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/openshift" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" @@ -43,23 +43,23 @@ const ( ) func deploymentParams() manifests.Params { - return paramsWithMode(v1alpha2.ModeDeployment) + return paramsWithMode(v1beta1.ModeDeployment) } -func paramsWithMode(mode v1alpha2.Mode) manifests.Params { +func paramsWithMode(mode v1beta1.Mode) manifests.Params { replicas := int32(2) configYAML, err := os.ReadFile("testdata/test.yaml") if err != nil { fmt.Printf("Error getting yaml file: %v", err) } - cfg := v1alpha2.Config{} + cfg := v1beta1.Config{} err = go_yaml.Unmarshal(configYAML, &cfg) if err != nil { fmt.Printf("Error unmarshalling YAML: %v", err) } return manifests.Params{ Config: config.New(config.WithCollectorImage(defaultCollectorImage), config.WithTargetAllocatorImage(defaultTaAllocationImage)), - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ TypeMeta: metav1.TypeMeta{ Kind: "opentelemetry.io", APIVersion: "v1", @@ -69,8 +69,8 @@ func paramsWithMode(mode v1alpha2.Mode) manifests.Params { Namespace: "default", UID: instanceUID, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.47.0", Ports: []v1.ServicePort{{ @@ -107,7 +107,7 @@ func newParams(taContainerImage string, file string) (manifests.Params, error) { return manifests.Params{}, fmt.Errorf("error getting yaml file: %w", err) } - colCfg := v1alpha2.Config{} + colCfg := v1beta1.Config{} err = go_yaml.Unmarshal(configYAML, &colCfg) if err != nil { return manifests.Params{}, fmt.Errorf("failed to unmarshal config: %w", err) @@ -121,7 +121,7 @@ func newParams(taContainerImage string, file string) (manifests.Params, error) { return manifests.Params{ Config: cfg, - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ TypeMeta: metav1.TypeMeta{ Kind: "opentelemetry.io", APIVersion: "v1", @@ -131,8 +131,8 @@ func newParams(taContainerImage string, file string) (manifests.Params, error) { Namespace: "default", UID: instanceUID, }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Ports: []v1.ServicePort{{ Name: "web", Port: 80, @@ -145,8 +145,8 @@ func newParams(taContainerImage string, file string) (manifests.Params, error) { Replicas: &replicas, }, - Mode: v1alpha2.ModeStatefulSet, - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Mode: v1beta1.ModeStatefulSet, + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Image: taContainerImage, }, diff --git a/internal/manifests/collector/utils.go b/internal/manifests/collector/utils.go index 250e7dbcbd..da75763f0d 100644 --- a/internal/manifests/collector/utils.go +++ b/internal/manifests/collector/utils.go @@ -17,10 +17,10 @@ package collector import ( corev1 "k8s.io/api/core/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) -func getDNSPolicy(otelcol v1alpha2.OpenTelemetryCollector) corev1.DNSPolicy { +func getDNSPolicy(otelcol v1beta1.OpenTelemetryCollector) corev1.DNSPolicy { dnsPolicy := corev1.DNSClusterFirst if otelcol.Spec.HostNetwork { dnsPolicy = corev1.DNSClusterFirstWithHostNet diff --git a/internal/manifests/collector/volume.go b/internal/manifests/collector/volume.go index 634694c2a0..5cf82fde7a 100644 --- a/internal/manifests/collector/volume.go +++ b/internal/manifests/collector/volume.go @@ -18,13 +18,13 @@ package collector import ( corev1 "k8s.io/api/core/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) // Volumes builds the volumes for the given instance, including the config map volume. -func Volumes(cfg config.Config, otelcol v1alpha2.OpenTelemetryCollector) []corev1.Volume { +func Volumes(cfg config.Config, otelcol v1beta1.OpenTelemetryCollector) []corev1.Volume { volumes := []corev1.Volume{{ Name: naming.ConfigMapVolume(), VolumeSource: corev1.VolumeSource{ diff --git a/internal/manifests/collector/volume_test.go b/internal/manifests/collector/volume_test.go index 9f355320d2..0101699ebf 100644 --- a/internal/manifests/collector/volume_test.go +++ b/internal/manifests/collector/volume_test.go @@ -21,7 +21,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -29,7 +29,7 @@ import ( func TestVolumeNewDefault(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{} + otelcol := v1beta1.OpenTelemetryCollector{} cfg := config.New() // test @@ -44,9 +44,9 @@ func TestVolumeNewDefault(t *testing.T) { func TestVolumeAllowsMoreToBeAdded(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Volumes: []corev1.Volume{{ Name: "my-volume", }}, @@ -67,8 +67,8 @@ func TestVolumeAllowsMoreToBeAdded(t *testing.T) { func TestVolumeWithMoreConfigMaps(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ ConfigMaps: []v1alpha1.ConfigMapsSpec{{ Name: "configmap-test", MountPath: "/", diff --git a/internal/manifests/collector/volumeclaim.go b/internal/manifests/collector/volumeclaim.go index cd076cbcd1..d3c94ed6f3 100644 --- a/internal/manifests/collector/volumeclaim.go +++ b/internal/manifests/collector/volumeclaim.go @@ -18,12 +18,12 @@ package collector import ( corev1 "k8s.io/api/core/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) // VolumeClaimTemplates builds the volumeClaimTemplates for the given instance, // including the config map volume mount. -func VolumeClaimTemplates(otelcol v1alpha2.OpenTelemetryCollector) []corev1.PersistentVolumeClaim { +func VolumeClaimTemplates(otelcol v1beta1.OpenTelemetryCollector) []corev1.PersistentVolumeClaim { if otelcol.Spec.Mode != "statefulset" { return []corev1.PersistentVolumeClaim{} } diff --git a/internal/manifests/collector/volumeclaim_test.go b/internal/manifests/collector/volumeclaim_test.go index f848c98867..df34a41ab0 100644 --- a/internal/manifests/collector/volumeclaim_test.go +++ b/internal/manifests/collector/volumeclaim_test.go @@ -22,16 +22,16 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" ) func TestVolumeClaimAllowsUserToAdd(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Mode: "statefulset", - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ VolumeClaimTemplates: []corev1.PersistentVolumeClaim{{ ObjectMeta: metav1.ObjectMeta{ Name: "added-volume", @@ -65,10 +65,10 @@ func TestVolumeClaimAllowsUserToAdd(t *testing.T) { func TestVolumeClaimChecksForStatefulset(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ Mode: "daemonset", - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ VolumeClaimTemplates: []corev1.PersistentVolumeClaim{{ ObjectMeta: metav1.ObjectMeta{ Name: "added-volume", diff --git a/internal/manifests/params.go b/internal/manifests/params.go index 95a922a910..93a728e2ae 100644 --- a/internal/manifests/params.go +++ b/internal/manifests/params.go @@ -21,7 +21,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" ) @@ -31,7 +31,7 @@ type Params struct { Recorder record.EventRecorder Scheme *runtime.Scheme Log logr.Logger - OtelCol v1alpha2.OpenTelemetryCollector + OtelCol v1beta1.OpenTelemetryCollector OpAMPBridge v1alpha1.OpAMPBridge Config config.Config } diff --git a/internal/manifests/targetallocator/annotations.go b/internal/manifests/targetallocator/annotations.go index 8ad5b0d894..8d98e55a81 100644 --- a/internal/manifests/targetallocator/annotations.go +++ b/internal/manifests/targetallocator/annotations.go @@ -20,13 +20,13 @@ import ( v1 "k8s.io/api/core/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" ) const configMapHashAnnotationKey = "opentelemetry-targetallocator-config/hash" // Annotations returns the annotations for the TargetAllocator Pod. -func Annotations(instance v1alpha2.OpenTelemetryCollector, configMap *v1.ConfigMap) map[string]string { +func Annotations(instance v1beta1.OpenTelemetryCollector, configMap *v1.ConfigMap) map[string]string { // Make a copy of PodAnnotations to be safe annotations := make(map[string]string, len(instance.Spec.PodAnnotations)) for key, value := range instance.Spec.PodAnnotations { diff --git a/internal/manifests/targetallocator/annotations_test.go b/internal/manifests/targetallocator/annotations_test.go index bb5a839098..bcdb127e52 100644 --- a/internal/manifests/targetallocator/annotations_test.go +++ b/internal/manifests/targetallocator/annotations_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" ) @@ -58,7 +58,7 @@ func TestConfigMapHash(t *testing.T) { func TestInvalidConfigNoHash(t *testing.T) { instance := collectorInstance() - instance.Spec.Config = v1alpha2.Config{} + instance.Spec.Config = v1beta1.Config{} annotations := Annotations(instance, nil) require.NotContains(t, annotations, configMapHashAnnotationKey) } diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index e4ddb5182a..f4fe2be293 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -19,7 +19,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" @@ -64,7 +64,7 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) { if len(params.OtelCol.Spec.TargetAllocator.AllocationStrategy) > 0 { taConfig["allocation_strategy"] = params.OtelCol.Spec.TargetAllocator.AllocationStrategy } else { - taConfig["allocation_strategy"] = v1alpha2.TargetAllocatorAllocationStrategyConsistentHashing + taConfig["allocation_strategy"] = v1beta1.TargetAllocatorAllocationStrategyConsistentHashing } taConfig["filter_strategy"] = params.OtelCol.Spec.TargetAllocator.FilterStrategy diff --git a/internal/manifests/targetallocator/container.go b/internal/manifests/targetallocator/container.go index 53cbfc3a70..18848c7849 100644 --- a/internal/manifests/targetallocator/container.go +++ b/internal/manifests/targetallocator/container.go @@ -20,13 +20,13 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) // Container builds a container for the given TargetAllocator. -func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha2.OpenTelemetryCollector) corev1.Container { +func Container(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTelemetryCollector) corev1.Container { image := otelcol.Spec.TargetAllocator.Image if len(image) == 0 { image = cfg.TargetAllocatorImage() diff --git a/internal/manifests/targetallocator/container_test.go b/internal/manifests/targetallocator/container_test.go index 9957740c9a..9efc93ca8f 100644 --- a/internal/manifests/targetallocator/container_test.go +++ b/internal/manifests/targetallocator/container_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) @@ -34,7 +34,7 @@ var logger = logf.Log.WithName("unit-tests") func TestContainerNewDefault(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{} + otelcol := v1beta1.OpenTelemetryCollector{} cfg := config.New(config.WithTargetAllocatorImage("default-image")) // test @@ -46,9 +46,9 @@ func TestContainerNewDefault(t *testing.T) { func TestContainerWithImageOverridden(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Image: "overridden-image", }, @@ -65,9 +65,9 @@ func TestContainerWithImageOverridden(t *testing.T) { func TestContainerPorts(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Image: "default-image", }, @@ -86,9 +86,9 @@ func TestContainerPorts(t *testing.T) { func TestContainerVolumes(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Image: "default-image", }, @@ -105,9 +105,9 @@ func TestContainerVolumes(t *testing.T) { } func TestContainerResourceRequirements(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Resources: corev1.ResourceRequirements{ Limits: corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("100m"), @@ -143,9 +143,9 @@ func TestContainerResourceRequirements(t *testing.T) { func TestContainerHasEnvVars(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Env: []corev1.EnvVar{ { @@ -228,9 +228,9 @@ func TestContainerHasProxyEnvVars(t *testing.T) { defer os.Unsetenv("NO_PROXY") // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Env: []corev1.EnvVar{ { @@ -254,9 +254,9 @@ func TestContainerHasProxyEnvVars(t *testing.T) { func TestContainerDoesNotOverrideEnvVars(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, Env: []corev1.EnvVar{ { @@ -320,9 +320,9 @@ func TestContainerDoesNotOverrideEnvVars(t *testing.T) { assert.Equal(t, expected, c) } func TestReadinessProbe(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, }, }, @@ -345,9 +345,9 @@ func TestReadinessProbe(t *testing.T) { } func TestLivenessProbe(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, }, }, @@ -375,9 +375,9 @@ func TestSecurityContext(t *testing.T) { RunAsNonRoot: &runAsNonRoot, } // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + otelcol := v1beta1.OpenTelemetryCollector{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Enabled: true, SecurityContext: securityContext, }, diff --git a/internal/manifests/targetallocator/deployment_test.go b/internal/manifests/targetallocator/deployment_test.go index 61efa1550f..96647bea3a 100644 --- a/internal/manifests/targetallocator/deployment_test.go +++ b/internal/manifests/targetallocator/deployment_test.go @@ -24,7 +24,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" ) @@ -78,7 +78,7 @@ var testSecurityContextValue = &v1.PodSecurityContext{ func TestDeploymentSecurityContext(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -98,12 +98,12 @@ func TestDeploymentSecurityContext(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.SecurityContext) // Test SecurityContext - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-securitycontext", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ PodSecurityContext: testSecurityContextValue, }, }, @@ -175,27 +175,27 @@ func TestDeploymentPodAnnotations(t *testing.T) { assert.Subset(t, ds.Spec.Template.Annotations, testPodAnnotationValues) } -func collectorInstance() v1alpha2.OpenTelemetryCollector { +func collectorInstance() v1beta1.OpenTelemetryCollector { configYAML, err := os.ReadFile("testdata/test.yaml") if err != nil { fmt.Printf("Error getting yaml file: %v", err) } - cfg := v1alpha2.Config{} + cfg := v1beta1.Config{} err = go_yaml.Unmarshal(configYAML, &cfg) if err != nil { fmt.Printf("Error unmarshalling YAML: %v", err) } - return v1alpha2.OpenTelemetryCollector{ + return v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "default", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Image: "ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.47.0", }, Config: cfg, - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Image: "ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-targetallocator:0.47.0", FilterStrategy: "relabel-config", }, @@ -205,7 +205,7 @@ func collectorInstance() v1alpha2.OpenTelemetryCollector { func TestDeploymentNodeSelector(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -223,12 +223,12 @@ func TestDeploymentNodeSelector(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.NodeSelector) // Test nodeSelector - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-nodeselector", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ NodeSelector: map[string]string{ "node-key": "node-value", }, @@ -250,7 +250,7 @@ func TestDeploymentNodeSelector(t *testing.T) { } func TestDeploymentAffinity(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -268,12 +268,12 @@ func TestDeploymentAffinity(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.Affinity) // Test affinity - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-affinity", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Affinity: testAffinityValue, }, }, @@ -294,7 +294,7 @@ func TestDeploymentAffinity(t *testing.T) { func TestDeploymentTolerations(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -312,12 +312,12 @@ func TestDeploymentTolerations(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.Tolerations) // Test Tolerations - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-toleration", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ Tolerations: testTolerationValues, }, }, @@ -338,7 +338,7 @@ func TestDeploymentTolerations(t *testing.T) { func TestDeploymentTopologySpreadConstraints(t *testing.T) { // Test default - otelcol1 := v1alpha2.OpenTelemetryCollector{ + otelcol1 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -357,12 +357,12 @@ func TestDeploymentTopologySpreadConstraints(t *testing.T) { assert.Empty(t, d1.Spec.Template.Spec.TopologySpreadConstraints) // Test TopologySpreadConstraints - otelcol2 := v1alpha2.OpenTelemetryCollector{ + otelcol2 := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance-topologyspreadconstraint", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ TopologySpreadConstraints: testTopologySpreadConstraintValue, }, }, diff --git a/internal/manifests/targetallocator/labels.go b/internal/manifests/targetallocator/labels.go index f2b87c1c0e..09a43e4108 100644 --- a/internal/manifests/targetallocator/labels.go +++ b/internal/manifests/targetallocator/labels.go @@ -15,18 +15,18 @@ package targetallocator import ( - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) // Labels return the common labels to all TargetAllocator objects that are part of a managed OpenTelemetryCollector. -func Labels(instance v1alpha2.OpenTelemetryCollector, name string) map[string]string { +func Labels(instance v1beta1.OpenTelemetryCollector, name string) map[string]string { return manifestutils.Labels(instance.ObjectMeta, name, instance.Spec.TargetAllocator.Image, ComponentOpenTelemetryTargetAllocator, nil) } // SelectorLabels return the selector labels for Target Allocator Pods. -func SelectorLabels(instance v1alpha2.OpenTelemetryCollector) map[string]string { +func SelectorLabels(instance v1beta1.OpenTelemetryCollector) map[string]string { selectorLabels := manifestutils.SelectorLabels(instance.ObjectMeta, ComponentOpenTelemetryTargetAllocator) // TargetAllocator uses the name label as well for selection // This is inconsistent with the Collector, but changing is a somewhat painful breaking change diff --git a/internal/manifests/targetallocator/labels_test.go b/internal/manifests/targetallocator/labels_test.go index d029dd5a97..382835d532 100644 --- a/internal/manifests/targetallocator/labels_test.go +++ b/internal/manifests/targetallocator/labels_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) @@ -31,7 +31,7 @@ const ( func TestLabelsCommonSet(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, @@ -50,7 +50,7 @@ func TestLabelsCommonSet(t *testing.T) { func TestLabelsPropagateDown(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "myapp": "mycomponent", @@ -70,7 +70,7 @@ func TestLabelsPropagateDown(t *testing.T) { func TestSelectorLabels(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, diff --git a/internal/manifests/targetallocator/poddisruptionbudget.go b/internal/manifests/targetallocator/poddisruptionbudget.go index ed4a441500..f4e93869cc 100644 --- a/internal/manifests/targetallocator/poddisruptionbudget.go +++ b/internal/manifests/targetallocator/poddisruptionbudget.go @@ -17,7 +17,7 @@ package targetallocator import ( "fmt" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -35,7 +35,7 @@ func PodDisruptionBudget(params manifests.Params) (*policyV1.PodDisruptionBudget // defaulter doesn't set PodDisruptionBudget if the strategy isn't valid, // if PodDisruptionBudget != nil and stategy isn't correct, users have set // it wrongly - if params.OtelCol.Spec.TargetAllocator.AllocationStrategy != v1alpha2.TargetAllocatorAllocationStrategyConsistentHashing { + if params.OtelCol.Spec.TargetAllocator.AllocationStrategy != v1beta1.TargetAllocatorAllocationStrategyConsistentHashing { params.Log.V(4).Info("current allocation strategy not compatible, skipping podDisruptionBudget creation") return nil, fmt.Errorf("target allocator pdb has been configured but the allocation strategy isn't not compatible") } diff --git a/internal/manifests/targetallocator/poddisruptionbudget_test.go b/internal/manifests/targetallocator/poddisruptionbudget_test.go index 88a3097a1c..f15e552a69 100644 --- a/internal/manifests/targetallocator/poddisruptionbudget_test.go +++ b/internal/manifests/targetallocator/poddisruptionbudget_test.go @@ -21,7 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" ) @@ -66,17 +66,17 @@ var tests = []test{ func TestPDBWithValidStrategy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ - PodDisruptionBudget: &v1alpha2.PodDisruptionBudgetSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ + PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{ MinAvailable: test.MinAvailable, MaxUnavailable: test.MaxUnavailable, }, - AllocationStrategy: v1alpha2.TargetAllocatorAllocationStrategyConsistentHashing, + AllocationStrategy: v1beta1.TargetAllocatorAllocationStrategyConsistentHashing, }, }, } @@ -100,17 +100,17 @@ func TestPDBWithValidStrategy(t *testing.T) { func TestPDBWithNotValidStrategy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ - PodDisruptionBudget: &v1alpha2.PodDisruptionBudgetSpec{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ + PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{ MinAvailable: test.MinAvailable, MaxUnavailable: test.MaxUnavailable, }, - AllocationStrategy: v1alpha2.TargetAllocatorAllocationStrategyLeastWeighted, + AllocationStrategy: v1beta1.TargetAllocatorAllocationStrategyLeastWeighted, }, }, } @@ -129,13 +129,13 @@ func TestPDBWithNotValidStrategy(t *testing.T) { } func TestNoPDB(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ - AllocationStrategy: v1alpha2.TargetAllocatorAllocationStrategyLeastWeighted, + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ + AllocationStrategy: v1beta1.TargetAllocatorAllocationStrategyLeastWeighted, }, }, } diff --git a/internal/manifests/targetallocator/serviceaccount.go b/internal/manifests/targetallocator/serviceaccount.go index d9e0b1d3e6..6d29796c09 100644 --- a/internal/manifests/targetallocator/serviceaccount.go +++ b/internal/manifests/targetallocator/serviceaccount.go @@ -18,13 +18,13 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) // ServiceAccountName returns the name of the existing or self-provisioned service account to use for the given instance. -func ServiceAccountName(instance v1alpha2.OpenTelemetryCollector) string { +func ServiceAccountName(instance v1beta1.OpenTelemetryCollector) string { if len(instance.Spec.TargetAllocator.ServiceAccount) == 0 { return naming.TargetAllocatorServiceAccount(instance.Name) } diff --git a/internal/manifests/targetallocator/serviceaccount_test.go b/internal/manifests/targetallocator/serviceaccount_test.go index bf31c21422..4d469f2e9c 100644 --- a/internal/manifests/targetallocator/serviceaccount_test.go +++ b/internal/manifests/targetallocator/serviceaccount_test.go @@ -21,13 +21,13 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" ) func TestServiceAccountDefaultName(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -42,12 +42,12 @@ func TestServiceAccountDefaultName(t *testing.T) { func TestServiceAccountOverrideName(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ ServiceAccount: "my-special-sa", }, }, @@ -62,7 +62,7 @@ func TestServiceAccountOverrideName(t *testing.T) { func TestServiceAccountDefault(t *testing.T) { params := manifests.Params{ - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, @@ -86,12 +86,12 @@ func TestServiceAccountDefault(t *testing.T) { func TestServiceAccountOverride(t *testing.T) { params := manifests.Params{ - OtelCol: v1alpha2.OpenTelemetryCollector{ + OtelCol: v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - TargetAllocator: v1alpha2.TargetAllocatorEmbedded{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + TargetAllocator: v1beta1.TargetAllocatorEmbedded{ ServiceAccount: "my-special-sa", }, }, diff --git a/internal/manifests/targetallocator/servicemonitor_test.go b/internal/manifests/targetallocator/servicemonitor_test.go index acb704a102..ac5027e5ac 100644 --- a/internal/manifests/targetallocator/servicemonitor_test.go +++ b/internal/manifests/targetallocator/servicemonitor_test.go @@ -20,7 +20,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" @@ -28,16 +28,16 @@ import ( ) func TestDesiredServiceMonitors(t *testing.T) { - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "my-instance", Namespace: "my-namespace", }, - Spec: v1alpha2.OpenTelemetryCollectorSpec{ - OpenTelemetryCommonFields: v1alpha2.OpenTelemetryCommonFields{ + Spec: v1beta1.OpenTelemetryCollectorSpec{ + OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{ Tolerations: testTolerationValues, }, - Mode: v1alpha2.ModeStatefulSet, + Mode: v1beta1.ModeStatefulSet, }, } cfg := config.New() diff --git a/internal/manifests/targetallocator/volume.go b/internal/manifests/targetallocator/volume.go index e52a57297f..ee649e10d8 100644 --- a/internal/manifests/targetallocator/volume.go +++ b/internal/manifests/targetallocator/volume.go @@ -17,13 +17,13 @@ package targetallocator import ( corev1 "k8s.io/api/core/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) // Volumes builds the volumes for the given instance, including the config map volume. -func Volumes(cfg config.Config, otelcol v1alpha2.OpenTelemetryCollector) []corev1.Volume { +func Volumes(cfg config.Config, otelcol v1beta1.OpenTelemetryCollector) []corev1.Volume { volumes := []corev1.Volume{{ Name: naming.TAConfigMapVolume(), VolumeSource: corev1.VolumeSource{ diff --git a/internal/manifests/targetallocator/volume_test.go b/internal/manifests/targetallocator/volume_test.go index 76da542d12..3aecc91136 100644 --- a/internal/manifests/targetallocator/volume_test.go +++ b/internal/manifests/targetallocator/volume_test.go @@ -19,14 +19,14 @@ import ( "github.com/stretchr/testify/assert" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) func TestVolumeNewDefault(t *testing.T) { // prepare - otelcol := v1alpha2.OpenTelemetryCollector{} + otelcol := v1beta1.OpenTelemetryCollector{} cfg := config.New() // test diff --git a/internal/status/collector/handle.go b/internal/status/collector/handle.go index d1f1331aed..9620d37975 100644 --- a/internal/status/collector/handle.go +++ b/internal/status/collector/handle.go @@ -39,7 +39,7 @@ const ( // HandleReconcileStatus handles updating the status of the CRDs managed by the operator. // TODO: make the status more useful https://github.com/open-telemetry/opentelemetry-operator/issues/1972 -// TODO: update status to use v1alpha2 https://github.com/open-telemetry/opentelemetry-operator/milestone/4 +// TODO: update status to use v1beta1 https://github.com/open-telemetry/opentelemetry-operator/milestone/4 func HandleReconcileStatus(ctx context.Context, log logr.Logger, params manifests.Params, otelcol v1alpha1.OpenTelemetryCollector, err error) (ctrl.Result, error) { log.V(2).Info("updating collector status") if err != nil { diff --git a/pkg/sidecar/pod.go b/pkg/sidecar/pod.go index faae733236..445af47e47 100644 --- a/pkg/sidecar/pod.go +++ b/pkg/sidecar/pod.go @@ -21,7 +21,7 @@ import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -33,7 +33,7 @@ const ( ) // add a new sidecar container to the given pod, based on the given OpenTelemetryCollector. -func add(cfg config.Config, logger logr.Logger, otelcol v1alpha2.OpenTelemetryCollector, pod corev1.Pod, attributes []corev1.EnvVar) (corev1.Pod, error) { +func add(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTelemetryCollector, pod corev1.Pod, attributes []corev1.EnvVar) (corev1.Pod, error) { otelColCfg, err := collector.ReplaceConfig(otelcol) if err != nil { return pod, err diff --git a/pkg/sidecar/pod_test.go b/pkg/sidecar/pod_test.go index d030d370ae..920f3890fe 100644 --- a/pkg/sidecar/pod_test.go +++ b/pkg/sidecar/pod_test.go @@ -24,7 +24,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha2" + "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/api/convert" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" @@ -130,7 +130,7 @@ func TestAddSidecarWhenOneExistsAlready(t *testing.T) { }, }, } - otelcol := v1alpha2.OpenTelemetryCollector{} + otelcol := v1beta1.OpenTelemetryCollector{} cfg := config.New(config.WithCollectorImage("some-default-image")) // test @@ -219,7 +219,7 @@ func TestAddSidecarWithAditionalEnv(t *testing.T) { }, }, } - otelcol := v1alpha2.OpenTelemetryCollector{ + otelcol := v1beta1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Name: "otelcol-sample", Namespace: "some-app",