Kubernetes config map example
This example contains everything you need to use a configmap
as the source for your flags.
We will use minikube to test the solution, but it works the same in your cluster.
As you can see the main.go
file contains a basic HTTP server that expose an API that use your flags.
For this example we are using a InClusterConfig
because we will run the service inside kubernetes.
How to setup the example
All commands should be run in the root level of the repository.
- Load all dependencies
make vendor
- Create a minikube environment in your machine:
minikube start --vm
- Use the minikube docker cli in your shell
eval $(minikube docker-env)
- Build the docker image of the service
docker build -f examples/retriever_configmap/Dockerfile -t goff-test-configmap .
- Create a
configmap
based on your go-feature-flag
config file
kubectl create configmap goff --from-file=examples/retriever_configmap/flags.goff.yaml
- Deploy your service to your kubernetes instance
kubectl apply -f examples/retriever_configmap/k8s-manifests.yaml
- Forward the port to the service
kubectl port-forward $(kubectl get pod | grep "goff-test-configmap" | cut -d ' ' -f1) 9090:8080
- Access to the service and check the values for different users
curl http://localhost:9090/
- Play with the values in the
go-feature-flag
config file
kubectl edit configmap goff
- Delete your minikube instance
minikube delete