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

feat(build): add root image info #4836

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions config/crd/bases/camel.apache.org_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,10 @@ spec:
phase:
description: describes the phase
type: string
rootImage:
description: root image (the first image from which the incremental
image has started)
type: string
startedAt:
description: the time when it started
format: date-time
Expand Down
13 changes: 12 additions & 1 deletion config/crd/bases/camel.apache.org_integrationkits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ spec:
jsonPath: .status.image
name: Image
type: string
- description: The integration kit root image
jsonPath: .status.rootImage
name: Root
type: string
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -197,6 +201,9 @@ spec:
description: The builder trait is internally used to determine
the best strategy to build and configure IntegrationKits.
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down Expand Up @@ -410,7 +417,7 @@ spec:
type: object
type: array
baseImage:
description: base image used by the kit
description: base image used by the kit (could be another IntegrationKit)
type: string
conditions:
description: a list of conditions which happened for the events related
Expand Down Expand Up @@ -495,6 +502,10 @@ spec:
platform:
description: the platform for which this kit was configured
type: string
rootImage:
description: root image used by the kit (the first image from which
the incremental image has started, typically a JDK/JRE base image)
type: string
runtimeProvider:
description: the runtime provider for which this kit was configured
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/camel.apache.org_integrationplatforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down Expand Up @@ -2315,6 +2318,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/camel.apache.org_integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6417,6 +6417,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/camel.apache.org_kameletbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6699,6 +6699,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6697,6 +6697,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
23 changes: 22 additions & 1 deletion docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@ string

the digest from image

|`rootImage` +
string
|


root image (the first image from which the incremental image has started)

|`baseImage` +
string
|
Expand Down Expand Up @@ -2461,12 +2468,19 @@ ObservedGeneration is the most recent generation observed for this IntegrationKi

phase of the kit

|`rootImage` +
string
|


root image used by the kit (the first image from which the incremental image has started, typically a JDK/JRE base image)

|`baseImage` +
string
|


base image used by the kit
base image used by the kit (could be another IntegrationKit)

|`image` +
string
Expand Down Expand Up @@ -5797,6 +5811,13 @@ string

The strategy to use, either `pod` or `routine` (default routine)

|`baseImage` +
string
|


Specify a base image

|`incrementalImageBuild` +
bool
|
Expand Down
4 changes: 4 additions & 0 deletions docs/modules/traits/pages/builder.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ The following configuration options are available:
| string
| The strategy to use, either `pod` or `routine` (default routine)

| builder.base-image
| string
| Specify a base image

| builder.incremental-image-build
| bool
| Use the incremental image build option, to reuse existing containers (default `true`)
Expand Down
61 changes: 61 additions & 0 deletions e2e/commonwithcustominstall/incremental_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
package commonwithcustominstall

import (
"fmt"
"testing"

. "github.com/onsi/gomega"
Expand All @@ -34,6 +35,7 @@ import (
"github.com/apache/camel-k/v2/pkg/util/defaults"
)

/*
func TestRunIncrementalBuildRoutine(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-incremental-build"
Expand All @@ -48,6 +50,7 @@ func TestRunIncrementalBuildRoutine(t *testing.T) {
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
integrationKitName := IntegrationKit(ns, name)()
Eventually(Kit(ns, integrationKitName)().Status.BaseImage).Should(Equal(defaults.BaseImage()))
Eventually(Kit(ns, integrationKitName)().Status.RootImage).Should(Equal(defaults.BaseImage()))

t.Run("Reuse previous kit", func(t *testing.T) {
nameClone := "java-clone"
Expand Down Expand Up @@ -77,6 +80,7 @@ func TestRunIncrementalBuildRoutine(t *testing.T) {
// 10.108.177.66/test-d7cad110-bb1d-4e79-8a0e-ebd44f6fe5d4/camel-k-kit-c8357r4k5tp6fn1idm60@sha256:d49716f0429ad8b23a1b8d20a357d64b1aa42a67c1a2a534ebd4c54cd598a18d
// we should be save just to check the substring is contained
Eventually(Kit(ns, integrationIncrementalKitName)().Status.BaseImage).Should(ContainSubstring(integrationKitName))
Eventually(Kit(ns, integrationIncrementalKitName)().Status.RootImage).Should(Equal(defaults.BaseImage()))
})

Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
Expand All @@ -98,6 +102,7 @@ func TestRunIncrementalBuildPod(t *testing.T) {
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
integrationKitName := IntegrationKit(ns, name)()
Eventually(Kit(ns, integrationKitName)().Status.BaseImage).Should(Equal(defaults.BaseImage()))
Eventually(Kit(ns, integrationKitName)().Status.RootImage).Should(Equal(defaults.BaseImage()))
Eventually(BuilderPodsCount(ns)).Should(Equal(1))

t.Run("Reuse previous kit", func(t *testing.T) {
Expand Down Expand Up @@ -131,6 +136,7 @@ func TestRunIncrementalBuildPod(t *testing.T) {
// 10.108.177.66/test-d7cad110-bb1d-4e79-8a0e-ebd44f6fe5d4/camel-k-kit-c8357r4k5tp6fn1idm60@sha256:d49716f0429ad8b23a1b8d20a357d64b1aa42a67c1a2a534ebd4c54cd598a18d
// we should be save just to check the substring is contained
Eventually(Kit(ns, integrationIncrementalKitName)().Status.BaseImage).Should(ContainSubstring(integrationKitName))
Eventually(Kit(ns, integrationIncrementalKitName)().Status.RootImage).Should(Equal(defaults.BaseImage()))
Eventually(BuilderPodsCount(ns)).Should(Equal(2))
})

Expand Down Expand Up @@ -185,3 +191,58 @@ func TestRunIncrementalBuildOff(t *testing.T) {
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}
*/
func TestRunIncrementalBuildWithDifferentBaseImages(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := "camel-k-standard-build"
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())

name := "java"
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
integrationKitName := IntegrationKit(ns, name)()
Eventually(Kit(ns, integrationKitName)().Status.BaseImage).Should(Equal(defaults.BaseImage()))
Eventually(Kit(ns, integrationKitName)().Status.RootImage).Should(Equal(defaults.BaseImage()))

t.Run("Create incremental kit", func(t *testing.T) {
// Another integration that should be built on top of the previous IntegrationKit
// just add a new random dependency
nameIncremental := "java-incremental"
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", nameIncremental,
"-d", "camel:zipfile",
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, nameIncremental), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, nameIncremental, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, nameIncremental), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
integrationIncrementalKitName := IntegrationKit(ns, nameIncremental)()
// the container comes in a format like
// 10.108.177.66/test-d7cad110-bb1d-4e79-8a0e-ebd44f6fe5d4/camel-k-kit-c8357r4k5tp6fn1idm60@sha256:d49716f0429ad8b23a1b8d20a357d64b1aa42a67c1a2a534ebd4c54cd598a18d
// we should be save just to check the substring is contained
Eventually(Kit(ns, integrationIncrementalKitName)().Status.BaseImage).Should(ContainSubstring(integrationKitName))
Eventually(Kit(ns, integrationIncrementalKitName)().Status.RootImage).Should(Equal(defaults.BaseImage()))
})

