Skip to main content
Version: Next

Kubernetes Secret

Overview​

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

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

Add a flag configuration file as Secret​

If you have a flag configuration file, you can create a Secret with the content of the file. The following command will create a Secret with the content of the examples/retriever_k8s_secret/flags.goff.yaml file:

kubectl create secret generic goff --from-file=examples/retriever_k8s_secret/flags.goff.yaml

Configure the relay proxy​

To configure your relay proxy to use the Kubernetes Secret retriever, you need to add the following configuration to your relay proxy configuration file:

note

Relay proxy is only supporting the secrets while running inside the kubernetes cluster.

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

Configure the GO Module​

To configure your GO module to use the Kubernetes Secret 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.SecretRetriever{
Path: "flags.goff.yaml",
Namespace: "default"
SecretName: "secret"
SecretKey: "flags.yml"
ClientConfig: &config
},
})
defer ffclient.Close()
FieldMandatoryDescription
NamespaceThe namespace of the Secret.
SecretNameThe name of the Secret.
SecretKeyThe key within the Secret storing the flags.
ClientConfigThe configuration object for the Kubernetes client