Skip to content

Commit 9721825

Browse files
odubajDTbacherfltoddbaert
authored
docs: support in-process evaluation (#640)
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com> Signed-off-by: odubajDT <93584209+odubajDT@users.noreply.github.com> Co-authored-by: Florian Bacher <florian.bacher@dynatrace.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
1 parent 51db913 commit 9721825

File tree

3 files changed

+189
-16
lines changed

3 files changed

+189
-16
lines changed

docs/annotations.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,29 @@ Example:
3131
openfeature.dev/featureflagsource: "config-A, config-B"
3232
```
3333

34+
### `openfeature.dev/inprocessconfiguration`
35+
36+
This annotation specifies the names of the `InProcessConfigurations` used to configure the injected environment variables to support flagd's [in-process evaluation mode](https://flagd.dev/architecture/#in-process-evaluation).
37+
The annotation value is a comma separated list of values following one of 2 patterns: {NAME} or {NAMESPACE}/{NAME}.
38+
39+
If no namespace is provided, it is assumed that the custom resource is within the **same namespace** as the annotated pod.
40+
If multiple CRs are provided, they are merged with the latest taking precedence.
41+
42+
Users should not combine `openfeature.dev/inprocessconfiguration` and `openfeature.dev/featureflagsource` annotations
43+
for the same pod. If this happens `openfeature.dev/featureflagsource` will take precedence.
44+
45+
For example, in the scenario below, `inProcessConfig-B` will take priority in the merge, replacing duplicated values that are set in `inProcessConfig-A`.
46+
47+
Example:
48+
```yaml
49+
metadata:
50+
annotations:
51+
openfeature.dev/enabled: "true"
52+
openfeature.dev/inprocessconfiguration: "inProcessConfig-A, inProcessConfig-B"
53+
```
54+
3455
### `openfeature.dev/allowkubernetessync`
3556
*This annotation is used INTERNALLY by the operator.*
3657

3758
This annotation is used to mark pods which should have their permissions backfilled in the event of an upgrade.
3859
When the OFO manager pod is started, all `Service Accounts` of any `Pods` with this annotation set to `"true"` will be added to the `flagd-kubernetes-sync` `Cluster Role Binding`.
39-
40-
## Deprecated annotations
41-
42-
Given below are references to **deprecated** annotations used by previous versions of the operator.

docs/in_process_configuration.md

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Feature Flag In-process Configuration
2+
3+
The `InProcessConfiguration` is a custom resource used to set up the
4+
[configuration options](https://flagd.dev/providers/nodejs/?h=flagd_host#available-configuration-options)
5+
for applications using `OpenFeature operator` with in-process evaluation mode enabled.
6+
7+
Below you can see a minimal example of `InProcessConfiguration` resource
8+
9+
```yaml
10+
apiVersion: core.openfeature.dev/v1beta1
11+
kind: InProcessConfiguration
12+
metadata:
13+
labels:
14+
name: inprocessconfiguration-sample
15+
spec:
16+
port: 2424
17+
tls: true
18+
offlineFlagSourcePath: "my-path"
19+
cacheMaxSize: 11
20+
envVarPrefix: "my-prefix"
21+
envVars:
22+
- name: "name1"
23+
value: "val1"
24+
- name: "name2"
25+
value: "val2"
26+
```
27+
28+
## How does it work?
29+
30+
Similar to usage of [FeatureFlagSource](./feature_flag_source.md) configuration,
31+
[annotations](./annotations.md#) are used to allow the injection of configuration data
32+
into the annotated Pod.
33+
The mutating webhook parses the annotations, retrieves the referenced `InProcessConfiguration` resources from the cluster and injects the data from the resource into all containers of the Pod via environment variables, which configure the provider in the workload to consume feature flag configuration from the available [sync implementation](https://flagd.dev/concepts/syncs/#grpc-sync) specified by the configuration.
34+
35+
## Merging of configurations
36+
37+
The value of `openfeature.dev/inprocessconfiguration` annotation is a comma separated list of values following one of two patterns: {NAME} or {NAMESPACE}/{NAME}.
38+
If no namespace is provided, it is assumed that the CR is within the same namespace as the deployed pod, for example:
39+
40+
```yaml
41+
metadata:
42+
annotations:
43+
openfeature.dev/enabled: "true"
44+
openfeature.dev/inprocessconfiguration: "inProcessConfig-A, inProcessConfig-B"
45+
```
46+
47+
When multiple `InProcessConfigurations` are provided, the custom resources are merged in runtime and the last `CR` takes precedence over the first, similarly how it's done for `FeatureFlagSource`.
48+
In this example, 2 CRs are being used to set the injected configuration.
49+
50+
```yaml
51+
apiVersion: core.openfeature.dev/v1beta1
52+
kind: InProcessConfiguration
53+
metadata:
54+
name: inProcessConfig-A
55+
spec:
56+
port: 2424
57+
tls: true
58+
offlineFlagSourcePath: "my-path"
59+
cacheMaxSize: 11
60+
envVarPrefix: "my-prefix"
61+
envVars:
62+
- name: "name1"
63+
value: "val1"
64+
- name: "name2"
65+
value: "val2"
66+
---
67+
apiVersion: core.openfeature.dev/v1beta1
68+
kind: InProcessConfiguration
69+
metadata:
70+
name: inProcessConfig-B
71+
spec:
72+
envVarPrefix: "my-second-prefix"
73+
host: "my-host"
74+
```
75+
76+
The resources are merged in runtime, which means that no changes are made to the `InProcessConfiguration` resources
77+
in the cluster, but the operator handles the merge and injection internally.
78+
79+
The resulting configuration will look like the following
80+
81+
```yaml
82+
apiVersion: core.openfeature.dev/v1beta1
83+
kind: InProcessConfiguration
84+
metadata:
85+
name: internal
86+
spec:
87+
port: 2424
88+
tls: true
89+
offlineFlagSourcePath: "my-path"
90+
cacheMaxSize: 11
91+
envVarPrefix: "my-seconf-prefix"
92+
host: "my-host"
93+
envVars:
94+
- name: "name1"
95+
value: "val1"
96+
- name: "name2"
97+
value: "val2"
98+
```
99+
100+
This resulting resource is transformed into environment variables and injected into all containers
101+
of the annotated Pod
102+
103+
```yaml
104+
apiVersion: v1
105+
kind: Pod
106+
metadata:
107+
annotations:
108+
openfeature.dev/enabled: "true"
109+
openfeature.dev/inprocessconfiguration: "inProcessConfig-A, inProcessConfig-B"
110+
name: ofo-pod
111+
spec:
112+
containers:
113+
- name: container1
114+
image: image1
115+
env:
116+
- name: my-second-prefix_name2
117+
value: val2
118+
- name: my-second-prefix_name1
119+
value: val1
120+
- name: my-second-prefix_HOST
121+
value: my-host
122+
- name: my-second-prefix_PORT
123+
value: "2424"
124+
- name: my-second-prefix_TLS
125+
value: "true"
126+
- name: my-second-prefix_OFFLINE_FLAG_SOURCE_PATH
127+
value: my-path
128+
- name: my-second-prefix_MAX_CACHE_SIZE
129+
value: "11"
130+
- name: my-second-prefix_RESOLVER
131+
value: in-process
132+
- name: container2
133+
image: image2
134+
env:
135+
- name: my-second-prefix_name2
136+
value: val2
137+
- name: my-second-prefix_name1
138+
value: val1
139+
- name: my-second-prefix_HOST
140+
value: my-host
141+
- name: my-second-prefix_PORT
142+
value: "2424"
143+
- name: my-second-prefix_TLS
144+
value: "true"
145+
- name: my-second-prefix_OFFLINE_FLAG_SOURCE_PATH
146+
value: my-path
147+
- name: my-second-prefix_MAX_CACHE_SIZE
148+
value: "11"
149+
- name: my-second-prefix_RESOLVER
150+
value: in-process
151+
```

docs/permissions.md

+17-12
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,23 @@ The `manager-role` applies the rules described below, its definition can be foun
2323
It provides the operator with sufficient permissions over the `core.openfeature.dev` resources, and the required permissions for injecting the `flagd` sidecar into appropriate pods.
2424
The `ConfigMap` permissions are needed to allow the mounting of `FeatureFlag` resources for file syncs.
2525

26-
| API Group | Resource | Verbs |
27-
|-----------------------------|--------------------------|-------------------------------------------------|
28-
| - | `ConfigMap` | create, delete, get, list, patch, update, watch |
29-
| - | `Pod` | create, delete, get, list, patch, update, watch |
30-
| - | `ServiceAccount` | get, list, watch |
31-
| - | `Service` *(\*)* | create, delete, get, list, patch, update, watch |
32-
| `networking.k8s.io` | `Ingress` *(\*)* | create, delete, get, list, patch, update, watch |
33-
| `core.openfeature.dev` | `FeatureFlag` | create, delete, get, list, patch, update, watch |
34-
| `core.openfeature.dev` | `FeatureFlag Finalizers` | update |
35-
| `core.openfeature.dev` | `FeatureFlag Status` | get, patch, update |
36-
| `core.openfeature.dev` | `Flagd` | create, delete, get, list, patch, update, watch |
37-
| `rbac.authorization.k8s.io` | `ClusterRoleBinding` | get, list, update, watch |
26+
| API Group | Resource | Verbs |
27+
|-----------------------------|---------------------------------|-------------------------------------------------|
28+
| - | `ConfigMap` | create, delete, get, list, patch, update, watch |
29+
| - | `Pod` | create, delete, get, list, patch, update, watch |
30+
| - | `ServiceAccount` | get, list, watch |
31+
| - | `Service` *(\*)* | create, delete, get, list, patch, update, watch |
32+
| `networking.k8s.io` | `Ingress` *(\*)* | create, delete, get, list, patch, update, watch |
33+
| `core.openfeature.dev` | `FeatureFlag` | create, delete, get, list, patch, update, watch |
34+
| `core.openfeature.dev` | `FeatureFlag Finalizers` | update |
35+
| `core.openfeature.dev` | `FeatureFlag Status` | get, patch, update |
36+
| `core.openfeature.dev` | `FeatureFlagSource` | create, delete, get, list, patch, update, watch |
37+
| `core.openfeature.dev` | `FeatureFlagSource Finalizers` | get, update |
38+
| `core.openfeature.dev` | `FeatureFlagSource Status` | get, patch, update |
39+
| `core.openfeature.dev` | `Flagd` | create, delete, get, list, patch, update, watch |
40+
| `core.openfeature.dev` | `Flagd Finalizers` | update |
41+
| `core.openfeature.dev` | `InProcessConfiguration` | create, delete, get, list, patch, update, watch |
42+
| `rbac.authorization.k8s.io` | `ClusterRoleBinding` | get, list, update, watch |
3843

3944
*(\*) Permissions for `Service` and `networking.k8s.ioIngress` are only granted if the `core.openfeature.dev.Flagd`
4045
CRD has been enabled via the `managerConfig.flagdResourceEnabled` helm value.*

0 commit comments

Comments
 (0)