This is a sample application that demonstrates how to use ConfigCat feature flags with Kubernetes for smoother deployments.
In this sample app, we utilize the Python Kubernetes client to create deployments and services. This choice was made to seamlessly integrate Kubernetes with ConfigCat feature flags. It's important to note that the integration of ConfigCat feature flags with Kubernetes can be approached in various ways. The explanation below details how these components work together:
-
Two Docker images are created for the backend. Each of these are built from a Separate Dockerfile. The Dockerfile.with-node18 uses Node 18 and the Dockerfile.with-node20 uses Node 20.
-
The
kubernetes-script.py
script is run to create the deployments and services. A default deployment logic gets executed to create a Pod with a container that contains the Docker image built from the Dockerfile.with-node18. Afterwards, the feature flag value is checked and if it is true, the Pod's container image is updated/patched to use the Docker image built from the Dockerfile.with-node20.
- Create a virtual environment
python3 -m venv venv
- Activate the virtual environment
source venv/bin/activate
- Install the dependencies
pip3 install -r requirements.txt
- Build the images for the backend that Kubernetes will use
docker build -f Dockerfile.with-node18 -t backend-with-node18:latest .
docker build -f Dockerfile.with-node20 -t backend-with-node20:latest .
In this setup, we are using Docker Desktop with Kubernetes enabled.
- Create the deployments and services
python3 kubernetes-script.py
- Check the deployments
kubectl get deployments
You should see something like this:
NAME READY UP-TO-DATE AVAILABLE AGE
backend-deployment 1/1 1 1 35m
Useful links to technical resources.
ConfigCat also supports many other frameworks and languages. Check out the full list of supported SDKs here.
You can also explore other code samples for various languages, frameworks, and topics here in the ConfigCat labs on GitHub.
Keep up with ConfigCat on X, Facebook, LinkedIn, and GitHub.
Contributions are welcome!