Skip to content

Commit 0aa61ec

Browse files
fix: flagd environment variables missing prefix (#730)
Signed-off-by: Lukas Reining <lukas.reining@codecentric.de>
1 parent 674dd16 commit 0aa61ec

File tree

6 files changed

+159
-0
lines changed

6 files changed

+159
-0
lines changed

apis/core/v1beta1/featureflagsource_types.go

+5
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ import (
2828
type FeatureFlagSourceSpec struct {
2929
// ManagemetPort defines the port to serve management on, defaults to 8014
3030
// +optional
31+
// +kubebuilder:default:=8014
3132
ManagementPort int32 `json:"managementPort"`
3233

3334
// Port defines the port to listen on, defaults to 8013
3435
// +optional
36+
// +kubebuilder:default:=8013
3537
Port int32 `json:"port"`
3638

3739
// SocketPath defines the unix socket path to listen on
@@ -40,6 +42,7 @@ type FeatureFlagSourceSpec struct {
4042

4143
// Evaluator sets an evaluator, defaults to 'json'
4244
// +optional
45+
// +kubebuilder:default:="json"
4346
Evaluator string `json:"evaluator"`
4447

4548
// SyncProviders define the syncProviders and associated configuration to be applied to the sidecar
@@ -61,10 +64,12 @@ type FeatureFlagSourceSpec struct {
6164

6265
// LogFormat allows for the sidecar log format to be overridden, defaults to 'json'
6366
// +optional
67+
// +kubebuilder:default:="json"
6468
LogFormat string `json:"logFormat"`
6569

6670
// EnvVarPrefix defines the prefix to be applied to all environment variables applied to the sidecar, default FLAGD
6771
// +optional
72+
// +kubebuilder:default:="FLAGD"
6873
EnvVarPrefix string `json:"envVarPrefix"`
6974

7075
// RolloutOnChange dictates whether annotated deployments will be restarted when configuration changes are

config/crd/bases/core.openfeature.dev_featureflagsources.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spec:
4949
description: DefaultSyncProvider defines the default sync provider
5050
type: string
5151
envVarPrefix:
52+
default: FLAGD
5253
description: EnvVarPrefix defines the prefix to be applied to all
5354
environment variables applied to the sidecar, default FLAGD
5455
type: string
@@ -173,13 +174,16 @@ spec:
173174
type: object
174175
type: array
175176
evaluator:
177+
default: json
176178
description: Evaluator sets an evaluator, defaults to 'json'
177179
type: string
178180
logFormat:
181+
default: json
179182
description: LogFormat allows for the sidecar log format to be overridden,
180183
defaults to 'json'
181184
type: string
182185
managementPort:
186+
default: 8014
183187
description: ManagemetPort defines the port to serve management on,
184188
defaults to 8014
185189
format: int32
@@ -189,6 +193,7 @@ spec:
189193
flag of flagd sidecar. Default false (disabled).
190194
type: string
191195
port:
196+
default: 8013
192197
description: Port defines the port to listen on, defaults to 8013
193198
format: int32
194199
type: integer

docs/crds.md

+8
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ FeatureFlagSourceSpec defines the desired state of FeatureFlagSource
279279
<td>string</td>
280280
<td>
281281
EnvVarPrefix defines the prefix to be applied to all environment variables applied to the sidecar, default FLAGD<br/>
282+
<br/>
283+
<i>Default</i>: FLAGD<br/>
282284
</td>
283285
<td>false</td>
284286
</tr><tr>
@@ -294,13 +296,17 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de
294296
<td>string</td>
295297
<td>
296298
Evaluator sets an evaluator, defaults to 'json'<br/>
299+
<br/>
300+
<i>Default</i>: json<br/>
297301
</td>
298302
<td>false</td>
299303
</tr><tr>
300304
<td><b>logFormat</b></td>
301305
<td>string</td>
302306
<td>
303307
LogFormat allows for the sidecar log format to be overridden, defaults to 'json'<br/>
308+
<br/>
309+
<i>Default</i>: json<br/>
304310
</td>
305311
<td>false</td>
306312
</tr><tr>
@@ -310,6 +316,7 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de
310316
ManagemetPort defines the port to serve management on, defaults to 8014<br/>
311317
<br/>
312318
<i>Format</i>: int32<br/>
319+
<i>Default</i>: 8014<br/>
313320
</td>
314321
<td>false</td>
315322
</tr><tr>
@@ -326,6 +333,7 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de
326333
Port defines the port to listen on, defaults to 8013<br/>
327334
<br/>
328335
<i>Format</i>: int32<br/>
336+
<i>Default</i>: 8013<br/>
329337
</td>
330338
<td>false</td>
331339
</tr><tr>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: flagd-sample
6+
app.kubernetes.io/managed-by: open-feature-operator
7+
app.kubernetes.io/name: flagd-sample
8+
name: flagd-sample
9+
namespace: ($namespace)
10+
ownerReferences:
11+
- apiVersion: core.openfeature.dev/v1beta1
12+
kind: Flagd
13+
name: flagd-sample
14+
spec:
15+
replicas: 1
16+
selector:
17+
matchLabels:
18+
app: flagd-sample
19+
template:
20+
metadata:
21+
labels:
22+
app: flagd-sample
23+
app.kubernetes.io/managed-by: open-feature-operator
24+
app.kubernetes.io/name: flagd-sample
25+
spec:
26+
containers:
27+
- name: flagd
28+
# renovate: datasource=github-tags depName=open-feature/flagd/flagd
29+
image: ghcr.io/open-feature/flagd:v0.11.1
30+
ports:
31+
- containerPort: 8014
32+
name: management
33+
protocol: TCP
34+
- containerPort: 8013
35+
name: flagd
36+
protocol: TCP
37+
- containerPort: 8016
38+
name: ofrep
39+
protocol: TCP
40+
- containerPort: 8015
41+
name: sync
42+
protocol: TCP
43+
env:
44+
- name: FLAGD_MANAGEMENT_PORT
45+
value: "9999"
46+
- name: FLAGD_PORT
47+
value: "8888"
48+
- name: FLAGD_EVALUATOR
49+
value: json
50+
- name: FLAGD_LOG_FORMAT
51+
value: json
52+
- name: FLAGD_RESOLVER
53+
value: rpc
54+
serviceAccount: default
55+
serviceAccountName: default
56+
---
57+
apiVersion: v1
58+
kind: Service
59+
metadata:
60+
labels:
61+
app: flagd-sample
62+
app.kubernetes.io/managed-by: open-feature-operator
63+
app.kubernetes.io/name: flagd-sample
64+
name: flagd-sample
65+
namespace: ($namespace)
66+
ownerReferences:
67+
- apiVersion: core.openfeature.dev/v1beta1
68+
kind: Flagd
69+
name: flagd-sample
70+
spec:
71+
ports:
72+
- name: flagd
73+
port: 8013
74+
protocol: TCP
75+
targetPort: 8013
76+
- name: ofrep
77+
port: 8016
78+
protocol: TCP
79+
targetPort: 8016
80+
- name: sync
81+
port: 8015
82+
protocol: TCP
83+
targetPort: 8015
84+
- name: metrics
85+
port: 8014
86+
protocol: TCP
87+
targetPort: 8014
88+
selector:
89+
app: flagd-sample
90+
type: ClusterIP
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: core.openfeature.dev/v1beta1
2+
kind: FeatureFlag
3+
metadata:
4+
name: featureflag-sample
5+
spec:
6+
flagSpec:
7+
flags:
8+
"simple-flag":
9+
state: "ENABLED"
10+
variants:
11+
"on": true
12+
"off": false
13+
defaultVariant: "on"
14+
---
15+
apiVersion: core.openfeature.dev/v1beta1
16+
kind: FeatureFlagSource
17+
metadata:
18+
name: end-to-end
19+
spec:
20+
sources:
21+
- source: featureflag-sample
22+
provider: kubernetes
23+
port: 8888
24+
managementPort: 9999
25+
evaluator: json
26+
---
27+
apiVersion: core.openfeature.dev/v1beta1
28+
kind: Flagd
29+
metadata:
30+
name: flagd-sample
31+
spec:
32+
serviceType: ClusterIP
33+
serviceAccountName: default
34+
featureFlagSource: end-to-end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
name: flagd-custom-ports
6+
spec:
7+
steps:
8+
- name: step-00
9+
try:
10+
- apply:
11+
file: ../assets/gateway-api.yaml
12+
- name: step-01
13+
try:
14+
- apply:
15+
file: 00-install.yaml
16+
- assert:
17+
file: 00-assert.yaml

0 commit comments

Comments
 (0)