[camel-k] branch master updated (89f3a29 -> 22fe728)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel-k] branch master updated (89f3a29 -> 22fe728)

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

astefanutti pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from 89f3a29  feat: Offer easier access to trait list
     new e93f01c  chore(trait): Rename Classpath trait to JVM trait
     new b9f5fb8  chore: Fix IntegrationKit kind variable
     new daedb24  chore(trait): Move JVM related configuration to the JVM trait
     new ada13cc  feat(JVM): Add a JVM options option to the JVM trait
     new 387ae53  chore(trait): Merge Debug trait into the JVM trait
     new c9ab8d2  feat(trait): Add options to configure JVM remote debugging
     new 22fe728  feat(JVM): Max heap size heuristic based on container memory limit

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/modules/ROOT/nav.adoc                         |   3 +-
 docs/modules/ROOT/pages/traits/classpath.adoc      |  31 ------
 .../ROOT/pages/traits/{quarkus.adoc => jvm.adoc}   |  32 +++---
 docs/modules/ROOT/pages/traits/traits.adoc         |   3 +-
 go.mod                                             |   1 +
 pkg/apis/camel/v1/integrationkit_types.go          |   4 +-
 pkg/apis/camel/v1/integrationkit_types_support.go  |   4 +-
 pkg/builder/builder_steps_test.go                  |   4 +-
 pkg/controller/integration/util_test.go            |  12 +--
 pkg/install/common.go                              |   2 +-
 pkg/trait/container.go                             |   7 +-
 pkg/trait/debug.go                                 |  58 -----------
 pkg/trait/debug_test.go                            | 111 ---------------------
 pkg/trait/{classpath.go => jvm.go}                 |  77 +++++++++++---
 pkg/trait/{classpath_test.go => jvm_test.go}       |  76 ++++++++++----
 pkg/trait/trait_catalog.go                         |  18 ++--
 pkg/trait/trait_test.go                            |   2 +-
 17 files changed, 165 insertions(+), 280 deletions(-)
 delete mode 100755 docs/modules/ROOT/pages/traits/classpath.adoc
 copy docs/modules/ROOT/pages/traits/{quarkus.adoc => jvm.adoc} (51%)
 delete mode 100644 pkg/trait/debug.go
 delete mode 100644 pkg/trait/debug_test.go
 rename pkg/trait/{classpath.go => jvm.go} (55%)
 rename pkg/trait/{classpath_test.go => jvm_test.go} (70%)

Reply | Threaded
Open this post in threaded view
|

[camel-k] 01/07: chore(trait): Rename Classpath trait to JVM trait

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

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

commit e93f01c6ae712a83ab76ccd94a8d47214ff28d8a
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Thu Jan 23 09:12:08 2020 +0100

    chore(trait): Rename Classpath trait to JVM trait
---
 docs/modules/ROOT/nav.adoc                         |  2 +-
 .../ROOT/pages/traits/{classpath.adoc => jvm.adoc} | 10 +++---
 docs/modules/ROOT/pages/traits/traits.adoc         |  2 +-
 pkg/trait/{classpath.go => jvm.go}                 | 18 +++++-----
 pkg/trait/{classpath_test.go => jvm_test.go}       | 39 +++++++++++-----------
 pkg/trait/trait_catalog.go                         | 12 +++----
 pkg/trait/trait_test.go                            |  2 +-
 7 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index fb4ee9d..1251e0a 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -19,7 +19,6 @@
 ** xref:traits/affinity.adoc[Affinity]
 ** xref:traits/builder.adoc[Builder]
 ** xref:traits/camel.adoc[Camel]
-** xref:traits/classpath.adoc[Classpath]
 ** xref:traits/container.adoc[Container]
 ** xref:traits/cron.adoc[Cron]
 ** xref:traits/debug.adoc[Debug]
@@ -31,6 +30,7 @@
 ** xref:traits/ingress.adoc[Ingress]
 ** xref:traits/istio.adoc[Istio]
 ** xref:traits/jolokia.adoc[Jolokia]
+** xref:traits/jvm.adoc[Jvm]
 ** xref:traits/knative-service.adoc[Knative Service]
 ** xref:traits/knative.adoc[Knative]
 ** xref:traits/owner.adoc[Owner]
diff --git a/docs/modules/ROOT/pages/traits/classpath.adoc b/docs/modules/ROOT/pages/traits/jvm.adoc
similarity index 68%
rename from docs/modules/ROOT/pages/traits/classpath.adoc
rename to docs/modules/ROOT/pages/traits/jvm.adoc
index 9b5f516..2ae6152 100755
--- a/docs/modules/ROOT/pages/traits/classpath.adoc
+++ b/docs/modules/ROOT/pages/traits/jvm.adoc
@@ -1,12 +1,12 @@
-= Classpath Trait
+= Jvm Trait
 
 // Start of autogenerated code - DO NOT EDIT! (description)
-The Classpath trait is used internally to configure the classpath of the final integration.
+The JVM trait is used to configure the JVM that runs the integration.
 
 
 This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
 
-WARNING: The classpath trait is a *platform trait*: disabling it may compromise the platform functionality.
+WARNING: The jvm trait is a *platform trait*: disabling it may compromise the platform functionality.
 
 // End of autogenerated code - DO NOT EDIT! (description)
 // Start of autogenerated code - DO NOT EDIT! (configuration)
