You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/09/02 16:05:38 UTC
[camel-k] 01/02: chore: Upgrade to networking.k8s.io/v1 Ingress API
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 7438d02a3245c7fbb398e486905c7e74e409f7e3
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Tue Mar 2 11:53:36 2021 +0100
chore: Upgrade to networking.k8s.io/v1 Ingress API
---
config/rbac/operator-role-kubernetes.yaml | 2 +-
helm/camel-k/templates/operator-role.yaml | 2 +-
pkg/resources/resources.go | 4 ++--
pkg/trait/ingress.go | 30 ++++++++++++++++--------------
pkg/trait/ingress_test.go | 14 +++++++-------
5 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/config/rbac/operator-role-kubernetes.yaml b/config/rbac/operator-role-kubernetes.yaml
index a285970..fda70ff 100644
--- a/config/rbac/operator-role-kubernetes.yaml
+++ b/config/rbac/operator-role-kubernetes.yaml
@@ -116,7 +116,7 @@ rules:
- list
- watch
- apiGroups:
- - extensions
+ - networking.k8s.io
resources:
- ingresses
verbs:
diff --git a/helm/camel-k/templates/operator-role.yaml b/helm/camel-k/templates/operator-role.yaml
index b5b1aad..8515705 100644
--- a/helm/camel-k/templates/operator-role.yaml
+++ b/helm/camel-k/templates/operator-role.yaml
@@ -129,7 +129,7 @@ rules:
- apiGroups:
- extensions
resources:
- - ingresses
+ - networking.k8s.io
verbs:
- create
- delete
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 53caeed..086d23e 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -283,9 +283,9 @@ var assets = func() http.FileSystem {
"/rbac/operator-role-kubernetes.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-kubernetes.yaml",
modTime: time.Time{},
- uncompressedSize: 2342,
+ uncompressedSize: 2349,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x55\xc1\x6e\xe3\x36\x10\xbd\xeb\x2b\x1e\xac\xcb\x6e\x11\xdb\x6d\x4f\x85\x7b\x72\x77\x93\xd6\xe8\xc2\x06\x22\x6f\x17\x7b\xa4\xa8\xb1\x3c\x0d\xc5\x61\x49\x2a\x8a\xfb\xf5\x05\x29\x7b\xd7\x59\x27\x40\x0e\x41\x5b\x5d\x3c\xa4\x86\x6f\xde\x9b\x37\xa6\x4a\x4c\x5f\xef\x29\x4a\x7c\x60\x4d\x36\x50\x83\x28\x88\x7b\xc2\xd2\x29\xbd\x27\x54\xb2\x8b\x83\xf2\x84\x1b\xe9\x6d\xa3\x22\x8b\xc5\x9b\x65\x75\xf3\x16\xbd\x6d\xc8\x43\x2c\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x55\xc1\x6e\xe3\x36\x10\xbd\xeb\x2b\x1e\xac\xcb\x6e\x11\xdb\x6d\x4f\x85\x7b\x72\x77\x93\xd6\xe8\xc2\x06\x22\x6f\x17\x7b\xa4\xa8\xb1\x3c\x0d\xc5\x61\x49\x2a\x8a\xfb\xf5\x05\x29\x7b\xd7\x59\x27\x40\x0e\x41\x5b\x5d\x3c\xa4\x46\x6f\xde\x9b\x79\x26\x4b\x4c\x5f\xef\x29\x4a\x7c\x60\x4d\x36\x50\x83\x28\x88\x7b\xc2\xd2\x29\xbd\x27\x54\xb2\x8b\x83\xf2\x84\x1b\xe9\x6d\xa3\x22\x8b\xc5\x9b\x65\x75\xf3\x16\xbd\x6d\xc8\x43\x2c\x [...]
},
"/rbac/operator-role-leases.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-leases.yaml",
diff --git a/pkg/trait/ingress.go b/pkg/trait/ingress.go
index c1f8207..dd0d565 100644
--- a/pkg/trait/ingress.go
+++ b/pkg/trait/ingress.go
@@ -21,13 +21,11 @@ import (
"errors"
"fmt"
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-
- "k8s.io/api/extensions/v1beta1"
- "k8s.io/apimachinery/pkg/util/intstr"
-
corev1 "k8s.io/api/core/v1"
+ networking "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
)
// The Ingress trait can be used to expose the service associated with the integration
@@ -108,21 +106,25 @@ func (t *ingressTrait) Apply(e *Environment) error {
return errors.New("cannot Apply ingress trait: no target service")
}
- ingress := v1beta1.Ingress{
+ ingress := networking.Ingress{
TypeMeta: metav1.TypeMeta{
Kind: "Ingress",
- APIVersion: v1beta1.SchemeGroupVersion.String(),
+ APIVersion: networking.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: service.Name,
Namespace: service.Namespace,
},
- Spec: v1beta1.IngressSpec{
- Backend: &v1beta1.IngressBackend{
- ServiceName: service.Name,
- ServicePort: intstr.FromString("http"),
+ Spec: networking.IngressSpec{
+ DefaultBackend: &networking.IngressBackend{
+ Service: &networking.IngressServiceBackend{
+ Name: service.Name,
+ Port: networking.ServiceBackendPort{
+ Name: "http",
+ },
+ },
},
- Rules: []v1beta1.IngressRule{
+ Rules: []networking.IngressRule{
{
Host: t.Host,
},
@@ -135,8 +137,8 @@ func (t *ingressTrait) Apply(e *Environment) error {
message := fmt.Sprintf("%s(%s) -> %s(%s)",
ingress.Name,
t.Host,
- ingress.Spec.Backend.ServiceName,
- ingress.Spec.Backend.ServicePort.String())
+ ingress.Spec.DefaultBackend.Service.Name,
+ ingress.Spec.DefaultBackend.Service.Port.Name)
e.Integration.Status.SetCondition(
v1.IntegrationConditionExposureAvailable,
diff --git a/pkg/trait/ingress_test.go b/pkg/trait/ingress_test.go
index b0f08ca..a0fb217 100644
--- a/pkg/trait/ingress_test.go
+++ b/pkg/trait/ingress_test.go
@@ -21,15 +21,15 @@ import (
"context"
"testing"
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
- "github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/stretchr/testify/assert"
- "k8s.io/api/extensions/v1beta1"
- "k8s.io/apimachinery/pkg/runtime"
-
corev1 "k8s.io/api/core/v1"
+ networking "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/runtime"
+
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/util/kubernetes"
)
func TestConfigureIngressTraitDoesSucceed(t *testing.T) {
@@ -139,10 +139,10 @@ func TestApplyIngressTraitDoesSucceed(t *testing.T) {
assert.Len(t, environment.Resources.Items(), 2)
environment.Resources.Visit(func(resource runtime.Object) {
- if ingress, ok := resource.(*v1beta1.Ingress); ok {
+ if ingress, ok := resource.(*networking.Ingress); ok {
assert.Equal(t, "service-name", ingress.Name)
assert.Equal(t, "namespace", ingress.Namespace)
- assert.Equal(t, "service-name", ingress.Spec.Backend.ServiceName)
+ assert.Equal(t, "service-name", ingress.Spec.DefaultBackend.Service.Name)
assert.Len(t, ingress.Spec.Rules, 1)
assert.Equal(t, "hostname", ingress.Spec.Rules[0].Host)
}