=== Kubernetes ConfigMap Store

The Kubernetes ConfigMap Store extends the Vert.x Configuration Retriever and provides 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`):

[source,xml,subs="+attributes"]
----
<dependency>
 <groupId>io.vertx</groupId>
 <artifactId>vertx-config-kubernetes-configmap</artifactId>
 <version>3.8.1</version>
</dependency>
<dependency>
 <groupId>io.vertx</groupId>
 <artifactId>vertx-config</artifactId>
 <version>3.8.1</version>
</dependency>
----

* Gradle (in your `build.gradle` file):

[source,groovy,subs="+attributes"]
----
compile 'io.vertx:vertx-config:3.8.1'
compile 'io.vertx:vertx-config-kubernetes-configmap:3.8.1'
----

==== Configuring the store

Once added to your classpath or dependencies, you need to configure the
`link:../../apidocs/io/vertx/config/ConfigRetriever.html[ConfigRetriever]` to use this store:

[source, java]
----
ConfigStoreOptions store = new ConfigStoreOptions()
    .setType("configmap")
    .setConfig(new JsonObject()
        .put("namespace", "my-project-namespace")
        .put("name", "configmap-name")
    );

ConfigRetriever retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions().addStore(store));
----

You need to configure the store to find the right configmap. this is done with:

* `namespace` - the project namespace, `default` by default. If the `KUBERNETES_NAMESPACE` ENV variable is set, it
uses this value.
* `name` - the name of the config map
* `optional` - whether or not the config map is optional (`true` by default)

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`:

[source, java]
----
ConfigStoreOptions store = new ConfigStoreOptions()
    .setType("configmap")
    .setConfig(new JsonObject()
        .put("namespace", "my-project-namespace")
        .put("name", "my-secret")
        .put("secret", true)
    );

ConfigRetriever retriever = ConfigRetriever.create(vertx,
    new ConfigRetrieverOptions().addStore(store));
----

If the config map is not available, an empty JSON object is passed as configuration chunk. To disable this
behavior and explicitly fail, you can set the `optional` configuration to `false`.