You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/03 07:38:37 UTC

[camel] branch k8s-env created (now 8644ae06826)

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

davsclaus pushed a change to branch k8s-env
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 8644ae06826 CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup.

This branch includes the following new commits:

     new 8644ae06826 CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/01: CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch k8s-env
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8644ae06826939f54f66eea5821574d07140c4cb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 3 09:38:24 2023 +0200

    CAMEL-19701: camel-main - Filter out k8s injected service ENV variables that can cause camel-main to fail startup.
---
 .../src/main/java/org/apache/camel/main/MainHelper.java    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
index a1ff0c1da8a..a78a289c417 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -120,9 +120,17 @@ public final class MainHelper {
             final String pk2 = pk.replace('-', '_');
             System.getenv().forEach((k, v) -> {
                 k = k.toUpperCase(Locale.US);
-                if (k.startsWith(pk) || k.startsWith(pk2)) {
-                    String key = k.toLowerCase(Locale.US).replace('_', '.');
-                    answer.put(key, v);
+                // kubernetes ENV injected services should be skipped
+                // (https://learn.microsoft.com/en-us/visualstudio/bridge/kubernetes-environment-variables#environment-variables-table)
+                boolean k8s = k.endsWith("_SERVICE_HOST") || k.endsWith("_SERVICE_PORT") || k.endsWith("_PORT")
+                        || k.contains("_PORT_");
+                if (k8s) {
+                    LOG.trace("Skipping Kubernetes Service OS environment variable: {}", k);
+                } else {
+                    if (k.startsWith(pk) || k.startsWith(pk2)) {
+                        String key = k.toLowerCase(Locale.US).replace('_', '.');
+                        answer.put(key, v);
+                    }
                 }
             });
         }