@@ -14,7 +14,7 @@ WARNING: The classpath trait is a *platform trait*: disabling it may compromise
 
 Trait properties can be specified when running any integration with the CLI:
 ```
-kamel run --trait classpath.[key]=[value] integration.groovy
+kamel run --trait jvm.[key]=[value] integration.groovy
 ```
 The following configuration options are available:
 
@@ -22,7 +22,7 @@ The following configuration options are available:
 |===
 |Property | Type | Description
 
-| classpath.enabled
+| jvm.enabled
 | bool
 | Can be used to enable or disable a trait. All traits share this common property.
 
diff --git a/docs/modules/ROOT/pages/traits/traits.adoc b/docs/modules/ROOT/pages/traits/traits.adoc
index 44bc59e..efb3465 100644
--- a/docs/modules/ROOT/pages/traits/traits.adoc
+++ b/docs/modules/ROOT/pages/traits/traits.adoc
@@ -37,7 +37,6 @@ See the trait description pages for more information on a specific trait:
 * xref:traits/affinity.adoc[Affinity Trait]
 * xref:traits/builder.adoc[Builder Trait]
 * xref:traits/camel.adoc[Camel Trait]
-* xref:traits/classpath.adoc[Classpath Trait]
 * xref:traits/container.adoc[Container Trait]
 * xref:traits/cron.adoc[Cron Trait]
 * xref:traits/debug.adoc[Debug Trait]
@@ -49,6 +48,7 @@ See the trait description pages for more information on a specific trait:
 * xref:traits/ingress.adoc[Ingress Trait]
 * xref:traits/istio.adoc[Istio Trait]
 * xref:traits/jolokia.adoc[Jolokia Trait]
+* xref:traits/jvm.adoc[Jvm Trait]
 * xref:traits/knative-service.adoc[Knative Service Trait]
 * xref:traits/knative.adoc[Knative Trait]
 * xref:traits/owner.adoc[Owner Trait]
diff --git a/pkg/trait/classpath.go b/pkg/trait/jvm.go
similarity index 88%
rename from pkg/trait/classpath.go
rename to pkg/trait/jvm.go
index 71b7cc4..b143683 100644
--- a/pkg/trait/classpath.go
+++ b/pkg/trait/jvm.go
@@ -35,20 +35,20 @@ const (
  defaultMainClass = "org.apache.camel.k.main.Application"
 )
 
-// The Classpath trait is used internally to configure the classpath of the final integration.
+// The JVM trait is used to configure the JVM that runs the integration.
 //
