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

(#5635) Add TLS configuration in the ingress trait #5650

Merged
merged 3 commits into from
Jun 18, 2024
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
14 changes: 14 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7228,6 +7228,20 @@ bool
To automatically add an ingress whenever the integration uses an HTTP endpoint consumer.
|`tlsHosts` +
[]string
|
To configure tls hosts
|`tlsSecretName` +
string
|
To configure tls secret name
|===
Expand Down
8 changes: 8 additions & 0 deletions docs/modules/traits/pages/ingress.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ One of `Exact`, `Prefix`, `ImplementationSpecific` (default to `Prefix`).
| bool
| To automatically add an ingress whenever the integration uses an HTTP endpoint consumer.

| ingress.tls-hosts
| []string
| To configure tls hosts

| ingress.tls-secret-name
| string
| To configure tls secret name

|===

// End of autogenerated code - DO NOT EDIT! (configuration)
16 changes: 16 additions & 0 deletions helm/camel-k/crds/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down Expand Up @@ -3180,6 +3188,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
16 changes: 16 additions & 0 deletions helm/camel-k/crds/crd-integration-profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down Expand Up @@ -2940,6 +2948,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
8 changes: 8 additions & 0 deletions helm/camel-k/crds/crd-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7107,6 +7107,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
8 changes: 8 additions & 0 deletions helm/camel-k/crds/crd-kamelet-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7391,6 +7391,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
8 changes: 8 additions & 0 deletions helm/camel-k/crds/crd-pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7389,6 +7389,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/camel/v1/trait/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ type IngressTrait struct {
PathType *networkingv1.PathType `property:"path-type" json:"pathType,omitempty"`
// To automatically add an ingress whenever the integration uses an HTTP endpoint consumer.
Auto *bool `property:"auto" json:"auto,omitempty"`
// To configure tls hosts
TLSHosts []string `property:"tls-hosts" json:"tlsHosts,omitempty"`
// To configure tls secret name
TLSSecretName string `property:"tls-secret-name" json:"tlsSecretName,omitempty"`
}
5 changes: 5 additions & 0 deletions pkg/apis/camel/v1/trait/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 @@ -1166,6 +1166,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down Expand Up @@ -3180,6 +3188,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down Expand Up @@ -2940,6 +2948,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7107,6 +7107,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7391,6 +7391,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
8 changes: 8 additions & 0 deletions pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7389,6 +7389,14 @@ spec:
- Prefix
- ImplementationSpecific
type: string
tlsHosts:
description: To configure tls hosts
items:
type: string
type: array
tlsSecretName:
description: To configure tls secret name
type: string
type: object
istio:
description: The configuration of Istio trait
Expand Down
24 changes: 17 additions & 7 deletions pkg/trait/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import (
"errors"
"fmt"

v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"

v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
)

const (
Expand All @@ -44,10 +43,12 @@ func newIngressTrait() Trait {
return &ingressTrait{
BaseTrait: NewBaseTrait(ingressTraitID, ingressTraitOrder),
IngressTrait: traitv1.IngressTrait{
Annotations: map[string]string{},
Host: "",
Path: "/",
PathType: ptrFrom(networkingv1.PathTypePrefix),
Annotations: map[string]string{},
Host: "",
Path: "/",
PathType: ptrFrom(networkingv1.PathTypePrefix),
TLSHosts: []string{},
TLSSecretName: "",
},
}
}
Expand Down Expand Up @@ -126,6 +127,15 @@ func (t *ingressTrait) Apply(e *Environment) error {
},
}

if len(t.TLSHosts) > 0 && t.TLSSecretName != "" {
ingress.Spec.TLS = []networkingv1.IngressTLS{
{
Hosts: t.TLSHosts,
SecretName: t.TLSSecretName,
},
}
}

e.Resources.Add(&ingress)

message := fmt.Sprintf("%s(%s) -> %s(%s)", ingress.Name, t.Host, service.Name, "http")
Expand Down
Loading
Loading