Skip to content

Commit 56ad0bd

Browse files
authored
feat: add flagd sidecar resources attribute (#514)
Signed-off-by: Leopold Jacquot <[email protected]>
1 parent 31d8d5a commit 56ad0bd

File tree

13 files changed

+218
-10
lines changed

13 files changed

+218
-10
lines changed

apis/core/v1alpha1/flagsourceconfiguration_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ type FlagSourceConfigurationSpec struct {
132132
// OtelCollectorUri defines whether to enable --otel-collector-uri flag of flagd sidecar. Default false (disabled).
133133
// +optional
134134
OtelCollectorUri string `json:"otelCollectorUri"`
135+
136+
// Resources defines flagd sidecar resources. Default to operator sidecar-cpu-* and sidecar-ram-* flags.
137+
// +optional
138+
Resources corev1.ResourceRequirements `json:"resources"`
135139
}
136140

137141
type Source struct {

apis/core/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/core/v1alpha2/featureflagconfiguration_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ type FeatureFlagConfigurationSpec struct {
4545
FlagDSpec *FlagDSpec `json:"flagDSpec"`
4646
// FeatureFlagSpec is the structured representation of the feature flag specification
4747
FeatureFlagSpec FeatureFlagSpec `json:"featureFlagSpec,omitempty"`
48+
// Resources defines flagd sidecar resources. Default to operator sidecar-cpu-* and sidecar-ram-* flags.
49+
// +optional
50+
Resources corev1.ResourceRequirements `json:"resources"`
4851
}
4952

5053
type FlagDSpec struct {

apis/core/v1alpha2/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/core/v1alpha3/flagsourceconfiguration_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ type FlagSourceConfigurationSpec struct {
9696
// OtelCollectorUri defines whether to enable --otel-collector-uri flag of flagd sidecar. Default false (disabled).
9797
// +optional
9898
OtelCollectorUri string `json:"otelCollectorUri"`
99+
100+
// Resources defines flagd sidecar resources. Default to operator sidecar-cpu-* and sidecar-ram-* flags.
101+
// +optional
102+
Resources corev1.ResourceRequirements `json:"resources"`
99103
}
100104

101105
type Source struct {

apis/core/v1alpha3/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart/open-feature-operator/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ The command removes all the Kubernetes components associated with the chart and
108108
| `sidecarConfiguration.probesEnabled` | Enable or Disable Liveness and Readiness probes of the flagd sidecar. When enabled, HTTP probes( paths - `/readyz`, `/healthz`) are set with an initial delay of 5 seconds. | `true` |
109109
| `sidecarConfiguration.debugLogging` | Controls the addition of the `--debug` flag to the container startup arguments. | `false` |
110110
| `sidecarConfiguration.otelCollectorUri` | Otel exporter uri. | `""` |
111+
| `sidecarConfiguration.resources` | Override resources of the flagd sidecar. | `{}` |
111112

112113
### Flagd-proxy configuration
113114

chart/open-feature-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ sidecarConfiguration:
3333
debugLogging: false
3434
## @param sidecarConfiguration.otelCollectorUri Otel exporter uri.
3535
otelCollectorUri: ""
36+
## @param sidecarConfiguration.resources Override resources of the flagd sidecar.
37+
resources: { }
3638

3739
## @section Flagd-proxy configuration
3840
flagdProxyConfiguration:

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,54 @@ spec:
189189
description: ProbesEnabled defines whether to enable liveness and
190190
readiness probes of flagd sidecar. Default true (enabled).
191191
type: boolean
192+
resources:
193+
description: Resources defines flagd sidecar resources. Default to
194+
operator sidecar-cpu-limit and sidecar-ram-limit flags.
195+
properties:
196+
claims:
197+
description: "Claims lists the names of resources, defined in
198+
spec.resourceClaims, that are used by this container. \n This
199+
is an alpha field and requires enabling the DynamicResourceAllocation
200+
feature gate. \n This field is immutable. It can only be set
201+
for containers."
202+
items:
203+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
204+
properties:
205+
name:
206+
description: Name must match the name of one entry in pod.spec.resourceClaims
207+
of the Pod where this field is used. It makes that resource
208+
available inside a container.
209+
type: string
210+
required:
211+
- name
212+
type: object
213+
type: array
214+
x-kubernetes-list-map-keys:
215+
- name
216+
x-kubernetes-list-type: map
217+
limits:
218+
additionalProperties:
219+
anyOf:
220+
- type: integer
221+
- type: string
222+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
223+
x-kubernetes-int-or-string: true
224+
description: 'Limits describes the maximum amount of compute resources
225+
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
226+
type: object
227+
requests:
228+
additionalProperties:
229+
anyOf:
230+
- type: integer
231+
- type: string
232+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
233+
x-kubernetes-int-or-string: true
234+
description: 'Requests describes the minimum amount of compute
235+
resources required. If Requests is omitted for a container,
236+
it defaults to Limits if that is explicitly specified, otherwise
237+
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
238+
type: object
239+
type: object
192240
rolloutOnChange:
193241
description: RolloutOnChange dictates whether annotated deployments
194242
will be restarted when configuration changes are detected in this

controllers/common/flagd-injector.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ func (fi *FlagdContainerInjector) InjectFlagd(
104104
)
105105
}
106106

107+
if len(flagSourceConfig.Resources.Requests) != 0 {
108+
flagdContainer.Resources.Requests = flagSourceConfig.Resources.Requests
109+
}
110+
111+
if len(flagSourceConfig.Resources.Limits) != 0 {
112+
flagdContainer.Resources.Limits = flagSourceConfig.Resources.Limits
113+
}
114+
107115
addFlagdContainer(podSpec, flagdContainer)
108116

109117
return nil

0 commit comments

Comments
 (0)