You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/08/21 12:21:57 UTC
(camel) branch docs-about-secrets-kubernetes created (now b75a7802c60)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch docs-about-secrets-kubernetes
in repository https://gitbox.apache.org/repos/asf/camel.git
at b75a7802c60 Add documentation about Kubernetes Secret Properties Function to Secret Component
This branch includes the following new commits:
new b75a7802c60 Add documentation about Kubernetes Secret Properties Function to Secret Component
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: Add documentation about Kubernetes Secret Properties Function to Secret Component
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch docs-about-secrets-kubernetes
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b75a7802c60e659cef414478f1cf9ce229771054
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Aug 21 14:21:15 2024 +0200
Add documentation about Kubernetes Secret Properties Function to Secret Component
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../main/docs/kubernetes-secrets-component.adoc | 74 +++++++++++++++++++++-
1 file changed, 73 insertions(+), 1 deletion(-)
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-secrets-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-secrets-component.adoc
index 5cb4bdc60e8..bbdb04575ef 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-secrets-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-secrets-component.adoc
@@ -80,6 +80,78 @@ from("direct:listByLabels").process(new Processor() {
This operation returns a list of Secrets from your cluster using a label selector (with key1 and key2, with value value1 and value2)
-
+== Using secrets properties function with Kubernetes
+
+The `camel-kubernetes` component include the following secrets related functions:
+
+* `secret` - A function to lookup the string property from Kubernetes Secrets.
+* `secret-binary` - A function to lookup the binary property from Kubernetes Secrets.
+
+Camel reads Secrets from the Kubernetes API Server. And when RBAC is enabled on the cluster,
+the ServiceAccount that is used to run the application needs to have the proper permissions for such access.
+
+Before the Kubernetes property placeholder functions can be used they need to be configured with either (or both)
+
+- path - A _mount path_ that must be mounted to the running pod, to load the configmaps or secrets from local disk.
+- kubernetes client - *Autowired* An `io.fabric8.kubernetes.client.KubernetesClient` instance to use for connecting to the Kubernetes API server.
+
+Camel will first use _mount paths_ (if configured) to lookup, and then fallback to use the `KubernetesClient`.
+
+A secret named `mydb` could contain username and passwords to connect to a database such as:
+
+[source,properties]
+----
+myhost = killroy
+myport = 5555
+myuser = scott
+mypass = tiger
+----
+
+This can be used in Camel with for example the Postrgres Sink Kamelet:
+
+[source,xml]
+----
+<camelContext>
+ <route>
+ <from uri="direct:rome"/>
+ <setBody>
+ <constant>{ "username":"oscerd", "city":"Rome"}</constant>
+ </setBody>
+ <to uri="kamelet:postgresql-sink?serverName={{secret:mydb/myhost}}
+ &serverPort={{secret:mydb/myport}}
+ &username={{secret:mydb/myuser}}
+ &password={{secret:mydb/mypass}}
+ &databaseName=cities
+ &query=INSERT INTO accounts (username,city) VALUES (:#username,:#city)"/>
+ </route>
+</camelContext>
+----
+
+The postgres-sink Kamelet can also be configured in `application.properties` which reduces the configuration
+in the route above:
+
+[source,properties]
+----
+camel.component.kamelet.postgresql-sink.databaseName={{secret:mydb/myhost}}
+camel.component.kamelet.postgresql-sink.serverPort={{secret:mydb/myport}}
+camel.component.kamelet.postgresql-sink.username={{secret:mydb/myuser}}
+camel.component.kamelet.postgresql-sink.password={{secret:mydb/mypass}}
+----
+
+Which reduces the route to:
+
+[source,xml]
+----
+<camelContext>
+ <route>
+ <from uri="direct:rome"/>
+ <setBody>
+ <constant>{ "username":"oscerd", "city":"Rome"}</constant>
+ </setBody>
+ <to uri="kamelet:postgresql-sink?databaseName=cities
+ &query=INSERT INTO accounts (username,city) VALUES (:#username,:#city)"/>
+ </route>
+</camelContext>
+----
include::spring-boot:partial$starter.adoc[]