---
sidebar_position: 30
description: How to configure a kubernetes configmap retriever.
---
import { integrations } from "@site/data/integrations";
import {Mandatory, NotMandatory} from "@site/src/components/checks/checks";
export const retrieverName = 'Kubernetes ConfigMap'
export const info = integrations.retrievers.find((r) => r.name === retrieverName)

# Kubernetes ConfigMap

## Overview
{info.longDescription ?? info.description}

The **Kubernetes Retriever** will access flags in a Kubernetes ConfigMap via the [Kubernetes Go Client](https://github.com/kubernetes/client-go).

## Add a flag configuration file as ConfigMap
If you have a flag configuration file, you can create a ConfigMap with the content of the file.
The following command will create a ConfigMap with the content of the `examples/retriever_configmap/flags.yaml` file:
```shell
kubectl create configmap goff --from-file=examples/retriever_configmap/flags.yaml
```
## Configure the relay proxy

To configure your relay proxy to use the {retrieverName} retriever, you need to add the following
configuration to your relay proxy configuration file:

:::note
Relay proxy is only supporting the configmaps while running inside the kubernetes cluster.
:::

```yaml title="goff-proxy.yaml"
# ...
retrievers:
  - kind: configmap
    namespace: default
    configmap: my-configmap
    key: my-flags.yml
# ...
```

| Field name  |   Mandatory   | Type   | Default  | Description                                                                                                 |
|-------------|:-------------:|--------|----------|-------------------------------------------------------------------------------------------------------------|
| `kind`      | <Mandatory /> | string | **none** | Value should be **`configmap`**.<br/>_This field is mandatory and describes which retriever you are using._ |
| `namespace` | <Mandatory /> | string | **none** | This is the name of the namespace where your **configmap** is located _(ex: `default`)_.                    |
| `configmap` | <Mandatory /> | string | **none** | Name of the **configmap** we should read  _(ex: `feature-flag`)_.                                           |
| `key`       | <Mandatory /> | string | **none** | Name of the `key` in the **configmap** which contains the flag.                                             |

## Configure the GO Module
To configure your GO module to use the {retrieverName} retriever, you need to add the following
configuration to your `ffclient.Config{}` object:

```go title="example.go"
import (
    restclient "k8s.io/client-go/rest"
)
// ...
config, _ := restclient.InClusterConfig()
err = ffclient.Init(ffclient.Config{
    PollingInterval: 3 * time.Second,
    Retriever: &k8sretriever.Retriever{
        Path: "file-example.yaml",
        Namespace:      "default"
        ConfigMapName: "my-configmap"
        Key:    "my-flags.yml"
        ClientConfig: &config
    },
})
defer ffclient.Close()
```

| Field               |   Mandatory   | Description                                        |
|---------------------|:-------------:|----------------------------------------------------|
| **`Namespace`**     | <Mandatory /> | The namespace of the ConfigMap.                    |
| **`ConfigMapName`** | <Mandatory /> | The name of the ConfigMap.                         |
| **`Key`**           | <Mandatory /> | The key within the ConfigMap storing the flags.    |
| **`ClientConfig`**  | <Mandatory /> | The configuration object for the Kubernetes client |