t.Run("Create new hierarchy kit", func(t *testing.T) {
// We should spin off a new hierarchy of builds
newBaseImage := "eclipse-temurin:17.0.8.1_1-jdk-ubi9-minimal"
name = "java-new"
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-d", "camel:mongodb",
"-t", fmt.Sprintf("builder.base-image=%s", newBaseImage),
).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
integrationKitName = IntegrationKit(ns, name)()
Eventually(Kit(ns, integrationKitName)().Status.BaseImage).Should(Equal(newBaseImage))
Eventually(Kit(ns, integrationKitName)().Status.RootImage).Should(Equal(newBaseImage))
})
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
}
4 changes: 4 additions & 0 deletions helm/camel-k/crds/crd-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,10 @@ spec:
phase:
description: describes the phase
type: string
rootImage:
description: root image (the first image from which the incremental
image has started)
type: string
startedAt:
description: the time when it started
format: date-time
Expand Down
13 changes: 12 additions & 1 deletion helm/camel-k/crds/crd-integration-kit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ spec:
jsonPath: .status.image
name: Image
type: string
- description: The integration kit root image
jsonPath: .status.rootImage
name: Root
type: string
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -197,6 +201,9 @@ spec:
description: The builder trait is internally used to determine
the best strategy to build and configure IntegrationKits.
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down Expand Up @@ -410,7 +417,7 @@ spec:
type: object
type: array
baseImage:
description: base image used by the kit
description: base image used by the kit (could be another IntegrationKit)
type: string
conditions:
description: a list of conditions which happened for the events related
Expand Down Expand Up @@ -495,6 +502,10 @@ spec:
platform:
description: the platform for which this kit was configured
type: string
rootImage:
description: root image used by the kit (the first image from which
the incremental image has started, typically a JDK/JRE base image)
type: string
runtimeProvider:
description: the runtime provider for which this kit was configured
type: string
Expand Down
6 changes: 6 additions & 0 deletions helm/camel-k/crds/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down Expand Up @@ -2315,6 +2318,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
3 changes: 3 additions & 0 deletions helm/camel-k/crds/crd-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6417,6 +6417,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
3 changes: 3 additions & 0 deletions helm/camel-k/crds/crd-kamelet-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6699,6 +6699,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
3 changes: 3 additions & 0 deletions helm/camel-k/crds/crd-pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6697,6 +6697,9 @@ spec:
builder:
description: The configuration of Builder trait
properties:
baseImage:
description: Specify a base image
type: string
configuration:
description: 'Legacy trait configuration parameters. Deprecated:
for backward compatibility.'
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/camel/v1/build_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ type BuildStatus struct {
Image string `json:"image,omitempty"`
// the digest from image
Digest string `json:"digest,omitempty"`
// root image (the first image from which the incremental image has started)
RootImage string `json:"rootImage,omitempty"`
// the base image used for this build
BaseImage string `json:"baseImage,omitempty"`
// a list of artifacts contained in the build
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/camel/v1/integrationkit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
// +kubebuilder:printcolumn:name="Type",type=string,JSONPath=`.metadata.labels.camel\.apache\.org\/kit\.type`,description="The integration kit type"
// +kubebuilder:printcolumn:name="Layout",type=string,JSONPath=`.metadata.labels.camel\.apache\.org\/kit\.layout`,description="The integration kit layout"
// +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.status.image`,description="The integration kit image"
// +kubebuilder:printcolumn:name="Root",type=string,JSONPath=`.status.rootImage`,description="The integration kit root image"

// IntegrationKit defines a container image and additional configuration needed to run an `Integration`.
// An `IntegrationKit` is a generic image generally built from the requirements of an `Integration`, but agnostic to it,
Expand Down Expand Up @@ -97,7 +98,9 @@ type IntegrationKitStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// phase of the kit
Phase IntegrationKitPhase `json:"phase,omitempty"`
// base image used by the kit
// root image used by the kit (the first image from which the incremental image has started, typically a JDK/JRE base image)
RootImage string `json:"rootImage,omitempty"`
// base image used by the kit (could be another IntegrationKit)
BaseImage string `json:"baseImage,omitempty"`
// actual image name of the kit
Image string `json:"image,omitempty"`
Expand Down
Loading
Loading