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(#1656) : Jib publish strategy base on JibCli #4545

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
strategy:
fail-fast: false
matrix:
publisher: ["Buildah", "Spectrum", "Kaniko"]
publisher: ["Buildah", "Spectrum", "Kaniko", "Jib"]

steps:
- name: Checkout code
Expand Down
25 changes: 23 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine:latest AS jibcli
ARG JIB_CLI_VERSION=0.12.0
ARG JIB_HOME="/opt/jib"
RUN apk --no-cache add ca-certificates \
curl \
unzip \
&& rm -rf /var/cache/apk/*
# replace xargs command not available in some base images
RUN set -xe \
&& curl -sSL -o jib.zip https://github.com/GoogleContainerTools/jib/releases/download/v${JIB_CLI_VERSION}-cli/jib-jre-${JIB_CLI_VERSION}.zip \
&& unzip jib.zip \
&& rm jib.zip \
&& mv jib-${JIB_CLI_VERSION} ${JIB_HOME} \
&& sed -i "s/xargs -n1/tr \' \' \'\\\n\'/g" ${JIB_HOME}/bin/jib

FROM eclipse-temurin:17-jdk as base

ARG MAVEN_DEFAULT_VERSION="3.8.6"
Expand All @@ -21,6 +36,8 @@ ARG MAVEN_DIST_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_DEFAUL
ARG MVNW_DIR="/usr/share/maven/mvnw/"
ARG MVN_REPO="/etc/maven/m2"

ARG JIB_HOME="/opt/jib"

USER 0

# Maven configuration
Expand All @@ -42,6 +59,8 @@ RUN ${MVNW_DIR}/mvnw --version | grep "Maven home:" | sed 's/Maven home: //' >>
&& rm $(cat ${MVNW_DIR}default)/lib/maven-slf4j-provider*
ENV MAVEN_OPTS="${MAVEN_OPTS} -Dlogback.configurationFile=${MAVEN_HOME}/conf/logback.xml"

COPY --from=jibcli ${JIB_HOME} ${JIB_HOME}

ADD build/_maven_output ${MVN_REPO}
ADD build/_kamelets /kamelets

Expand All @@ -52,7 +71,9 @@ RUN chgrp -R 0 ${MVN_REPO} \
&& chmod -R g=u /kamelets \
&& chgrp -R 0 ${MAVEN_HOME} \
&& chown -R 1001:0 ${MAVEN_HOME} \
&& chmod -R 775 ${MAVEN_HOME}
&& chmod -R 775 ${MAVEN_HOME} \
&& chown -R 1001:0 ${JIB_HOME} \
&& chmod -R 775 ${JIB_HOME}

USER 1001:0

Expand All @@ -64,4 +85,4 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest

FROM base as debug

COPY --from=go /go/bin/dlv /usr/local/bin/dlv
COPY --from=go /go/bin/dlv /usr/local/bin/dlv
37 changes: 37 additions & 0 deletions config/crd/bases/camel.apache.org_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,43 @@ spec:
description: name of the task
type: string
type: object
jib:
description: a JibTask, for Jib strategy
properties:
baseImage:
description: base image layer
type: string
contextDir:
description: can be useful to share info with other tasks
type: string
image:
description: final image name
type: string
name:
description: name of the task
type: string
registry:
description: where to publish the final image
properties:
address:
description: the URI to access
type: string
ca:
description: the configmap which stores the Certificate
Authority
type: string
insecure:
description: if the container registry is insecure (ie,
http only)
type: boolean
organization:
description: the registry organization
type: string
secret:
description: the secret where credentials are stored
type: string
type: object
type: object
kaniko:
description: a KanikoTask, for Kaniko strategy
properties:
Expand Down
4 changes: 2 additions & 2 deletions config/samples/patch-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ spec:
#
#
# Build publish strategy for integrations
# ie. Buildah, Kaniko, S2I, Spectrum
# ie. Buildah, Kaniko, S2I, Spectrum, Jib
#
# publishStrategy: Buildah | Kaniko | S2I | Spectrum
# publishStrategy: Buildah | Kaniko | S2I | Spectrum | Jib
#
# Set the camel-k runtime version
#
Expand Down
40 changes: 40 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ a checksum (SHA1) of the content

* <<#_camel_apache_org_v1_BuildahTask, BuildahTask>>
* <<#_camel_apache_org_v1_BuilderTask, BuilderTask>>
* <<#_camel_apache_org_v1_JibTask, JibTask>>
* <<#_camel_apache_org_v1_KanikoTask, KanikoTask>>
* <<#_camel_apache_org_v1_S2iTask, S2iTask>>
* <<#_camel_apache_org_v1_SpectrumTask, SpectrumTask>>
Expand Down Expand Up @@ -3419,6 +3420,37 @@ string
JSONSchemaURL represents a schema url.


[#_camel_apache_org_v1_JibTask]
=== JibTask

*Appears on:*

* <<#_camel_apache_org_v1_Task, Task>>

JibTask is used to configure Jib

[cols="2,2a",options="header"]
|===
|Field
|Description

|`BaseTask` +
*xref:#_camel_apache_org_v1_BaseTask[BaseTask]*
|(Members of `BaseTask` are embedded into this type.)




|`PublishTask` +
*xref:#_camel_apache_org_v1_PublishTask[PublishTask]*
|(Members of `PublishTask` are embedded into this type.)





|===

[#_camel_apache_org_v1_KameletCondition]
=== KameletCondition

Expand Down Expand Up @@ -4268,6 +4300,7 @@ the specification
*Appears on:*

* <<#_camel_apache_org_v1_BuildahTask, BuildahTask>>
* <<#_camel_apache_org_v1_JibTask, JibTask>>
* <<#_camel_apache_org_v1_KanikoTask, KanikoTask>>
* <<#_camel_apache_org_v1_SpectrumTask, SpectrumTask>>

Expand Down Expand Up @@ -4827,6 +4860,13 @@ a SpectrumTask, for Spectrum strategy

a S2iTask, for S2I strategy

|`jib` +
*xref:#_camel_apache_org_v1_JibTask[JibTask]*
|


a JibTask, for Jib strategy

|`custom` +
*xref:#_camel_apache_org_v1_UserTask[UserTask]*
|
Expand Down
37 changes: 37 additions & 0 deletions helm/camel-k/crds/crd-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,43 @@ spec:
description: name of the task
type: string
type: object
jib:
description: a JibTask, for Jib strategy
properties:
baseImage:
description: base image layer
type: string
contextDir:
description: can be useful to share info with other tasks
type: string
image:
description: final image name
type: string
name:
description: name of the task
type: string
registry:
description: where to publish the final image
properties:
address:
description: the URI to access
type: string
ca:
description: the configmap which stores the Certificate
Authority
type: string
insecure:
description: if the container registry is insecure (ie,
http only)
type: boolean
organization:
description: the registry organization
type: string
secret:
description: the secret where credentials are stored
type: string
type: object
type: object
kaniko:
description: a KanikoTask, for Kaniko strategy
properties:
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/camel/v1/build_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ type Task struct {
Spectrum *SpectrumTask `json:"spectrum,omitempty"`
// a S2iTask, for S2I strategy
S2i *S2iTask `json:"s2i,omitempty"`
// a JibTask, for Jib strategy
Jib *JibTask `json:"jib,omitempty"`

// User customizable task execution

Expand Down Expand Up @@ -154,6 +156,12 @@ type KanikoTaskCache struct {
PersistentVolumeClaim string `json:"persistentVolumeClaim,omitempty"`
}

// JibTask is used to configure Jib
type JibTask struct {
BaseTask `json:",inline"`
PublishTask `json:",inline"`
}

// SpectrumTask is used to configure Spectrum
type SpectrumTask struct {
BaseTask `json:",inline"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/camel/v1/integrationplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ const (
// IntegrationPlatformBuildPublishStrategySpectrum uses Spectrum project (https://github.com/container-tools/spectrum)
// in order to push the incremental images to the image repository. It is the default choice on vanilla Kubernetes cluster
IntegrationPlatformBuildPublishStrategySpectrum IntegrationPlatformBuildPublishStrategy = "Spectrum"
// IntegrationPlatformBuildPublishStrategyJib used the JibCli tool (https://github.com/GoogleContainerTools/jib/tree/master/jib-cli)
// in order to ush the incremental images to the image repository.
IntegrationPlatformBuildPublishStrategyJib IntegrationPlatformBuildPublishStrategy = "Jib"
)

// IntegrationPlatformBuildPublishStrategies the list of all available publish strategies
Expand All @@ -173,6 +176,7 @@ var IntegrationPlatformBuildPublishStrategies = []IntegrationPlatformBuildPublis
IntegrationPlatformBuildPublishStrategyKaniko,
IntegrationPlatformBuildPublishStrategyS2I,
IntegrationPlatformBuildPublishStrategySpectrum,
IntegrationPlatformBuildPublishStrategyJib,
}

// IntegrationPlatformPhase is the phase of an IntegrationPlatform
Expand Down
22 changes: 22 additions & 0 deletions pkg/apis/camel/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading