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

Add command line support for creating, building and running containerized integrations locally #1827

Merged
merged 22 commits into from
Dec 9, 2020

Conversation

doru1004
Copy link
Contributor

@doru1004 doru1004 commented Nov 24, 2020

This patch adds command line options for creating, building and running local images.

A new local command, local create has been added to construct images.

The first image kind it can produce is a base image to be used as a starter for all integration images. Example of building a base image, the image will be saved under the default name of integration-base-image:

kamel local create --base-image --container-registry <registry-name>

The image can then be used as a base for creating and building integration images, the image will be used automatically every time an integration image is created. If a base image isn't available it will be created automatically. Example of building an integration image (without running it):

kamel local create --image <registry-name>/<my-image-name> -d <dep> -p <prop> --property-file <file> route1.java route2.yaml

The resulting image can then be run locally using the following invocation:

kamel local run --image <registry-name>/<my-image-name>

Local run has been enhanced with containerization capabilities i.e. it can now create, build and run container images locally. The following command containerizes and runs the integration (i.e. performs all previous steps automatically: base image creation and building, integration image creation and building, integration image running):

kamel local run --containerize --image <registry-name>/<my-image-name> -d <dep> -p <prop> --property-file <file> route1.java route2.yaml

Release Note

Added ability to package and run integrations locally or as container images

@doru1004 doru1004 changed the title Add command line options for creating, building and running containerized integrations locally Add command line support for creating, building and running containerized integrations locally Nov 24, 2020
Copy link
Member

@nicolaferraro nicolaferraro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @doru1004 , it looks really promising. Just some comments to improve it.

@nicolaferraro nicolaferraro added the kind/feature New feature or request label Nov 27, 2020
@nicolaferraro
Copy link
Member

Another issue is that kamel local create --base-image creates a maven structure in the current directory (pom.xml, src and target dirs).

@doru1004
Copy link
Contributor Author

Another issue is that kamel local create --base-image creates a maven structure in the current directory (pom.xml, src and target dirs).

I fixed this. There were several other files and folders emitted and now no intermediate files/folders are emitted in the current directory.

@nicolaferraro
Copy link
Member

Seems there is some other issue, I can't get kamel local run examples/routes.groovy to work (it does not print the periodic log message).

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 1, 2020

Seems there is some other issue, I can't get kamel local run examples/routes.groovy to work (it does not print the periodic log message).

It looks like this has nothing to do with the latest changes, it probably has to do with redirecting the output of the command.

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 1, 2020

Seems there is some other issue, I can't get kamel local run examples/routes.groovy to work (it does not print the periodic log message).

The -d camel-k:runtime-quarkus dependency needs to be added to the CLI then it all works. Perhaps we can add that dependency automatically every time.

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 2, 2020

I have updated the patch to fix the reported problems. I have also changed the directories used inside the image to be the same ones used in the Kubernetes case! :)

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 2, 2020

@nicolaferraro not sure why the knative test failed, it looks like there is a similar failure in master.

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 2, 2020

Rebased on latest master.

fmt.Printf("Executing: " + strings.Join(cmd.Args, " ") + "\n")

// Run the command.
if err := cmd.Run(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you set the stdout and stderr here? It works but I see no logs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can definitely do that. Are there some guidelines as to how std out/err should be managed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some simple redirection of stdout and stderr.

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 3, 2020

I have also added the capability to include environment variables in modeline options:

test.yaml

# camel-k: property=camel.component.slack.webhookUrl=${SLACK_WEBHOOK}

When the modeline option is extracted, it will be added to the command line like this:

kamel local run --property=camel.component.slack.webhookUrl=hooks.slack.com/AAA/BBB/CCC

If the variable is not exported or has no value an error will be thrown.

@doru1004
Copy link
Contributor Author

doru1004 commented Dec 7, 2020

Rebased on latest master.

@nicolaferraro nicolaferraro merged commit 0910b2d into apache:master Dec 9, 2020
@nicolaferraro nicolaferraro mentioned this pull request Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants