diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index 2eaf67a026..5b2ee5f0b9 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -25,7 +25,7 @@ import ( // functionality is only available if one of the valid modes is set. // Valid modes are: deployment, daemonset and statefulset. type Ingress struct { - // Type default value is: none + // Type default value is: "" // Supported types are: ingress Type IngressType `json:"type,omitempty"` diff --git a/apis/v1alpha1/opentelemetrycollector_webhook.go b/apis/v1alpha1/opentelemetrycollector_webhook.go index c52145d3c4..6c8c22ccdc 100644 --- a/apis/v1alpha1/opentelemetrycollector_webhook.go +++ b/apis/v1alpha1/opentelemetrycollector_webhook.go @@ -166,7 +166,7 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error { } - if r.Spec.Ingress.Type == IngressTypeNginx && (r.Spec.Mode != ModeDeployment || r.Spec.Mode == ModeDaemonSet || r.Spec.Mode == ModeStatefulSet) { + if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar { return fmt.Errorf("the OptenTelemetry Spec Ingress configuiration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", ModeDeployment, ModeDaemonSet, ModeStatefulSet, ) diff --git a/pkg/collector/reconcile/ingress.go b/pkg/collector/reconcile/ingress.go index df1ee04ee9..79576ebf74 100644 --- a/pkg/collector/reconcile/ingress.go +++ b/pkg/collector/reconcile/ingress.go @@ -35,10 +35,6 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress { if params.Instance.Spec.Ingress.Type != v1alpha1.IngressTypeNginx { return nil } - svcTarget := naming.Service(params.Instance) - hostname := params.Instance.Spec.Ingress.Hostname - tls := params.Instance.Spec.Ingress.TLS - ns := params.Instance.Namespace config, err := adapters.ConfigFromString(params.Instance.Spec.Config) if err != nil { @@ -89,7 +85,7 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress { PathType: &pathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ - Name: svcTarget, + Name: naming.Service(params.Instance), Port: networkingv1.ServiceBackendPort{ // Valid names must be non-empty and no more than 15 characters long. Name: naming.Truncate(p.Name, 15), @@ -102,7 +98,7 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress { return &networkingv1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: naming.Ingress(params.Instance), - Namespace: ns, + Namespace: params.Instance.Namespace, Annotations: params.Instance.Spec.Ingress.Annotations, Labels: map[string]string{ "app.kubernetes.io/name": naming.Ingress(params.Instance), @@ -111,10 +107,10 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress { }, }, Spec: networkingv1.IngressSpec{ - TLS: tls, + TLS: params.Instance.Spec.Ingress.TLS, Rules: []networkingv1.IngressRule{ { - Host: hostname, + Host: params.Instance.Spec.Ingress.Hostname, IngressRuleValue: networkingv1.IngressRuleValue{ HTTP: &networkingv1.HTTPIngressRuleValue{ Paths: paths,