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 Mount trait example #3166

Merged
merged 1 commit into from
Apr 28, 2022
Merged
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
26 changes: 26 additions & 0 deletions examples/traits/mount/Consumer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.
*/

import org.apache.camel.builder.RouteBuilder;

public class Consumer extends RouteBuilder {
@Override
public void configure() throws Exception {
from("file:/tmp/log/example.log")
.filter(simple("${exchangeProperty.CamelTimerCounter} == 10"));
}
}
28 changes: 28 additions & 0 deletions examples/traits/mount/Producer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
*/

import org.apache.camel.builder.RouteBuilder;

public class Producer extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:tick")
.setBody()
.simple("Hello Camel K! #${exchangeProperty.CamelTimerCounter}")
.log("${body}");
}
}
14 changes: 14 additions & 0 deletions examples/traits/mount/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Camel K Mount Trait


In this section you will find examples about fine tuning your `Integration` using **Mount** `trait` capability.


**Example 1: Mount Persistent Volume Claim on the Integration Pod in a Kubernetes platform**

Create the Persistent Volume Claim:
`kubectl apply -f pvc-example.yaml`

Enable the Mount trait in the integrations, mount the Persistent Volume Claim, and log to an external volume:
`kamel run --trait mount.enabled=true --trait mount.volumes=["pvc-example:/tmp/log"] Producer.java -p quarkus.log.file.path=/tmp/log/example.log -p quarkus.log.file.enable=true`
`kamel run --trait mount.enabled=true --trait mount.volumes=["pvc-example:/tmp/log"] Consumer.java`
11 changes: 11 additions & 0 deletions examples/traits/mount/pvc-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-example
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi