This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 4d248940a feat(trait): Provide the service type from the trait 
configuration
4d248940a is described below

commit 4d248940a283e81dce6fa9845001d032889baef6
Author: Nicolas Filotto <nfilo...@talend.com>
AuthorDate: Thu Sep 8 09:16:06 2022 +0200

    feat(trait): Provide the service type from the trait configuration
---
 .../camel.apache.org_integrationplatforms.yaml     | 16 ++++++--
 .../crd/bases/camel.apache.org_integrations.yaml   |  8 +++-
 .../bases/camel.apache.org_kameletbindings.yaml    |  8 +++-
 docs/modules/ROOT/partials/apis/camel-k-crds.adoc  | 18 +++++++++
 docs/modules/traits/pages/service.adoc             |  5 +++
 e2e/global/common/traits/service_test.go           | 45 ++++++++++++++++++++++
 helm/camel-k/crds/crd-integration-platform.yaml    | 16 ++++++--
 helm/camel-k/crds/crd-integration.yaml             |  8 +++-
 helm/camel-k/crds/crd-kamelet-binding.yaml         |  8 +++-
 pkg/apis/camel/v1/trait/service.go                 | 20 ++++++++++
 pkg/apis/camel/v1/trait/zz_generated.deepcopy.go   |  5 +++
 pkg/resources/resources.go                         | 16 ++++----
 pkg/trait/service.go                               | 21 ++++++++--
 resources/traits.yaml                              |  7 +++-
 14 files changed, 173 insertions(+), 28 deletions(-)

diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml 
b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
index 62eab915b..da49d6aad 100644
--- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml
+++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
@@ -1587,9 +1587,13 @@ spec:
                           traits share this common property.
                         type: boolean
                       nodePort:
-                        description: Enable Service to be exposed as NodePort 
(default
-                          `false`).
+                        description: 'Enable Service to be exposed as NodePort 
(default
+                          `false`). Deprecated: Use service type instead.'
                         type: boolean
+                      type:
+                        description: The type of service to be used, either 
'ClusterIP',
+                          'NodePort' or 'LoadBalancer'.
+                        type: string
                     type: object
                   service-binding:
                     description: The configuration of Service Binding trait
@@ -3220,9 +3224,13 @@ spec:
                           traits share this common property.
                         type: boolean
                       nodePort:
-                        description: Enable Service to be exposed as NodePort 
(default
-                          `false`).
+                        description: 'Enable Service to be exposed as NodePort 
(default
+                          `false`). Deprecated: Use service type instead.'
                         type: boolean
+                      type:
+                        description: The type of service to be used, either 
'ClusterIP',
+                          'NodePort' or 'LoadBalancer'.
+                        type: string
                     type: object
                   service-binding:
                     description: The configuration of Service Binding trait
diff --git a/config/crd/bases/camel.apache.org_integrations.yaml 
b/config/crd/bases/camel.apache.org_integrations.yaml
index b7219f9f7..e7c6616a6 100644
--- a/config/crd/bases/camel.apache.org_integrations.yaml
+++ b/config/crd/bases/camel.apache.org_integrations.yaml
@@ -7278,9 +7278,13 @@ spec:
                           traits share this common property.
                         type: boolean
                       nodePort:
-                        description: Enable Service to be exposed as NodePort 
(default
-                          `false`).
+                        description: 'Enable Service to be exposed as NodePort 
(default
+                          `false`). Deprecated: Use service type instead.'
                         type: boolean
+                      type:
+                        description: The type of service to be used, either 
'ClusterIP',
+                          'NodePort' or 'LoadBalancer'.
+                        type: string
                     type: object
                   service-binding:
                     description: The configuration of Service Binding trait
diff --git a/config/crd/bases/camel.apache.org_kameletbindings.yaml 
b/config/crd/bases/camel.apache.org_kameletbindings.yaml
index dbc4fc967..333b762a2 100644
--- a/config/crd/bases/camel.apache.org_kameletbindings.yaml
+++ b/config/crd/bases/camel.apache.org_kameletbindings.yaml
@@ -7578,9 +7578,13 @@ spec:
                               All traits share this common property.
                             type: boolean
                           nodePort:
