Skip to main content
Version: v1.40.0

Kubernetes ConfigMap

Overview​

Loads the configuration from a Kubernetes ConfigMap. This retriever is useful when you are using Kubernetes and want to use ConfigMaps to store your configuration files.

The Kubernetes Retriever will access flags in a Kubernetes ConfigMap via the Kubernetes Go Client.

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:

kubectl create configmap goff --from-file=examples/retriever_configmap/flags.yaml

Configure the relay proxy​

To configure your relay proxy to use the Kubernetes ConfigMap 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.

goff-proxy.yaml
# ...
retrievers:
- kind: configmap
namespace: default
configmap: my-configmap
key: my-flags.yml
# ...
Field nameMandatoryTypeDefaultDescription
kindstringnoneValue should be configmap.
This field is mandatory and describes which retriever you are using.
namespacestringnoneThis is the name of the namespace where your configmap is located (ex: default).
configmapstringnoneName of the configmap we should read (ex: feature-flag).
keystringnoneName of the key in the configmap which contains the flag.

Configure the GO Module​

To configure your GO module to use the Kubernetes ConfigMap retriever, you need to add the following configuration to your ffclient.Config{} object:

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()
FieldMandatoryDescription
NamespaceThe namespace of the ConfigMap.
ConfigMapNameThe name of the ConfigMap.
KeyThe key within the ConfigMap storing the flags.
ClientConfigThe configuration object for the Kubernetes client