/open-feature-operator

A Kubernetes feature flag operator

Primary LanguageGoApache License 2.0Apache-2.0

open-feature-operator

build goversion version status

The open-feature-operator is a Kubernetes native operator that allows you to expose feature flags to your applications. It injects a flagd sidecar into your pod and allows you to poll the flagd server for feature flags in a variety of ways.

Architecture

As per the issue here High level architecture is as follows:

Example

When wishing to leverage featureflagging within the local pod, the following steps are required:

  1. Create a new feature flag custom resource e.g.
apiVersion: core.openfeature.dev/v1alpha1
kind: FeatureFlagConfiguration
metadata:
  name: featureflagconfiguration-sample
spec:
  featureFlagSpec: |
    {
      "foo" : "bar"
    }
  1. Reference the CR within the pod spec annotations
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  annotations:
    openfeature.dev: "enabled"
    openfeature.dev/featureflagconfiguration: "featureflagconfiguration-sample"
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80
  1. Example usage from host container
root@nginx:/# curl localhost:8080
{
  "foo" : "bar"
}

Running the operator locally

  1. Create a local cluster with MicroK8s or Kind
  2. kubectl create ns 'open-feature-operator-system'
  3. kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
  4. kubectl apply -f config/webhook/certificate.yaml
  5. IMG=ghcr.io/open-feature/open-feature-operator:main make deploy

Run the example

  1. kubectl apply -f config/samples/config_v1alpha1_featureflagconfiguration.yaml
  2. kubectl apply -f config/samples/pod.yaml