-                            description: Enable Service to be exposed as 
NodePort
-                              (default `false`).
+                            description: 'Enable Service to be exposed as 
NodePort
+                              (default `false`). Deprecated: Use service type 
instead.'
                             type: boolean
+                          type:
+                            description: The type of service to be used, 
either 'ClusterIP',
+                              'NodePort' or 'LoadBalancer'.
+                            type: string
                         type: object
                       service-binding:
                         description: The configuration of Service Binding trait
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc 
b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 84a35694c..3b8ceab0e 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -5739,10 +5739,28 @@ bool
 
 
 Enable Service to be exposed as NodePort (default `false`).
+Deprecated: Use service type instead.
+
+|`type` +
+*xref:#_camel_apache_org_v1_trait_ServiceType[ServiceType]*
+|
+
+
+The type of service to be used, either 'ClusterIP', 'NodePort' or 
'LoadBalancer'.
 
 
 |===
 
+[#_camel_apache_org_v1_trait_ServiceType]
+=== ServiceType(`string` alias)
+
+*Appears on:*
+
+* <<#_camel_apache_org_v1_trait_ServiceTrait, ServiceTrait>>
+
+
+
+
 [#_camel_apache_org_v1_trait_TolerationTrait]
 === TolerationTrait
 
diff --git a/docs/modules/traits/pages/service.adoc 
b/docs/modules/traits/pages/service.adoc
index b79dcc728..896f6d67d 100755
--- a/docs/modules/traits/pages/service.adoc
+++ b/docs/modules/traits/pages/service.adoc
@@ -35,6 +35,11 @@ The following configuration options are available:
 | service.node-port
 | bool
 | Enable Service to be exposed as NodePort (default `false`).
+Deprecated: Use service type instead.
+
+| service.type
+| github.com/apache/camel-k/pkg/apis/camel/v1/trait.ServiceType
+| The type of service to be used, either 'ClusterIP', 'NodePort' or 
'LoadBalancer'.
 
 |===
 
diff --git a/e2e/global/common/traits/service_test.go 
b/e2e/global/common/traits/service_test.go
index 12ae21a56..1ae022531 100644
--- a/e2e/global/common/traits/service_test.go
+++ b/e2e/global/common/traits/service_test.go
@@ -65,5 +65,50 @@ func TestServiceTrait(t *testing.T) {
 
                        Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
                })
+
+               t.Run("NodePort service from Type", func(t *testing.T) {
+                       Expect(KamelRunWithID(operatorID, ns, 
"files/PlatformHttpServer.java",
+                               "-t", "service.enabled=true",
+                               "-t", 
"service.type=NodePort").Execute()).To(Succeed())
+                       Eventually(IntegrationPodPhase(ns, 
"platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+                       //
+                       // Service names can vary with the ExternalName Service
+                       // sometimes being created first and being given the 
root name
+                       //
+                       Eventually(ServicesByType(ns, 
corev1.ServiceTypeNodePort), TestTimeoutLong).ShouldNot(BeEmpty())
+
+                       Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
+               })
+
+               t.Run("ClusterIP service from Type", func(t *testing.T) {
+                       Expect(KamelRunWithID(operatorID, ns, 
"files/PlatformHttpServer.java",
+                               "-t", "service.enabled=true",
+                               "-t", 
"service.type=ClusterIP").Execute()).To(Succeed())
+                       Eventually(IntegrationPodPhase(ns, 
"platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+                       //
+                       // Service names can vary with the ExternalName Service
+                       // sometimes being created first and being given the 
root name
+                       //
+                       Eventually(ServicesByType(ns, 
corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())
+
+                       Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
+               })
+
+               t.Run("LoadBalancer service from Type", func(t *testing.T) {
+                       Expect(KamelRunWithID(operatorID, ns, 
"files/PlatformHttpServer.java",
+                               "-t", "service.enabled=true",
+                               "-t", 
"service.type=LoadBalancer").Execute()).To(Succeed())
+                       Eventually(IntegrationPodPhase(ns, 
"platform-http-server"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+
+                       //
+                       // Service names can vary with the ExternalName Service
+                       // sometimes being created first and being given the 
root name
+                       //
+                       Eventually(ServicesByType(ns, 
corev1.ServiceTypeLoadBalancer), TestTimeoutLong).ShouldNot(BeEmpty())
+
+                       Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
+               })
        })
 }
diff --git a/helm/camel-k/crds/crd-integration-platform.yaml 
b/helm/camel-k/crds/crd-integration-platform.yaml
index 62eab915b..da49d6aad 100644
--- a/helm/camel-k/crds/crd-integration-platform.yaml
+++ b/helm/camel-k/crds/crd-integration-platform.yaml
@@ -1587,9 +1587,13 @@ spec:
                           traits share this common property.
                         type: boolean
                       nodePort:
-                        description: Enable Service to be exposed as NodePort 
(default
-                          `false`).
+                        description: 'Enable Service to be exposed as NodePort 
(default
+                          `false`). Deprecated: Use service type instead.'
                         type: boolean
+                      type:
+                        description: The type of service to be used, either 
'ClusterIP',
+                          'NodePort' or 'LoadBalancer'.
+                        type: string
                     type: object
                   service-binding:
                     description: The configuration of Service Binding trait
@@ -3220,9 +3224,13 @@ spec:
                           traits share this common property.
                         type: boolean
                       nodePort:
-                        description: Enable Service to be exposed as NodePort 
(default
-                          `false`).
+                        description: 'Enable Service to be exposed as NodePort 
(default
+                          `false`). Deprecated: Use service type instead.'
                         type: boolean
+                      type:
+                        description: The type of service to be used, either 
'ClusterIP',
+                          'NodePort' or 'LoadBalancer'.
+                        type: string
                     type: object
                   service-binding:
                     description: The configuration of Service Binding trait
diff --git a/helm/camel-k/crds/crd-integration.yaml 
b/helm/camel-k/crds/crd-integration.yaml
index b7219f9f7..e7c6616a6 100644
--- a/helm/camel-k/crds/crd-integration.yaml
+++ b/helm/camel-k/crds/crd-integration.yaml
@@ -7278,9 +7278,13 @@ spec:
                           traits share this common property.
                         type: boolean
                       nodePort:
-                        description: Enable Service to be exposed as NodePort 
(default
-                          `false`).
+                        description: 'Enable Service to be exposed as NodePort 
(default
+                          `false`). Deprecated: Use service type instead.'
                         type: boolean
+                      type:
+                        description: The type of service to be used, either 
'ClusterIP',
+                          'NodePort' or 'LoadBalancer'.
+                        type: string
                     type: object
                   service-binding:
                     description: The configuration of Service Binding trait
diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml 
b/helm/camel-k/crds/crd-kamelet-binding.yaml
index dbc4fc967..333b762a2 100644
--- a/helm/camel-k/crds/crd-kamelet-binding.yaml
+++ b/helm/camel-k/crds/crd-kamelet-binding.yaml
@@ -7578,9 +7578,13 @@ spec:
                               All traits share this common property.
                             type: boolean
                           nodePort:
-                            description: Enable Service to be exposed as 
NodePort
-                              (default `false`).
+                            description: 'Enable Service to be exposed as 
NodePort
+                              (default `false`). Deprecated: Use service type 
instead.'
                             type: boolean
+                          type:
+                            description: The type of service to be used, 
either 'ClusterIP',
+                              'NodePort' or 'LoadBalancer'.
+                            type: string
                         type: object
                       service-binding:
                         description: The configuration of Service Binding trait
diff --git a/pkg/apis/camel/v1/trait/service.go 
b/pkg/apis/camel/v1/trait/service.go
index 83feadd2c..039567695 100644
--- a/pkg/apis/camel/v1/trait/service.go
+++ b/pkg/apis/camel/v1/trait/service.go
@@ -28,5 +28,25 @@ type ServiceTrait struct {
        // To automatically detect from the code if a Service needs to be 
created.
        Auto *bool `property:"auto" json:"auto,omitempty"`
        // Enable Service to be exposed as NodePort (default `false`).
+       // Deprecated: Use service type instead.
        NodePort *bool `property:"node-port" json:"nodePort,omitempty"`
+       // The type of service to be used, either 'ClusterIP', 'NodePort' or 
'LoadBalancer'.
+       Type *ServiceType `property:"type" json:"type,omitempty"`
 }
+
+type ServiceType string
+
+const (
+       // ServiceTypeClusterIP means a service will only be accessible inside 
the
+       // cluster, via the cluster IP.
+       ServiceTypeClusterIP ServiceType = "ClusterIP"
+
+       // ServiceTypeNodePort means a service will be exposed on one port of
+       // every node, in addition to 'ClusterIP' type.
+       ServiceTypeNodePort ServiceType = "NodePort"
+
+       // ServiceTypeLoadBalancer means a service will be exposed via an
+       // external load balancer (if the cloud provider supports it), in 
addition
+       // to 'NodePort' type.
+       ServiceTypeLoadBalancer ServiceType = "LoadBalancer"
+)
diff --git a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go 
b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go
index cab7a094d..f64b62a03 100644
--- a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go
@@ -942,6 +942,11 @@ func (in *ServiceTrait) DeepCopyInto(out *ServiceTrait) {
                *out = new(bool)
                **out = **in
        }
+       if in.Type != nil {
+               in, out := &in.Type, &out.Type
+               *out = new(ServiceType)
+               **out = **in
+       }
 }
 
 // DeepCopy is an autogenerated deepcopy function, copying the receiver, 
creating a new ServiceTrait.
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 1ce8e8c27..93dff2da0 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -138,23 +138,23 @@ var assets = func() http.FileSystem {
                "/crd/bases/camel.apache.org_integrationplatforms.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             
"camel.apache.org_integrationplatforms.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 177819,
+                       uncompressedSize: 178319,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\xfd\x73\xdb\x36\xb6\x30\x8e\xff\x9e\xbf\x02\xe3\xce\x9d\x38\x19\x49\x4e\xba\xb7\xbb\xbd\x7e\xa6\xf3\x3c\xae\x93\xb6\x6e\xe2\xd8\xd7\x76\x72\xef\x4e\xdb\xa9\x20\xf2\x48\x42\x4c\x02\x5c\x00\x94\xad\x7e\xf7\xfb\xbf\x7f\x06\x07\x00\x49\x49\x24\x48\x49\x7e\x6b\x23\x76\x66\x37\xb6\x09\xf0\xe0\xe0\xe0\xbc\xe1\xbc\x7c\x45\xfa\x77\xf7\x3c\xfb\x8a\xbc\x67\x11\x70\x05\x31\xd1\x82\xe8\x29\x90\xa3\x8c\x46\x53\x20\x97\x62\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\xfd\x73\xdb\x36\xb6\x30\x8e\xff\x9e\xbf\x02\xe3\xce\x1d\x3b\x19\x49\x4e\xba\xb7\xbb\xbd\x7e\xa6\xf3\x3c\xae\x93\xb6\x6e\xe2\xd8\xd7\x76\x72\xef\x4e\xdb\xa9\x20\xf2\x48\x42\x4c\x02\x5c\x00\x94\xa3\x7e\xf7\xfb\xbf\x7f\x06\x07\x00\x49\x49\x24\x48\x49\x7e\x6b\x23\x76\x66\x37\xb6\x09\xf0\xe0\xe0\xe0\xbc\xe1\xbc\x7c\x45\xfa\x77\xf7\x3c\xfb\x8a\xbc\x63\x11\x70\x05\x31\xd1\x82\xe8\x29\x90\xe3\x8c\x46\x53\x20\x57\x62\x
 [...]
                },
                "/crd/bases/camel.apache.org_integrations.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             "camel.apache.org_integrations.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 487275,
+                       uncompressedSize: 487525,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x7b\x73\x1b\x37\x96\x38\x0c\xff\xef\x4f\x81\x72\x52\x3f\x49\x1b\x91\xb2\x33\xb3\x53\x3b\x7e\xa7\x36\xa5\x91\xe4\x44\x6f\x6c\x99\x65\x29\xc9\x2f\xe5\x64\x13\xb0\x1b\x24\xb1\x6a\x02\x3d\x00\x9a\x12\xe7\xc9\xf3\xdd\x9f\xc2\x01\xd0\x17\xde\xfa\xa0\x45\x3a\xce\x4c\x63\xaa\x32\x26\xc5\x3e\x8d\xcb\xc1\xb9\x5f\x3e\x23\x83\xfd\x8d\x67\x9f\x91\x37\x3c\x61\x42\xb3\x94\x18\x49\xcc\x8c\x91\xf3\x9c\x26\x33\x46\x6e\xe5\xc4\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x7b\x73\x1b\x37\x96\x38\x0c\xff\xef\x4f\x81\x72\x52\x3f\x49\x1b\x91\xb2\x33\xb3\x53\x3b\x7e\xa7\x36\xa5\x91\xe4\x44\x6f\x6c\x99\x65\x29\xc9\x2f\xe5\x64\x13\xb0\x1b\x24\xb1\x6a\x02\x3d\x00\x9a\x12\xe7\xc9\xf3\xdd\x9f\xc2\x01\xd0\x17\xde\xfa\xa0\x45\x3a\xce\x4c\x63\xaa\x32\x26\xc5\x3e\x8d\xcb\xc1\xb9\x5f\x3e\x23\x83\xfd\x8d\x67\x9f\x91\x37\x3c\x61\x42\xb3\x94\x18\x49\xcc\x8c\x91\xf3\x9c\x26\x33\x46\x6e\xe5\xc4\x
 [...]
                },
                "/crd/bases/camel.apache.org_kameletbindings.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             
"camel.apache.org_kameletbindings.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 561145,
+                       uncompressedSize: 561411,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x7b\x73\x1b\x37\xb6\x28\x8a\xff\x9f\x4f\x81\x72\x52\x47\xd2\x8e\x48\xd9\x99\x47\xed\xf1\x6f\xea\xa4\xb4\x65\x39\xd1\x2f\xb1\xcc\xb2\x94\xe4\xa4\x9c\xec\x04\xec\x06\x49\x1c\x35\x81\xde\x00\x9a\x12\xe7\xe6\x7e\xf7\x5b\x58\x00\xba\xd1\x7c\x09\xab\x29\x69\xe4\x99\xc6\x54\x65\x4c\x8a\xbd\x1a\x8f\x85\xf5\x7e\x7c\x4e\x06\x0f\x37\x3e\xfb\x9c\x7c\xcf\x33\x26\x34\xcb\x89\x91\xc4\xcc\x18\x39\x2d\x69\x36\x63\xe4\x4a\x4e\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x7b\x73\x1b\x37\xb6\x28\x8a\xff\x9f\x4f\x81\x72\x52\x47\xd2\x8e\x48\xd9\x99\x47\xed\xf1\x6f\xea\xa4\xb4\x65\x39\xd1\x2f\xb1\xcc\xb2\x94\xe4\xa4\x9c\xec\x04\xec\x06\x49\x1c\x35\x81\xde\x00\x9a\x12\xe7\xe6\x7e\xf7\x5b\x58\x00\xba\xd1\x7c\x09\xab\x29\x69\xe4\x99\xc6\x54\x65\x4c\x8a\xbd\x1a\x8f\x85\xf5\x7e\x7c\x4e\x06\x0f\x37\x3e\xfb\x9c\x7c\xcf\x33\x26\x34\xcb\x89\x91\xc4\xcc\x18\x39\x2d\x69\x36\x63\xe4\x4a\x4e\x
 [...]
                },
                "/crd/bases/camel.apache.org_kamelets.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             "camel.apache.org_kamelets.yaml",
@@ -611,9 +611,9 @@ var assets = func() http.FileSystem {
                "/traits.yaml": &vfsgen۰CompressedFileInfo{
                        name:             "traits.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 53021,
+                       uncompressedSize: 53259,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xbd\x7b\x73\x1b\xb9\xb5\x20\xfe\xff\x7c\x0a\x94\xee\xef\x96\x25\x17\x49\x79\x26\x77\x72\xe7\xa7\xdd\xb9\x59\x8d\xed\x49\x34\xe3\x87\xd6\xf2\x4c\x6e\xca\xeb\x0a\xc1\x6e\x90\x84\xd9\x04\x3a\x00\x5a\x32\xb3\xd9\xef\xbe\x85\xf3\x00\xd0\x64\x4b\xa2\x6c\x6b\x36\xda\xda\x4c\x55\x2c\x92\xdd\xc0\xc1\xc1\x39\x07\xe7\x8d\xe0\xa4\x0e\xfe\xe4\xab\xb1\x30\x72\xad\x4e\xc4\xef\x7c\x25\x1b\xf5\x95\x10\x6d\x23\xc3\xdc\xba\xf5\x89\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xbd\xff\x73\x23\xb7\xb1\x20\xfe\xbb\xff\x0a\x94\xde\xe7\x95\xa4\x2d\x92\x92\x9d\xe7\x3c\x7f\x74\xe7\x97\x93\x77\xd7\x89\xec\xfd\xa2\x5b\xc9\xce\x4b\xed\x6d\x85\xe0\x0c\x48\x62\x39\x03\x4c\x00\x8c\xb4\xcc\xe5\xfe\xf7\x2b\x74\x37\xbe\xcc\x70\x28\x52\xbb\x92\x2f\xba\xba\xb8\x2a\x2b\x92\x33\x40\xa3\xd1\xdd\xe8\xef\x70\x86\x4b\x67\xcf\xbe\x1a\x33\xc5\x6b\x71\xc6\x7e\x67\x0b\x5e\x89\xaf\x18\x6b\x2a\xee\xe6\xda\xd4\x67\x
 [...]
                },
        }
        fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index d4211fb39..eb46b5cb5 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -18,6 +18,8 @@ limitations under the License.
 package trait
 
 import (
+       "fmt"
+
        corev1 "k8s.io/api/core/v1"
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/utils/pointer"
@@ -90,7 +92,6 @@ func (t *serviceTrait) Configure(e *Environment) (bool, 
error) {
                        return false, nil
                }
        }
-
        return true, nil
 }
 
@@ -100,9 +101,23 @@ func (t *serviceTrait) Apply(e *Environment) error {
        if svc == nil {
                svc = getServiceFor(e)
 
-               if pointer.BoolDeref(t.NodePort, false) {
-                       svc.Spec.Type = corev1.ServiceTypeNodePort
+               var serviceType corev1.ServiceType
+               if t.Type != nil {
+                       switch *t.Type {
+                       case traitv1.ServiceTypeClusterIP:
+                               serviceType = corev1.ServiceTypeClusterIP
+                       case traitv1.ServiceTypeNodePort:
+                               serviceType = corev1.ServiceTypeNodePort
+                       case traitv1.ServiceTypeLoadBalancer:
+                               serviceType = corev1.ServiceTypeLoadBalancer
+                       default:
+                               return fmt.Errorf("unsupported service type: 
%s", *t.Type)
+                       }
+               } else if pointer.BoolDeref(t.NodePort, false) {
+                       t.L.ForIntegration(e.Integration).Infof("Integration 
%s/%s should no more use the flag node-port as it is deprecated, use type 
instead", e.Integration.Namespace, e.Integration.Name)
+                       serviceType = corev1.ServiceTypeNodePort
                }
+               svc.Spec.Type = serviceType
        }
        e.Resources.Add(svc)
        return nil
diff --git a/resources/traits.yaml b/resources/traits.yaml
index a3d4246b9..429edb5fa 100755
--- a/resources/traits.yaml
+++ b/resources/traits.yaml
@@ -1183,7 +1183,12 @@ traits:
     description: To automatically detect from the code if a Service needs to 
be created.
   - name: node-port
     type: bool
-    description: Enable Service to be exposed as NodePort (default `false`).
+    description: 'Enable Service to be exposed as NodePort (default `false`). 
Deprecated:
+      Use service type instead.'
+  - name: type
+    type: github.com/apache/camel-k/pkg/apis/camel/v1/trait.ServiceType
+    description: The type of service to be used, either 'ClusterIP', 
'NodePort' or
+      'LoadBalancer'.
 - name: service-binding
   platform: false
   profiles:

Reply via email to