diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index 6db0579bc9..0aac34ca75 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -41,6 +41,12 @@ type Ingress struct { // TLS configuration. // +optional TLS []networkingv1.IngressTLS `json:"tls,omitempty"` + + // IngressClassName is the name of an IngressClass cluster resource. Ingress + // controller implementations use this field to know whether they should be + // serving this Ingress resource. + // +optional + IngressClassName *string `json:"ingressClassName,omitempty"` } // OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector. diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 1038386010..65bd3901d8 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -105,6 +105,11 @@ func (in *Ingress) DeepCopyInto(out *Ingress) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.IngressClassName != nil { + in, out := &in.IngressClassName, &out.IngressClassName + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Ingress. diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 21d8168cab..41d2e014ae 100644 --- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -1196,6 +1196,11 @@ spec: hostname: description: Hostname by which the ingress proxy can be reached. type: string + ingressClassName: + description: IngressClassName is the name of an IngressClass cluster + resource. Ingress controller implementations use this field + to know whether they should be serving this Ingress resource. + type: string tls: description: TLS configuration. items: diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 30ed3d3fa0..068df5d1ad 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -1194,6 +1194,11 @@ spec: hostname: description: Hostname by which the ingress proxy can be reached. type: string + ingressClassName: + description: IngressClassName is the name of an IngressClass cluster + resource. Ingress controller implementations use this field + to know whether they should be serving this Ingress resource. + type: string tls: description: TLS configuration. items: diff --git a/docs/api.md b/docs/api.md index 2bbc23e0af..87358baaf8 100644 --- a/docs/api.md +++ b/docs/api.md @@ -3827,6 +3827,13 @@ Ingress is used to specify how OpenTelemetry Collector is exposed. This function Hostname by which the ingress proxy can be reached.
false + + ingressClassName + string + + IngressClassName is the name of an IngressClass cluster resource. Ingress controller implementations use this field to know whether they should be serving this Ingress resource.
+ + false tls []object diff --git a/pkg/collector/reconcile/ingress.go b/pkg/collector/reconcile/ingress.go index 79576ebf74..ea82791120 100644 --- a/pkg/collector/reconcile/ingress.go +++ b/pkg/collector/reconcile/ingress.go @@ -118,6 +118,7 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress { }, }, }, + IngressClassName: params.Instance.Spec.Ingress.IngressClassName, }, } } diff --git a/pkg/collector/reconcile/ingress_test.go b/pkg/collector/reconcile/ingress_test.go index 2c3447c7f4..7324a14812 100644 --- a/pkg/collector/reconcile/ingress_test.go +++ b/pkg/collector/reconcile/ingress_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" - v1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -93,8 +92,9 @@ func TestDesiredIngresses(t *testing.T) { t.Run("should return nil unable to do something else", func(t *testing.T) { var ( - ns = "test" - hostname = "example.com" + ns = "test" + hostname = "example.com" + ingressClassName = "nginx" ) params, err := newParams("something:tag", test_file_ingress) @@ -104,9 +104,10 @@ func TestDesiredIngresses(t *testing.T) { params.Instance.Namespace = ns params.Instance.Spec.Ingress = v1alpha1.Ingress{ - Type: v1alpha1.IngressTypeNginx, - Hostname: hostname, - Annotations: map[string]string{"some.key": "some.value"}, + Type: v1alpha1.IngressTypeNginx, + Hostname: hostname, + Annotations: map[string]string{"some.key": "some.value"}, + IngressClassName: &ingressClassName, } got := desiredIngresses(context.Background(), params) @@ -124,6 +125,7 @@ func TestDesiredIngresses(t *testing.T) { }, }, Spec: networkingv1.IngressSpec{ + IngressClassName: &ingressClassName, Rules: []networkingv1.IngressRule{ { Host: hostname, @@ -243,7 +245,7 @@ func TestDeleteIngresses(t *testing.T) { } // check - exists, err = populateObjectIfExists(t, &v1.Ingress{}, nns) + exists, err = populateObjectIfExists(t, &networkingv1.Ingress{}, nns) assert.NoError(t, err) assert.False(t, exists) })