Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds ingressClassName field to collector spec #1269

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apis/v1alpha1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ingressClassName</b></td>
<td>string</td>
<td>
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.<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#opentelemetrycollectorspecingresstlsindex">tls</a></b></td>
<td>[]object</td>
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/reconcile/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func desiredIngresses(_ context.Context, params Params) *networkingv1.Ingress {
},
},
},
IngressClassName: params.Instance.Spec.Ingress.IngressClassName,
},
}
}
Expand Down
16 changes: 9 additions & 7 deletions pkg/collector/reconcile/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -124,6 +125,7 @@ func TestDesiredIngresses(t *testing.T) {
},
},
Spec: networkingv1.IngressSpec{
IngressClassName: &ingressClassName,
Rules: []networkingv1.IngressRule{
{
Host: hostname,
Expand Down Expand Up @@ -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)
})
Expand Down