-// +camel-k:trait=classpath
-type classpathTrait struct {
+// +camel-k:trait=jvm
+type jvmTrait struct {
  BaseTrait `property:",squash"`
 }
 
-func newClasspathTrait() *classpathTrait {
- return &classpathTrait{
- BaseTrait: newBaseTrait("classpath"),
+func newJvmTrait() *jvmTrait {
+ return &jvmTrait{
+ BaseTrait: newBaseTrait("jvm"),
  }
 }
 
-func (t *classpathTrait) Configure(e *Environment) (bool, error) {
+func (t *jvmTrait) Configure(e *Environment) (bool, error) {
  if t.Enabled != nil && !*t.Enabled {
  return false, nil
  }
@@ -57,7 +57,7 @@ func (t *classpathTrait) Configure(e *Environment) (bool, error) {
  e.InPhase(v1.IntegrationKitPhaseReady, v1.IntegrationPhaseRunning), nil
 }
 
-func (t *classpathTrait) Apply(e *Environment) error {
+func (t *jvmTrait) Apply(e *Environment) error {
  kit := e.IntegrationKit
 
  if kit == nil && e.Integration.Status.Kit != "" {
@@ -126,6 +126,6 @@ func (t *classpathTrait) Apply(e *Environment) error {
 }
 
 // IsPlatformTrait overrides base class method
-func (t *classpathTrait) IsPlatformTrait() bool {
+func (t *jvmTrait) IsPlatformTrait() bool {
  return true
 }
diff --git a/pkg/trait/classpath_test.go b/pkg/trait/jvm_test.go
similarity index 79%
rename from pkg/trait/classpath_test.go
rename to pkg/trait/jvm_test.go
index 5b12675..e480f06 100644
--- a/pkg/trait/classpath_test.go
+++ b/pkg/trait/jvm_test.go
@@ -22,29 +22,30 @@ import (
  "sort"
  "testing"
 
+ "github.com/scylladb/go-set/strset"
+ "github.com/stretchr/testify/assert"
+
  appsv1 "k8s.io/api/apps/v1"
  corev1 "k8s.io/api/core/v1"
  metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
  serving "knative.dev/serving/pkg/apis/serving/v1"
 
  v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
  "github.com/apache/camel-k/pkg/util/kubernetes"
  "github.com/apache/camel-k/pkg/util/test"
-
- "github.com/scylladb/go-set/strset"
- "github.com/stretchr/testify/assert"
 )
 
-func TestConfigureClasspathTraitInRightPhasesDoesSucceed(t *testing.T) {
- trait, environment := createNominalClasspathTest()
+func TestConfigureJvmTraitInRightPhasesDoesSucceed(t *testing.T) {
+ trait, environment := createNominalJvmTest()
 
  configured, err := trait.Configure(environment)
  assert.Nil(t, err)
  assert.True(t, configured)
 }
 
-func TestConfigureClasspathTraitInWrongIntegrationPhaseDoesNotSucceed(t *testing.T) {
- trait, environment := createNominalClasspathTest()
+func TestConfigureJvmTraitInWrongIntegrationPhaseDoesNotSucceed(t *testing.T) {
+ trait, environment := createNominalJvmTest()
  environment.Integration.Status.Phase = v1.IntegrationPhaseError
 
  configured, err := trait.Configure(environment)
@@ -52,8 +53,8 @@ func TestConfigureClasspathTraitInWrongIntegrationPhaseDoesNotSucceed(t *testing
  assert.False(t, configured)
 }
 
-func TestConfigureClasspathTraitInWrongIntegrationKitPhaseDoesNotSucceed(t *testing.T) {
- trait, environment := createNominalClasspathTest()
+func TestConfigureJvmTraitInWrongIntegrationKitPhaseDoesNotSucceed(t *testing.T) {
+ trait, environment := createNominalJvmTest()
  environment.IntegrationKit.Status.Phase = v1.IntegrationKitPhaseWaitingForPlatform
 
  configured, err := trait.Configure(environment)
@@ -61,8 +62,8 @@ func TestConfigureClasspathTraitInWrongIntegrationKitPhaseDoesNotSucceed(t *test
  assert.False(t, configured)
 }
 
-func TestConfigureClasspathDisabledTraitDoesNotSucceed(t *testing.T) {
- trait, environment := createNominalClasspathTest()
+func TestConfigureJvmDisabledTraitDoesNotSucceed(t *testing.T) {
+ trait, environment := createNominalJvmTest()
  trait.Enabled = new(bool)
 
  configured, err := trait.Configure(environment)
@@ -70,8 +71,8 @@ func TestConfigureClasspathDisabledTraitDoesNotSucceed(t *testing.T) {
  assert.False(t, configured)
 }
 
-func TestApplyClasspathTraitWithDeploymentResource(t *testing.T) {
- trait, environment := createNominalClasspathTest()
+func TestApplyJvmTraitWithDeploymentResource(t *testing.T) {
+ trait, environment := createNominalJvmTest()
 
  d := appsv1.Deployment{
  Spec: appsv1.DeploymentSpec{
@@ -108,8 +109,8 @@ func TestApplyClasspathTraitWithDeploymentResource(t *testing.T) {
  })
 }
 
-func TestApplyClasspathTraitWithKNativeResource(t *testing.T) {
- trait, environment := createNominalClasspathTest()
+func TestApplyJvmTraitWithKNativeResource(t *testing.T) {
+ trait, environment := createNominalJvmTest()
 
  s := serving.Service{}
  s.Spec.ConfigurationSpec.Template = serving.RevisionTemplateSpec{}
@@ -140,11 +141,11 @@ func TestApplyClasspathTraitWithKNativeResource(t *testing.T) {
  })
 }
 
-func createNominalClasspathTest() (*classpathTrait, *Environment) {
- return createClasspathTestWithKitType(v1.IntegrationKitTypePlatform)
+func createNominalJvmTest() (*jvmTrait, *Environment) {
+ return createJvmTestWithKitType(v1.IntegrationKitTypePlatform)
 }
 
-func createClasspathTestWithKitType(kitType string) (*classpathTrait, *Environment) {
+func createJvmTestWithKitType(kitType string) (*jvmTrait, *Environment) {
  client, _ := test.NewFakeClient(
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
@@ -161,7 +162,7 @@ func createClasspathTestWithKitType(kitType string) (*classpathTrait, *Environme
  },
  )
 
- trait := newClasspathTrait()
+ trait := newJvmTrait()
  enabled := true
  trait.Enabled = &enabled
  trait.ctx = context.TODO()
diff --git a/pkg/trait/trait_catalog.go b/pkg/trait/trait_catalog.go
index a045f30..81a3180 100644
--- a/pkg/trait/trait_catalog.go
+++ b/pkg/trait/trait_catalog.go
@@ -52,7 +52,7 @@ type Catalog struct {
  tBuilder          Trait
  tIstio            Trait
  tEnvironment      Trait
- tClasspath        Trait
+ tJvm              Trait
  tRestDsl          Trait
  tProbes           Trait
  tQuarkus          Trait
@@ -85,7 +85,7 @@ func NewCatalog(ctx context.Context, c client.Client) *Catalog {
  tBuilder:          newBuilderTrait(),
  tIstio:            newIstioTrait(),
  tEnvironment:      newEnvironmentTrait(),
- tClasspath:        newClasspathTrait(),
+ tJvm:              newJvmTrait(),
  tProbes:           newProbesTrait(),
  tQuarkus:          newQuarkusTrait(),
  tContainer:        newContainerTrait(),
@@ -126,7 +126,7 @@ func (c *Catalog) allTraits() []Trait {
  c.tBuilder,
  c.tIstio,
  c.tEnvironment,
- c.tClasspath,
+ c.tJvm,
  c.tProbes,
  c.tQuarkus,
  c.tContainer,
@@ -167,7 +167,7 @@ func (c *Catalog) TraitsForProfile(profile v1.TraitProfile) []Trait {
  c.tJolokia,
  c.tPrometheus,
  c.tDebug,
- c.tClasspath,
+ c.tJvm,
  c.tProbes,
  c.tRoute,
  c.tIstio,
@@ -193,7 +193,7 @@ func (c *Catalog) TraitsForProfile(profile v1.TraitProfile) []Trait {
  c.tJolokia,
  c.tPrometheus,
  c.tDebug,
- c.tClasspath,
+ c.tJvm,
  c.tProbes,
  c.tIngress,
  c.tIstio,
@@ -220,7 +220,7 @@ func (c *Catalog) TraitsForProfile(profile v1.TraitProfile) []Trait {
  c.tJolokia,
  c.tPrometheus,
  c.tDebug,
- c.tClasspath,
+ c.tJvm,
  c.tProbes,
  c.tIstio,
  c.tOwner,
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index bab4131..72a8da0 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -376,7 +376,7 @@ func TestOnlySomeTraitsInfluenceBuild(t *testing.T) {
 
 func TestOnlySomeTraitsArePlatform(t *testing.T) {
  c := NewTraitTestCatalog()
- platformTraits := []string{"builder", "camel", "classpath", "container", "dependencies", "deployer", "deployment", "environment", "rest-dsl", "owner", "platform"}
+ platformTraits := []string{"builder", "camel", "jvm", "container", "dependencies", "deployer", "deployment", "environment", "rest-dsl", "owner", "platform"}
 
  for _, trait := range c.allTraits() {
  if trait.IsPlatformTrait() {

Reply | Threaded
Open this post in threaded view
|

[camel-k] 02/07: chore: Fix IntegrationKit kind variable

astefanutti-2
In reply to this post by astefanutti-2
This is an automated email from the ASF dual-hosted git repository.

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

commit b9f5fb8e45c5e9518cc8ad9b010c7fc0ffa6870f
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Thu Jan 23 09:26:34 2020 +0100

    chore: Fix IntegrationKit kind variable
---
 pkg/apis/camel/v1/integrationkit_types.go         |  4 ++--
 pkg/apis/camel/v1/integrationkit_types_support.go |  4 ++--
 pkg/builder/builder_steps_test.go                 |  4 ++--
 pkg/controller/integration/util_test.go           | 12 ++++++------
 pkg/install/common.go                             |  2 +-
 pkg/trait/jvm_test.go                             |  2 +-
 6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/pkg/apis/camel/v1/integrationkit_types.go b/pkg/apis/camel/v1/integrationkit_types.go
index 5f3c046..e80cc89 100644
--- a/pkg/apis/camel/v1/integrationkit_types.go
+++ b/pkg/apis/camel/v1/integrationkit_types.go
@@ -79,8 +79,8 @@ type IntegrationKitPhase string
 type IntegrationKitConditionType string
 
 const (
- // IntegrationKindKind --
- IntegrationKindKind string = "IntegrationKit"
+ // IntegrationKitKind --
+ IntegrationKitKind string = "IntegrationKit"
 
  // IntegrationKitTypePlatform --
  IntegrationKitTypePlatform = "platform"
diff --git a/pkg/apis/camel/v1/integrationkit_types_support.go b/pkg/apis/camel/v1/integrationkit_types_support.go
index 9c78649..df3a95d 100644
--- a/pkg/apis/camel/v1/integrationkit_types_support.go
+++ b/pkg/apis/camel/v1/integrationkit_types_support.go
@@ -27,7 +27,7 @@ func NewIntegrationKit(namespace string, name string) IntegrationKit {
  return IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: SchemeGroupVersion.String(),
- Kind:       IntegrationKindKind,
+ Kind:       IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: namespace,
@@ -41,7 +41,7 @@ func NewIntegrationKitList() IntegrationKitList {
  return IntegrationKitList{
  TypeMeta: metav1.TypeMeta{
  APIVersion: SchemeGroupVersion.String(),
- Kind:       IntegrationKindKind,
+ Kind:       IntegrationKitKind,
  },
  }
 }
diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go
index 39c7ef2..a60744d 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -154,7 +154,7 @@ func TestListPublishedImages(t *testing.T) {
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
@@ -173,7 +173,7 @@ func TestListPublishedImages(t *testing.T) {
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
diff --git a/pkg/controller/integration/util_test.go b/pkg/controller/integration/util_test.go
index d7efedc..3f32dc6 100644
--- a/pkg/controller/integration/util_test.go
+++ b/pkg/controller/integration/util_test.go
@@ -34,7 +34,7 @@ func TestLookupKitForIntegration_DiscardKitsInError(t *testing.T) {
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
@@ -56,7 +56,7 @@ func TestLookupKitForIntegration_DiscardKitsInError(t *testing.T) {
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
@@ -110,7 +110,7 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
@@ -148,7 +148,7 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
@@ -181,7 +181,7 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
@@ -224,7 +224,7 @@ func TestLookupKitForIntegration_DiscardKitsWithIncompatibleTraits(t *testing.T)
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "ns",
diff --git a/pkg/install/common.go b/pkg/install/common.go
index 315c224..22fd6e7 100644
--- a/pkg/install/common.go
+++ b/pkg/install/common.go
@@ -95,7 +95,7 @@ func RuntimeObjectOrCollect(ctx context.Context, c client.Client, namespace stri
  return nil
  }
  // Don't recreate integration kits, platforms, etc
- if obj.GetObjectKind().GroupVersionKind().Kind == v1.IntegrationKindKind {
+ if obj.GetObjectKind().GroupVersionKind().Kind == v1.IntegrationKitKind {
  return nil
  }
  if obj.GetObjectKind().GroupVersionKind().Kind == v1.IntegrationPlatformKind {
diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go
index e480f06..57260db 100644
--- a/pkg/trait/jvm_test.go
+++ b/pkg/trait/jvm_test.go
@@ -150,7 +150,7 @@ func createJvmTestWithKitType(kitType string) (*jvmTrait, *Environment) {
  &v1.IntegrationKit{
  TypeMeta: metav1.TypeMeta{
  APIVersion: v1.SchemeGroupVersion.String(),
- Kind:       v1.IntegrationKindKind,
+ Kind:       v1.IntegrationKitKind,
  },
  ObjectMeta: metav1.ObjectMeta{
  Namespace: "kit-namespace",

Reply | Threaded
Open this post in threaded view
|

[camel-k] 03/07: chore(trait): Move JVM related configuration to the JVM trait

astefanutti-2
In reply to this post by astefanutti-2
This is an automated email from the ASF dual-hosted git repository.

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

commit daedb24ac4cfe71c9631dc628e7a451884d8aef8
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Thu Jan 23 09:29:33 2020 +0100

    chore(trait): Move JVM related configuration to the JVM trait
---
 pkg/trait/container.go | 7 +++----
 pkg/trait/jvm.go       | 7 ++++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index 02dd117..fb5d4c6 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -101,10 +101,9 @@ func (t *containerTrait) Configure(e *Environment) (bool, error) {
 
 func (t *containerTrait) Apply(e *Environment) error {
  container := corev1.Container{
- Name:    t.Name,
- Image:   e.Integration.Status.Image,
- Env:     make([]corev1.EnvVar, 0),
- Command: []string{"java"},
+ Name:  t.Name,
+ Image: e.Integration.Status.Image,
+ Env:   make([]corev1.EnvVar, 0),
  }
 
  // combine Environment of integration with platform, kit, integration
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index b143683..c09e46d 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -100,6 +100,10 @@ func (t *jvmTrait) Apply(e *Environment) error {
 
  container := e.getIntegrationContainer()
  if container != nil {
+ // Set the container command and working directory
+ container.Command = []string{"java"}
+ container.WorkingDir = "/deployments"
+
  // Add mounted resources to the class path
  for _, m := range container.VolumeMounts {
  classpath.Add(m.MountPath)
@@ -117,9 +121,6 @@ func (t *jvmTrait) Apply(e *Environment) error {
  } else {
  container.Args = append(container.Args, defaultMainClass)
  }
-
- // Set the container working directory
- container.WorkingDir = "/deployments"
  }
 
  return nil

Reply | Threaded
Open this post in threaded view
|

[camel-k] 04/07: feat(JVM): Add a JVM options option to the JVM trait

astefanutti-2
In reply to this post by astefanutti-2
This is an automated email from the ASF dual-hosted git repository.

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

commit ada13cc92a1facff00a4e665fdef222c22c2603f
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Thu Jan 23 14:48:33 2020 +0100

    feat(JVM): Add a JVM options option to the JVM trait
---
 docs/modules/ROOT/pages/traits/jvm.adoc | 6 +++++-
 pkg/trait/jvm.go                        | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/docs/modules/ROOT/pages/traits/jvm.adoc b/docs/modules/ROOT/pages/traits/jvm.adoc
index 2ae6152..530c1a7 100755
--- a/docs/modules/ROOT/pages/traits/jvm.adoc
+++ b/docs/modules/ROOT/pages/traits/jvm.adoc
@@ -14,7 +14,7 @@ WARNING: The jvm trait is a *platform trait*: disabling it may compromise the pl
 
 Trait properties can be specified when running any integration with the CLI:
 ```
-kamel run --trait jvm.[key]=[value] integration.groovy
+kamel run --trait jvm.[key]=[value] --trait jvm.[key2]=[value2] integration.groovy
 ```
 The following configuration options are available:
 
@@ -26,6 +26,10 @@ The following configuration options are available:
 | bool
 | Can be used to enable or disable a trait. All traits share this common property.
 
+| jvm.options
+| string
+| A comma-separated list of JVM options
+
 |===
 
 // End of autogenerated code - DO NOT EDIT! (configuration)
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index c09e46d..348e093 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -40,6 +40,9 @@ const (
 // +camel-k:trait=jvm
 type jvmTrait struct {
  BaseTrait `property:",squash"`
+
+ // A comma-separated list of JVM options
+ Options *string `property:"options"`
 }
 
 func newJvmTrait() *jvmTrait {
@@ -104,6 +107,11 @@ func (t *jvmTrait) Apply(e *Environment) error {
  container.Command = []string{"java"}
  container.WorkingDir = "/deployments"
 
+ // Add JVM options
+ if t.Options != nil {
+ container.Args = append(container.Args, strings.Split(*t.Options, ",")...)
+ }
+
  // Add mounted resources to the class path
  for _, m := range container.VolumeMounts {
  classpath.Add(m.MountPath)

Reply | Threaded
Open this post in threaded view
|

[camel-k] 05/07: chore(trait): Merge Debug trait into the JVM trait

astefanutti-2
In reply to this post by astefanutti-2
This is an automated email from the ASF dual-hosted git repository.

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

commit 387ae53fcc42dfefb801ac9eec68f7cf7af17544
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Thu Jan 23 15:19:45 2020 +0100

    chore(trait): Merge Debug trait into the JVM trait
---
 docs/modules/ROOT/nav.adoc                 |   1 -
 docs/modules/ROOT/pages/traits/jvm.adoc    |   4 ++
 docs/modules/ROOT/pages/traits/traits.adoc |   1 -
 pkg/trait/debug.go                         |  58 ---------------
 pkg/trait/debug_test.go                    | 111 -----------------------------
 pkg/trait/jvm.go                           |   8 ++-
 pkg/trait/trait_catalog.go                 |   6 --
 7 files changed, 11 insertions(+), 178 deletions(-)

diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 1251e0a..318f21a 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -21,7 +21,6 @@
 ** xref:traits/camel.adoc[Camel]
 ** xref:traits/container.adoc[Container]
 ** xref:traits/cron.adoc[Cron]
-** xref:traits/debug.adoc[Debug]
 ** xref:traits/dependencies.adoc[Dependencies]
 ** xref:traits/deployer.adoc[Deployer]
 ** xref:traits/deployment.adoc[Deployment]
diff --git a/docs/modules/ROOT/pages/traits/jvm.adoc b/docs/modules/ROOT/pages/traits/jvm.adoc
index 530c1a7..bdbe13c 100755
--- a/docs/modules/ROOT/pages/traits/jvm.adoc
+++ b/docs/modules/ROOT/pages/traits/jvm.adoc
@@ -26,6 +26,10 @@ The following configuration options are available:
 | bool
 | Can be used to enable or disable a trait. All traits share this common property.
 
+| jvm.debug
+| bool
+| Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding
+
 | jvm.options
 | string
 | A comma-separated list of JVM options
diff --git a/docs/modules/ROOT/pages/traits/traits.adoc b/docs/modules/ROOT/pages/traits/traits.adoc
index efb3465..f0c4b24 100644
--- a/docs/modules/ROOT/pages/traits/traits.adoc
+++ b/docs/modules/ROOT/pages/traits/traits.adoc
@@ -39,7 +39,6 @@ See the trait description pages for more information on a specific trait:
 * xref:traits/camel.adoc[Camel Trait]
 * xref:traits/container.adoc[Container Trait]
 * xref:traits/cron.adoc[Cron Trait]
-* xref:traits/debug.adoc[Debug Trait]
 * xref:traits/dependencies.adoc[Dependencies Trait]
 * xref:traits/deployer.adoc[Deployer Trait]
 * xref:traits/deployment.adoc[Deployment Trait]
diff --git a/pkg/trait/debug.go b/pkg/trait/debug.go
deleted file mode 100644
index 38d3c5f..0000000
--- a/pkg/trait/debug.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package trait
-
-import (
- "fmt"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
-)
-
-// The Debug trait can be used to enable debugging on the integration container,
-// so that a remote debugger can be attached.
-//
-// +camel-k:trait=debug
-type debugTrait struct {
- BaseTrait `property:",squash"`
-}
-
-func newDebugTrait() *debugTrait {
- return &debugTrait{
- BaseTrait: newBaseTrait("debug"),
- }
-}
-
-func (t *debugTrait) Configure(e *Environment) (bool, error) {
- if t.Enabled != nil && *t.Enabled {
- return e.IntegrationInPhase(v1.IntegrationPhaseDeploying, v1.IntegrationPhaseRunning), nil
- }
-
- return false, nil
-}
-
-func (t *debugTrait) Apply(e *Environment) error {
- container := e.getIntegrationContainer()
- if container == nil {
- return fmt.Errorf("unable to find integration container")
- }
-
- // TODO: Add options to configure debugging agent
- container.Args = append(container.Args, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")
-
- return nil
-}
diff --git a/pkg/trait/debug_test.go b/pkg/trait/debug_test.go
deleted file mode 100644
index 32b3e1d..0000000
--- a/pkg/trait/debug_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package trait
-
-import (
- "context"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- appsv1 "k8s.io/api/apps/v1"
- corev1 "k8s.io/api/core/v1"
-
- v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
- "github.com/apache/camel-k/pkg/util/camel"
- "github.com/apache/camel-k/pkg/util/kubernetes"
-)
-
-func TestDebugTraitApplicability(t *testing.T) {
- catalog, err := camel.DefaultCatalog()
- assert.Nil(t, err)
-
- env := Environment{
- CamelCatalog: catalog,
- Integration: &v1.Integration{
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseDeploying,
- },
- Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "debug": {
- Configuration: map[string]string{
- "enabled": "true",
- },
- },
- },
- },
- },
- }
-
- trait := newDebugTrait()
-
- enabled, err := trait.Configure(&env)
- assert.Nil(t, err)
- assert.False(t, enabled)
-
- env.Integration.Status.Phase = v1.IntegrationPhaseRunning
-
- enabled, err = trait.Configure(&env)
- assert.Nil(t, err)
- assert.False(t, enabled)
-}
-
-func TestApplyDebugTrait(t *testing.T) {
- environment := Environment{
- Catalog: NewCatalog(context.TODO(), nil),
- Integration: &v1.Integration{
- Status: v1.IntegrationStatus{
- Phase: v1.IntegrationPhaseDeploying,
- },
- Spec: v1.IntegrationSpec{
- Traits: map[string]v1.TraitSpec{
- "debug": {
- Configuration: map[string]string{
- "enabled": "true",
- },
- },
- },
- },
- },
- Resources: kubernetes.NewCollection(),
- }
-
- d := appsv1.Deployment{
- Spec: appsv1.DeploymentSpec{
- Template: corev1.PodTemplateSpec{
- Spec: corev1.PodSpec{
- Containers: []corev1.Container{
- {
- Name: defaultContainerName,
- },
- },
- },
- },
- },
- }
-
- environment.Resources.Add(&d)
-
- trait := newDebugTrait()
-
- assert.Nil(t, trait.Apply(&environment))
- assert.Equal(t, d.Spec.Template.Spec.Containers[0].Args, []string{
- "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005",
- })
-}
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 348e093..b5ece60 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -40,7 +40,8 @@ const (
 // +camel-k:trait=jvm
 type jvmTrait struct {
  BaseTrait `property:",squash"`
-
+ // Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding
+ Debug bool `property:"debug"`
  // A comma-separated list of JVM options
  Options *string `property:"options"`
 }
@@ -107,6 +108,11 @@ func (t *jvmTrait) Apply(e *Environment) error {
  container.Command = []string{"java"}
  container.WorkingDir = "/deployments"
 
+ if t.Debug {
+ // TODO: Add options to configure debugging agent
+ container.Args = append(container.Args, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")
+ }
+
  // Add JVM options
  if t.Options != nil {
  container.Args = append(container.Args, strings.Split(*t.Options, ",")...)
diff --git a/pkg/trait/trait_catalog.go b/pkg/trait/trait_catalog.go
index 81a3180..41d0fea 100644
--- a/pkg/trait/trait_catalog.go
+++ b/pkg/trait/trait_catalog.go
@@ -35,7 +35,6 @@ type Catalog struct {
  tPlatform         Trait
  tAffinity         Trait
  tCamel            Trait
- tDebug            Trait
  tDependencies     Trait
  tDeployer         Trait
  tCron             Trait
@@ -67,7 +66,6 @@ func NewCatalog(ctx context.Context, c client.Client) *Catalog {
  tPlatform:         newPlatformTrait(),
  tAffinity:         newAffinityTrait(),
  tCamel:            newCamelTrait(),
- tDebug:            newDebugTrait(),
  tRestDsl:          newRestDslTrait(),
  tKnative:          newKnativeTrait(),
  tDependencies:     newDependenciesTrait(),
@@ -108,7 +106,6 @@ func (c *Catalog) allTraits() []Trait {
  c.tPlatform,
  c.tAffinity,
  c.tCamel,
- c.tDebug,
  c.tRestDsl,
  c.tKnative,
  c.tDependencies,
@@ -166,7 +163,6 @@ func (c *Catalog) TraitsForProfile(profile v1.TraitProfile) []Trait {
  c.tPullSecret,
  c.tJolokia,
  c.tPrometheus,
- c.tDebug,
  c.tJvm,
  c.tProbes,
  c.tRoute,
@@ -192,7 +188,6 @@ func (c *Catalog) TraitsForProfile(profile v1.TraitProfile) []Trait {
  c.tPullSecret,
  c.tJolokia,
  c.tPrometheus,
- c.tDebug,
  c.tJvm,
  c.tProbes,
  c.tIngress,
@@ -219,7 +214,6 @@ func (c *Catalog) TraitsForProfile(profile v1.TraitProfile) []Trait {
  c.tPullSecret,
  c.tJolokia,
  c.tPrometheus,
- c.tDebug,
  c.tJvm,
  c.tProbes,
  c.tIstio,

Reply | Threaded
Open this post in threaded view
|

[camel-k] 06/07: feat(trait): Add options to configure JVM remote debugging

astefanutti-2
In reply to this post by astefanutti-2
This is an automated email from the ASF dual-hosted git repository.

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

commit c9ab8d26c32ac81676a146f9865efbe9598cd532
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Thu Jan 23 15:56:12 2020 +0100

    feat(trait): Add options to configure JVM remote debugging
---
 docs/modules/ROOT/pages/traits/jvm.adoc |  8 ++++++++
 pkg/trait/jvm.go                        | 16 +++++++++++++--
 pkg/trait/jvm_test.go                   | 35 +++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/docs/modules/ROOT/pages/traits/jvm.adoc b/docs/modules/ROOT/pages/traits/jvm.adoc
index bdbe13c..8dbfad4 100755
--- a/docs/modules/ROOT/pages/traits/jvm.adoc
+++ b/docs/modules/ROOT/pages/traits/jvm.adoc
@@ -30,6 +30,14 @@ The following configuration options are available:
 | bool
 | Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding
 
+| jvm.debug-suspend
+| bool
+| Suspends the target JVM immediately before the main class is loaded
+
+| jvm.debug-address
+| string
+| Transport address at which to listen for the newly launched JVM
+
 | jvm.options
 | string
 | A comma-separated list of JVM options
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index b5ece60..b1a783b 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -42,6 +42,10 @@ type jvmTrait struct {
  BaseTrait `property:",squash"`
  // Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding
  Debug bool `property:"debug"`
+ // Suspends the target JVM immediately before the main class is loaded
+ DebugSuspend bool `property:"debug-suspend"`
+ // Transport address at which to listen for the newly launched JVM
+ DebugAddress string `property:"debug-address"`
  // A comma-separated list of JVM options
  Options *string `property:"options"`
 }
@@ -49,6 +53,8 @@ type jvmTrait struct {
 func newJvmTrait() *jvmTrait {
  return &jvmTrait{
  BaseTrait: newBaseTrait("jvm"),
+ // To be defaulted to "*:5005" when upgrading the default base image to JDK9+
+ DebugAddress: "5005",
  }
 }
 
@@ -108,9 +114,15 @@ func (t *jvmTrait) Apply(e *Environment) error {
  container.Command = []string{"java"}
  container.WorkingDir = "/deployments"
 
+ // Remote debugging
  if t.Debug {
- // TODO: Add options to configure debugging agent
- container.Args = append(container.Args, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")
+ suspend := "n"
+ if t.DebugSuspend {
+ suspend = "y"
+ }
+ container.Args = append(container.Args,
+ fmt.Sprintf("-agentlib:jdwp=transport=dt_socket,server=y,suspend=%s,address=%s",
+ suspend, t.DebugAddress))
  }
 
  // Add JVM options
diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go
index 57260db..e180202 100644
--- a/pkg/trait/jvm_test.go
+++ b/pkg/trait/jvm_test.go
@@ -141,6 +141,41 @@ func TestApplyJvmTraitWithKNativeResource(t *testing.T) {
  })
 }
 
+func TestApplyJvmTraitWithDebugEnabled(t *testing.T) {
+ trait, environment := createNominalJvmTest()
+ trait.Debug = true
+ trait.DebugSuspend = true
+
+ d := appsv1.Deployment{
+ Spec: appsv1.DeploymentSpec{
+ Template: corev1.PodTemplateSpec{
+ Spec: corev1.PodSpec{
+ Containers: []corev1.Container{
+ {
+ Name: defaultContainerName,
+ VolumeMounts: []corev1.VolumeMount{
+ {
+ MountPath: "/mount/path",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ environment.Resources.Add(&d)
+
+ err := trait.Apply(environment)
+
+ assert.Nil(t, err)
+
+ assert.Contains(t, d.Spec.Template.Spec.Containers[0].Args,
+ "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005",
+ )
+}
+
 func createNominalJvmTest() (*jvmTrait, *Environment) {
  return createJvmTestWithKitType(v1.IntegrationKitTypePlatform)
 }

Reply | Threaded
Open this post in threaded view
|

[camel-k] 07/07: feat(JVM): Max heap size heuristic based on container memory limit

astefanutti-2
In reply to this post by astefanutti-2
This is an automated email from the ASF dual-hosted git repository.

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

commit 22fe7285a8adb24159a970a9e0d57da78bb84813
Author: Antonin Stefanutti <[hidden email]>
AuthorDate: Fri Jan 24 16:31:16 2020 +0100

    feat(JVM): Max heap size heuristic based on container memory limit
---
 go.mod           |  1 +
 pkg/trait/jvm.go | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/go.mod b/go.mod
index ac7aa1e..07f35d9 100644
--- a/go.mod
+++ b/go.mod
@@ -32,6 +32,7 @@ require (
  github.com/stoewer/go-strcase v1.0.2
  github.com/stretchr/testify v1.4.0
  go.uber.org/multierr v1.1.0
+ gopkg.in/inf.v0 v0.9.1
  gopkg.in/yaml.v2 v2.2.4
  k8s.io/api v0.0.0
  k8s.io/apimachinery v0.0.0
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index b1a783b..89f3710 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -22,9 +22,14 @@ import (
  "sort"
  "strings"
 
+ "gopkg.in/inf.v0"
+
  "github.com/pkg/errors"
  "github.com/scylladb/go-set/strset"
 
+ corev1 "k8s.io/api/core/v1"
+ "k8s.io/apimachinery/pkg/api/resource"
+
  k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 
  v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
@@ -125,11 +130,32 @@ func (t *jvmTrait) Apply(e *Environment) error {
  suspend, t.DebugAddress))
  }
 
+ hasHeapSizeOption := false
  // Add JVM options
  if t.Options != nil {
+ hasHeapSizeOption = strings.Contains(*t.Options, "-Xmx") ||
+ strings.Contains(*t.Options, "-XX:MaxHeapSize") ||
+ strings.Contains(*t.Options, "-XX:MinRAMPercentage") ||
+ strings.Contains(*t.Options, "-XX:MaxRAMPercentage")
+
  container.Args = append(container.Args, strings.Split(*t.Options, ",")...)
  }
 
+ // Tune JVM maximum heap size based on the container memory limit, if any.
+ // This is configured off-container, thus is limited to explicit user configuration.
+ // We may want to inject a wrapper script into the container image, so that it can
+ // be performed in-container, based on CGroups memory resource control files.
+ if memory, hasLimit := container.Resources.Limits[corev1.ResourceMemory]; !hasHeapSizeOption && hasLimit {
+ // Simple heuristic that caps the maximum heap size to 50% of the memory limit
+ percentage := int64(50)
+ // Unless the memory limit is lower than 300M, in which case we leave more room for the non-heap memory
+ if resource.NewScaledQuantity(300, 6).Cmp(memory) > 0 {
+ percentage = 25
+ }
+ memory.AsDec().Mul(memory.AsDec(), inf.NewDec(percentage, 2))
+ container.Args = append(container.Args, fmt.Sprintf("-Xmx%dM", memory.ScaledValue(resource.Mega)))
+ }
+
  // Add mounted resources to the class path
  for _, m := range container.VolumeMounts {
  classpath.Add(m.MountPath)