Skip to content

Commit

Permalink
Make integration podspec-able
Browse files Browse the repository at this point in the history
reflect changes in the pod trait
  • Loading branch information
mmelko committed Apr 28, 2021
1 parent 49c174d commit 37eb18f
Show file tree
Hide file tree
Showing 24 changed files with 47,030 additions and 86 deletions.
5,133 changes: 5,133 additions & 0 deletions config/crd/bases/camel.apache.org_integrations.yaml

Large diffs are not rendered by default.

5,388 changes: 5,388 additions & 0 deletions config/crd/bases/camel.apache.org_kameletbindings.yaml

Large diffs are not rendered by default.

5,133 changes: 5,133 additions & 0 deletions deploy/olm-catalog/camel-k-dev/1.4.0/camel.apache.org_integrations.yaml

Large diffs are not rendered by default.

5,388 changes: 5,388 additions & 0 deletions deploy/olm-catalog/camel-k-dev/1.4.0/camel.apache.org_kameletbindings.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions deploy/traits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,18 @@ traits:
type: bool
description: To automatically detect from the environment if a default platform
can be created (it will be created on OpenShift only).
- name: pod
platform: false
profiles:
- Kubernetes
- Knative
- OpenShift
description: The pod trait allows the customization of the Integration pods. It
applies the `PodSpecTemplate` struct contained in the Integration `.spec.podTemplate`
field, into the Integration deployment Pods template, using strategic merge patch.
This can be used to customize the container where Camel routes execute, by using
the `integration` container name.
properties: []
- name: prometheus
platform: false
profiles:
Expand Down
4,528 changes: 4,528 additions & 0 deletions docs/modules/ROOT/assets/attachments/schema/integration-schema.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
** xref:traits:owner.adoc[Owner]
** xref:traits:pdb.adoc[Pdb]
** xref:traits:platform.adoc[Platform]
** xref:traits:pod.adoc[Pod]
** xref:traits:prometheus.adoc[Prometheus]
** xref:traits:pull-secret.adoc[Pull Secret]
** xref:traits:quarkus.adoc[Quarkus]
Expand Down
33 changes: 33 additions & 0 deletions docs/modules/traits/pages/pod.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
= Pod Trait

// Start of autogenerated code - DO NOT EDIT! (description)
The pod trait allows the customization of the Integration pods.
It applies the `PodSpecTemplate` struct contained in the Integration `.spec.podTemplate` field, into the Integration deployment Pods template, using strategic merge patch.

This can be used to customize the container where Camel routes execute, by using the `integration` container name.


This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.

// End of autogenerated code - DO NOT EDIT! (description)
// Start of autogenerated code - DO NOT EDIT! (configuration)
== Configuration

Trait properties can be specified when running any integration with the CLI:
[source,console]
----
$ kamel run --trait pod.[key]=[value] integration.groovy
----
The following configuration options are available:

[cols="2m,1m,5a"]
|===
|Property | Type | Description

| pod.enabled
| bool
| Can be used to enable or disable a trait. All traits share this common property.

|===

// End of autogenerated code - DO NOT EDIT! (configuration)
5 changes: 5 additions & 0 deletions e2e/common/traits/files/PodTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// camel-k: language=groovy
from('file:///var/log')
.convertBodyTo(String.class)
.routeId('groovy')
.to('log:info')
19 changes: 19 additions & 0 deletions e2e/common/traits/files/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
containers:
- name: integration
env:
- name: TEST_VARIABLE
value: pod_test_value
volumeMounts:
- name: var-logs
mountPath: /var/log
- name: sidecar-container
image: busybox
command: [ "/bin/sh" , "-c", "while true; do echo $(date -u) 'Content from the sidecar container' > /var/log/file.txt; sleep 1;done" ]

resources: { }
volumeMounts:
- name: var-logs
mountPath: /var/log
volumes:
- name: var-logs
emptyDir: { }
64 changes: 64 additions & 0 deletions e2e/common/traits/pod_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// +build integration

// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"

/*
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 traits

import (
"testing"

. "github.com/apache/camel-k/e2e/support"
camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
)

func TestPodTrait(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
name := "pod-template-test"
Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
Expect(Kamel("run", "-n", ns, "files/PodTest.groovy",
"--name", name,
"--pod-template", "files/template.yaml",
).Execute()).To(Succeed())

//check integration is deployed
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(v1.PodRunning))
Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue))

//check that integrations is working and reading data created by sidecar container
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Content from the sidecar container"))
pod := IntegrationPod(ns, name)()

//check if ENV variable is applied
envValue := getEnvVar("TEST_VARIABLE", pod.Spec)
Expect(envValue).To(Equal("pod_test_value"))

})
}

func getEnvVar(name string, spec v1.PodSpec) string {
for _, i := range spec.Containers[0].Env {
if i.Name == name {
return i.Value
}
}
return ""
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/evanphx/json-patch v4.9.0+incompatible
github.com/fatih/structs v1.1.0
github.com/gertd/go-pluralize v0.1.1
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v0.4.0
github.com/golangplus/testing v1.0.0
github.com/google/go-github/v32 v32.1.0
Expand Down Expand Up @@ -52,6 +53,7 @@ require (
k8s.io/client-go v12.0.0+incompatible
k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027
k8s.io/klog/v2 v2.5.0
k8s.io/kubernetes v1.13.0
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009
knative.dev/eventing v0.21.1
knative.dev/pkg v0.0.0-20210216013737-584933f8280b
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYis
github.com/gertd/go-pluralize v0.1.1 h1:fQhql/WRRwr4TVp+TCw12s2esCacvEVBdkTUUwNqF/Q=
github.com/gertd/go-pluralize v0.1.1/go.mod h1:t5DfHcumb6m0RqyVJDrDLEzL2AGeaiqUXIcDNwLaeAs=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
Expand Down Expand Up @@ -1605,6 +1606,7 @@ k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM=
k8s.io/kube-openapi v0.0.0-20210113233702-8566a335510f h1:ZcWbnalfwIst131Zff7dGd1HQdt+NA9q7z9Fi0vbsHY=
k8s.io/kube-openapi v0.0.0-20210113233702-8566a335510f/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM=
k8s.io/kubernetes v1.13.0 h1:qTfB+u5M92k2fCCCVP2iuhgwwSOv1EkAkvQY1tQODD8=
k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/legacy-cloud-providers v0.17.4/go.mod h1:FikRNoD64ECjkxO36gkDgJeiQWwyZTuBkhu+yxOc1Js=
k8s.io/legacy-cloud-providers v0.19.7/go.mod h1:dsZk4gH9QIwAtHQ8CK0Ps257xlfgoXE3tMkMNhW2xDU=
Expand Down
Loading

0 comments on commit 37eb18f

Please sign in to comment.