You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/07/27 09:18:06 UTC

[camel-k] 02/03: Add HTTPS Healthcheck Example

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit b2278cd41a7d9812f208745444f718ff5c0b0c14
Author: Kyle Cooley <Ky...@ibm.com>
AuthorDate: Mon Jul 26 10:11:26 2021 -0500

    Add HTTPS Healthcheck Example
---
 examples/traits/container/HttpsHealthChecks.java | 47 ++++++++++++++++++++++++
 examples/traits/container/README.md              |  3 ++
 2 files changed, 50 insertions(+)

diff --git a/examples/traits/container/HttpsHealthChecks.java b/examples/traits/container/HttpsHealthChecks.java
new file mode 100644
index 0000000..3607fc7
--- /dev/null
+++ b/examples/traits/container/HttpsHealthChecks.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+// Generate a certificate for the integration (provide at least Country Name, can use defaults for rest)
+// openssl req -x509 -newkey rsa:4096 -keyout /tmp/integration-key.pem -out /tmp/integration-cert.pem -days 365 -nodes
+
+// Create a secret containing the generated certificate
+// kubectl create secret tls my-tls-secret --cert=/tmp/integration-cert.pem --key=/tmp/integration-key.pem
+
+// Run the integration
+/*
+kamel run \
+  --property quarkus.http.ssl.certificate.file=/etc/camel/conf.d/_secrets/my-tls-secret/tls.crt \
+  --property quarkus.http.ssl.certificate.key-file=/etc/camel/conf.d/_secrets/my-tls-secret/tls.key \
+  --config secret:my-tls-secret \
+  HttpsHealthChecks.java \
+  --trait container.port=8443 \
+  --trait container.probes-enabled=true \
+  --trait container.liveness-scheme=HTTPS \
+  --trait container.readiness-scheme=HTTPS
+*/
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class HttpsHealthChecks extends RouteBuilder {
+    @Override
+    public void configure() throws Exception {
+        from("timer:tick")
+            .setBody()
+            .constant("Hello Camel K!")
+            .to("log:info");
+    }
+}
diff --git a/examples/traits/container/README.md b/examples/traits/container/README.md
new file mode 100644
index 0000000..144142a
--- /dev/null
+++ b/examples/traits/container/README.md
@@ -0,0 +1,3 @@
+# Camel K Container Trait
+
+In this section you will find examples about fine tuning your `Integration` using **Container** `trait` capability.