Flagger aims to be a simple feature flag management system.
- To allow users to sign-up.
- To allow users to authenticate in to the system.
- To allow authenticated users to create projects, environments and flags.
- To allow authenticated users to toggle the status of the flag i.e. on or off.
- To allow applications to fetch the current status of the provided flag.
Flagger is built using the Go programming language, MongoDB for database, Redis as the cache, and GRPC for communications.
Flagger requires Docker and Kubernetes for running.
-
Copy the sample env files
sample.env
andsecret_sample.env
files tok8s/base
using:cp sample.env k8s/base/.env cp secret_sample.env k8s/base/.env.secret
Once copied enter the values for the variables in
k8s/base/.env.secret
. -
Start a Kubernetes cluster on your machine. I've used
minikube
and so the instructions here are going to be with reference tominikube
. Start aminikube
cluster using:minikube start
-
Set up the Docker environment for
minikube
using:eval $(minikube docker-env)
This will allow us to build the images directly into
minikube
. -
To build the development image, run:
make build-dev
-
[Optional] To build the debug image, run:
make build-debug
-
To start the application in development mode, run:
kubectl apply -k k8s/overlays/dev
-
[Optional] To start the application in debug mode, run:
kubectl apply -k k8s/overlays/debug
-
When the application first starts the API server will not be able to run as MongoDB replicaset has not been setup up yet. To do so first, we to spin up a new MongoDB pod using:
kubectl run mongo --image mongo --rm -it -- bash
-
After a bash session has started, connect to the primary MongoDB instance using:
mongosh mongodb://mongo-0.mongo-hlsvc
-
Initiate the replicaset using the following
mongosh
command:rs.initiate({ _id: "rs0", members: [ { _id: 0, host: "mongo-0.mongo-hlsvc" }, { _id: 1, host: "mongo-1.mongo-hlsvc" }, { _id: 2, host: "mongo-2.mongo-hlsvc" }, ], });
-
The replicaset will take a little while to initiate. The status of the replicaset can be checked using the following
mongosh
command:rs.status();
Once you see one primary server and 2 secondary servers, you are ready to go.
-
Now, just wait for the API server to restart automatically and every thing should work.
-
To make requests to the API, you'll first need to get the IP of
minikube
using:minikube ip
-
Next you'll need the port on which the API server is running. To get that run:
kubectl get service/api-server
The port that you need will be mapped under the "PORT(S)" column.
-
Now you can make requests to the service on the IP
$(minikube ip):<PORT>
.
Note: Once you delete your local minikube
cluster, you'll have to repeat
steps 7 through 11 to setup the replicaset.
To stop the all the deployed units in the cluster, run:
kubectl delete -k k8s/overlays/<overlay>
Here, replace <overlay>
with the overlay used to deploy units.
To delete all resources started by minikube
, run:
minikube delete