This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c187484eaf5 CAMEL-18171: camel-kubernetes - Fallback to default k8s
client
c187484eaf5 is described below
commit c187484eaf5c6a2a5b34f17dd5704e1ebfb6db7f
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jun 24 20:36:08 2022 +0200
CAMEL-18171: camel-kubernetes - Fallback to default k8s client
---
.../kubernetes/properties/BasePropertiesFunction.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git
a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/properties/BasePropertiesFunction.java
b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/properties/BasePropertiesFunction.java
index d132c6d984f..a9225da4ee9 100644
---
a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/properties/BasePropertiesFunction.java
+++
b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/properties/BasePropertiesFunction.java
@@ -22,6 +22,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
@@ -55,6 +56,8 @@ abstract class BasePropertiesFunction extends ServiceSupport
implements Properti
public static final String ENV_MOUNT_PATH_SECRETS =
"camel.k.mount-path.secrets";
private static final Logger LOG =
LoggerFactory.getLogger(BasePropertiesFunction.class);
+ private static final AtomicBoolean LOGGED = new AtomicBoolean();
+
private CamelContext camelContext;
private KubernetesClient client;
private String mountPathConfigMaps;
@@ -91,7 +94,7 @@ abstract class BasePropertiesFunction extends ServiceSupport
implements Properti
.withCamelContext(camelContext)
.bind();
client = new DefaultKubernetesClient(config.build());
- LOG.info("Auto-configuration
io.fabric8.kubernetes.client.KubernetesClient summary");
+ LOG.info("Auto-configuration KubernetesClient summary");
for (var entry : properties.entrySet()) {
String k = entry.getKey().toString();
Object v = entry.getValue();
@@ -102,14 +105,22 @@ abstract class BasePropertiesFunction extends
ServiceSupport implements Properti
LOG.info(" {} {}={}", loc, k, v);
}
}
- // add to registry so the client can be reused
- camelContext.getRegistry().bind("camelKubernetesClient",
client);
+ } else {
+ // create a default client to use
+ client = new DefaultKubernetesClient();
+ LOG.debug("Created default KubernetesClient (auto-configured
by itself)");
}
+ // add to registry so the client can be reused
+ camelContext.getRegistry().bind("camelKubernetesClient", client);
}
-
if (client == null && getMountPath() == null) {
throw new IllegalArgumentException("Either a mount path or the
Kubernetes Client must be configured");
}
+
+ if (client != null && LOGGED.compareAndSet(false, true)) {
+ // only log once
+ LOG.info("KubernetesClient using masterUrl: {} with namespace:
{}", client.getMasterUrl(), client.getNamespace());
+ }
}
@Override