The Kubernetes ConfigMap Store extends the Vert.x Configuration Retriever and provides the support Kubernetes Config Map and Secrets.
So, configuration is retrieved by reading the config map or the secrets.
Using the Kubernetes ConfigMap Store
To use the Kubernetes ConfigMap Store, add the following dependency to the dependencies section of your build descriptor:
-
Maven (in your
pom.xml
):
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-config-kubernetes-configmap</artifactId>
<version>3.4.0.Beta1</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-config</artifactId>
<version>3.4.0.Beta1</version>
</dependency>
-
Gradle (in your
build.gradle
file):
compile 'io.vertx:vertx-config:3.4.0.Beta1'
compile 'io.vertx:vertx-config-kubernetes-configmap:3.4.0.Beta1'
Configuring the store
Once added to your classpath or dependencies, you need to configure the
ConfigRetriever
to use this store:
import io.vertx.config.ConfigRetriever
def store = [
type:"configmap",
config:[
namespace:"my-project-namespace",
name:"configmap-name"
]
]
def retriever = ConfigRetriever.create(vertx, [
stores:[
store
]
])
You need to configure the store to find the right configmap. this is done with:
-
namespace
- the project namespace,default
by default. If theKUBERNETES_NAMESPACE
ENV variable is set, it uses this value. -
name
- the name of the config map
If the config map is composed by several element, you can use the key
parameter to tell
which key
is read
The application must have the permissions to read the config map.
To read data from a secret, just configure the secret
property to true
:
import io.vertx.config.ConfigRetriever
def store = [
type:"configmap",
config:[
namespace:"my-project-namespace",
name:"my-secret",
secret:true
]
]
def retriever = ConfigRetriever.create(vertx, [
stores:[
store
]
])