Skip to content

Commit

Permalink
feat: enable flagd probes (#390)
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
  • Loading branch information
Kavindu-Dodan authored Mar 16, 2023
1 parent dd34801 commit 41efb15
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 34 deletions.
22 changes: 21 additions & 1 deletion apis/core/v1alpha1/flagsourceconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
SidecarProviderArgsEnvVar string = "PROVIDER_ARGS"
SidecarDefaultSyncProviderEnvVar string = "SYNC_PROVIDER"
SidecarLogFormatEnvVar string = "LOG_FORMAT"
SidecarProbesEnabledVar string = "PROBES_ENABLED"
defaultSidecarEnvVarPrefix string = "FLAGD"
DefaultMetricPort int32 = 8014
defaultPort int32 = 8013
Expand All @@ -49,10 +50,10 @@ const (
// INPUT_FLAGD_VERSION` is replaced in the `update-flagd` Makefile target
defaultTag string = "INPUT_FLAGD_VERSION"
defaultLogFormat string = "json"
defaultProbesEnabled bool = true
SyncProviderKubernetes SyncProviderType = "kubernetes"
SyncProviderFilepath SyncProviderType = "filepath"
SyncProviderHttp SyncProviderType = "http"
defaultSyncProvider = SyncProviderKubernetes
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down Expand Up @@ -116,6 +117,10 @@ type FlagSourceConfigurationSpec struct {
// detected in this CR, defaults to false
// +optional
RolloutOnChange *bool `json:"rolloutOnChange"`

// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true(enabled)
// +optional
ProbesEnabled *bool `json:"probesEnabled"`
}

type Source struct {
Expand Down Expand Up @@ -175,6 +180,10 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
RolloutOnChange: nil,
}

// set default value derived from constant default
probes := defaultProbesEnabled
fsc.ProbesEnabled = &probes

if metricsPort := os.Getenv(envVarKey(InputConfigurationEnvVarPrefix, SidecarMetricPortEnvVar)); metricsPort != "" {
metricsPortI, err := strconv.Atoi(metricsPort)
if err != nil {
Expand Down Expand Up @@ -223,6 +232,14 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
fsc.EnvVarPrefix = envVarPrefix
}

if probesEnabled := os.Getenv(fmt.Sprintf("%s_%s", InputConfigurationEnvVarPrefix, SidecarProbesEnabledVar)); probesEnabled != "" {
b, err := strconv.ParseBool(probesEnabled)
if err != nil {
return fsc, fmt.Errorf("unable to parse sidecar probes enabled %s to boolean: %w", probesEnabled, err)
}
fsc.ProbesEnabled = &b
}

return fsc, nil
}

Expand Down Expand Up @@ -269,6 +286,9 @@ func (fc *FlagSourceConfigurationSpec) Merge(new *FlagSourceConfigurationSpec) {
if new.RolloutOnChange != nil {
fc.RolloutOnChange = new.RolloutOnChange
}
if new.ProbesEnabled != nil {
fc.ProbesEnabled = new.ProbesEnabled
}
}

func (fc *FlagSourceConfigurationSpec) ToEnvVars() []corev1.EnvVar {
Expand Down
5 changes: 5 additions & 0 deletions apis/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apis/core/v1alpha2/flagsourceconfiguration_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (src *FlagSourceConfiguration) ConvertTo(dstRaw conversion.Hub) error {
SyncProviderArgs: src.Spec.SyncProviderArgs,
LogFormat: src.Spec.LogFormat,
DefaultSyncProvider: v1alpha1.SyncProviderType(src.Spec.DefaultSyncProvider),
ProbesEnabled: src.Spec.ProbesEnabled,
}
return nil
}
Expand All @@ -71,6 +72,7 @@ func (dst *FlagSourceConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
SyncProviderArgs: src.Spec.SyncProviderArgs,
LogFormat: src.Spec.LogFormat,
DefaultSyncProvider: string(src.Spec.DefaultSyncProvider),
ProbesEnabled: src.Spec.ProbesEnabled,
}
return nil
}
4 changes: 4 additions & 0 deletions apis/core/v1alpha2/flagsourceconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type FlagSourceConfigurationSpec struct {
// LogFormat allows for the sidecar log format to be overridden, defaults to 'json'
// +optional
LogFormat string `json:"logFormat"`

// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true(enabled)
// +optional
ProbesEnabled *bool `json:"probesEnabled"`
}

// FlagSourceConfigurationStatus defines the observed state of FlagSourceConfiguration
Expand Down
5 changes: 5 additions & 0 deletions apis/core/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apis/core/v1alpha3/flagsourceconfiguration_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (src *FlagSourceConfiguration) ConvertTo(dstRaw conversion.Hub) error {
LogFormat: src.Spec.LogFormat,
EnvVarPrefix: src.Spec.EnvVarPrefix,
RolloutOnChange: src.Spec.RolloutOnChange,
ProbesEnabled: src.Spec.ProbesEnabled,
}
return nil
}
Expand Down Expand Up @@ -94,6 +95,7 @@ func (dst *FlagSourceConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
LogFormat: src.Spec.LogFormat,
EnvVarPrefix: src.Spec.EnvVarPrefix,
RolloutOnChange: src.Spec.RolloutOnChange,
ProbesEnabled: src.Spec.ProbesEnabled,
}
return nil
}
4 changes: 4 additions & 0 deletions apis/core/v1alpha3/flagsourceconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ type FlagSourceConfigurationSpec struct {
// detected in this CR, defaults to false
// +optional
RolloutOnChange *bool `json:"rolloutOnChange"`

// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true(enabled)
// +optional
ProbesEnabled *bool `json:"probesEnabled"`
}

type Source struct {
Expand Down
5 changes: 5 additions & 0 deletions apis/core/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 32 additions & 31 deletions chart/open-feature-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,41 @@ The command removes all the Kubernetes components associated with the chart and

### Sidecar configuration

| Value | Default | Explanation |
| ----------- | ----------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sidecarConfiguration.envVarPrefix` | `FLAGD` | Sets the prefix for all environment variables set in the injected sidecar. |
| `sidecarConfiguration.port` | 8013 | Sets the value of the `XXX_PORT` environment variable for the injected sidecar container. |
| `sidecarConfiguration.metricsPort` | 8014 | Sets the value of the `XXX_METRICS_PORT` environment variable for the injected sidecar container. |
| `sidecarConfiguration.socketPath` | `""` | Sets the value of the `XXX_SOCKET_PATH` environment variable for the injected sidecar container. |
| `sidecarConfiguration.image.repository` | `ghcr.io/open-feature/flagd` | Sets the image for the injected sidecar container. |
| `sidecarConfiguration.image.tag` | current flagd version: `v0.4.1` | Sets the version tag for the injected sidecar container. |
| `sidecarConfiguration.providerArgs` | `""` | Used to append arguments to the sidecar startup command. This value is a comma separated string of key values separated by '=', e.g. `key=value,key2=value2` results in the appending of `--sync-provider-args key=value --sync-provider-args key2=value2` |
| `sidecarConfiguration.defaultSyncProvider` | `kubernetes` | Sets the value of the `XXX_SYNC_PROVIDER` environment variable for the injected sidecar container. There are 3 valid sync providers: `kubernetes`, `filepath` and `http` |
| `sidecarConfiguration.logFormat` | `json` | Sets the value of the `XXX_LOG_FORMAT` environment variable for the injected sidecar container. |
| `sidecarConfiguration.evaluator` | `json` | Sets the value of the `XXX_EVALUATOR` environment variable for the injected sidecar container.|
| Value | Default | Explanation |
|--------------------------------------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sidecarConfiguration.envVarPrefix` | `FLAGD` | Sets the prefix for all environment variables set in the injected sidecar. |
| `sidecarConfiguration.port` | 8013 | Sets the value of the `XXX_PORT` environment variable for the injected sidecar container. |
| `sidecarConfiguration.metricsPort` | 8014 | Sets the value of the `XXX_METRICS_PORT` environment variable for the injected sidecar container. |
| `sidecarConfiguration.socketPath` | `""` | Sets the value of the `XXX_SOCKET_PATH` environment variable for the injected sidecar container. |
| `sidecarConfiguration.image.repository` | `ghcr.io/open-feature/flagd` | Sets the image for the injected sidecar container. |
| `sidecarConfiguration.image.tag` | current flagd version: `v0.4.1` | Sets the version tag for the injected sidecar container. |
| `sidecarConfiguration.providerArgs` | `""` | Used to append arguments to the sidecar startup command. This value is a comma separated string of key values separated by '=', e.g. `key=value,key2=value2` results in the appending of `--sync-provider-args key=value --sync-provider-args key2=value2` |
| `sidecarConfiguration.defaultSyncProvider` | `kubernetes` | Sets the value of the `XXX_SYNC_PROVIDER` environment variable for the injected sidecar container. There are 3 valid sync providers: `kubernetes`, `filepath` and `http` |
| `sidecarConfiguration.logFormat` | `json` | Sets the value of the `XXX_LOG_FORMAT` environment variable for the injected sidecar container. |
| `sidecarConfiguration.evaluator` | `json` | Sets the value of the `XXX_EVALUATOR` environment variable for the injected sidecar container. |
| `sidecarConfiguration.probesEnabled` | `true` | 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 |

### Operator resource configuration

| Value | Default |
| ----------- | ----------- |
| `defaultNamespace` | `open-feature-operator` | [INTERNAL USE ONLY] To override the namespace use the `--namespace` flag. This default is provided to ensure that the kustomize build charts in `/templates` deploy correctly when no `namespace` is provided via the `-n` flag.|
| `controllerManager.kubeRbacProxy.image.repository` | `gcr.io/kubebuilder/kube-rbac-proxy` |
| `controllerManager.kubeRbacProxy.image.tag` | `v0.13.1` |
| `controllerManager.kubeRbacProxy.resources.limits.cpu` | `500m` |
| `controllerManager.kubeRbacProxy.resources.limits.memory` | `128Mi` |
| `controllerManager.kubeRbacProxy.resources.requests.cpu` | `5m` |
| `controllerManager.kubeRbacProxy.resources.requests.memory` | `64Mi` |
| `controllerManager.manager.image.repository` | `ghcr.io/open-feature/open-feature-operator` |
| `controllerManager.manager.image.tag` | <!-- x-release-please-start-version --> `v0.2.28` <!-- x-release-please-end --> |
| `controllerManager.manager.resources.limits.cpu` | `500m` |
| `controllerManager.manager.resources.limits.memory` | `128Mi` |
| `controllerManager.manager.resources.requests.cpu` | `10m` |
| `controllerManager.manager.resources.requests.memory` | `64Mi` |
| `managerConfig.controllerManagerConfigYaml` | `1` |
| `managerConfig.replicas.health.healthProbeBindAddress` | `:8081` |
| `managerConfig.replicas.metrics.bindAddress` | `0.2.29.1:8080` |
| `managerConfig.replicas.webhook.port` | `9443` |
| Value | Default |
|-------------------------------------------------------------|---------------------------------------------------------------------------------|
| `defaultNamespace` | `open-feature-operator` | [INTERNAL USE ONLY] To override the namespace use the `--namespace` flag. This default is provided to ensure that the kustomize build charts in `/templates` deploy correctly when no `namespace` is provided via the `-n` flag.|
| `controllerManager.kubeRbacProxy.image.repository` | `gcr.io/kubebuilder/kube-rbac-proxy` |
| `controllerManager.kubeRbacProxy.image.tag` | `v0.13.1` |
| `controllerManager.kubeRbacProxy.resources.limits.cpu` | `500m` |
| `controllerManager.kubeRbacProxy.resources.limits.memory` | `128Mi` |
| `controllerManager.kubeRbacProxy.resources.requests.cpu` | `5m` |
| `controllerManager.kubeRbacProxy.resources.requests.memory` | `64Mi` |
| `controllerManager.manager.image.repository` | `ghcr.io/open-feature/open-feature-operator` |
| `controllerManager.manager.image.tag` | <!-- x-release-please-start-version --> `v0.2.28` <!-- x-release-please-end --> |
| `controllerManager.manager.resources.limits.cpu` | `500m` |
| `controllerManager.manager.resources.limits.memory` | `128Mi` |
| `controllerManager.manager.resources.requests.cpu` | `10m` |
| `controllerManager.manager.resources.requests.memory` | `64Mi` |
| `managerConfig.controllerManagerConfigYaml` | `1` |
| `managerConfig.replicas.health.healthProbeBindAddress` | `:8081` |
| `managerConfig.replicas.metrics.bindAddress` | `0.2.29.1:8080` |
| `managerConfig.replicas.webhook.port` | `9443` |

## Changelog

Expand Down
1 change: 1 addition & 0 deletions chart/open-feature-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sidecarConfiguration:
defaultSyncProvider: kubernetes
evaluator: json
logFormat: "json"
probesEnabled: true

controllerManager:
kubeRbacProxy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ spec:
description: Port defines the port to listen on, defaults to 8013
format: int32
type: integer
probesEnabled:
description: ProbesEnabled defines whether to enable liveness and
readiness probes of flagd sidecar. Default true(enabled)
type: boolean
rolloutOnChange:
description: RolloutOnChange dictates whether annotated deployments
will be restarted when configuration changes are detected in this
Expand Down Expand Up @@ -272,6 +276,10 @@ spec:
description: Port defines the port to listen on, defaults to 8014
format: int32
type: integer
probesEnabled:
description: ProbesEnabled defines whether to enable liveness and
readiness probes of flagd sidecar. Default true(enabled)
type: boolean
socketPath:
description: SocketPath defines the unix socket path to listen on
type: string
Expand Down Expand Up @@ -455,6 +463,10 @@ spec:
description: Port defines the port to listen on, defaults to 8013
format: int32
type: integer
probesEnabled:
description: ProbesEnabled defines whether to enable liveness and
readiness probes of flagd sidecar. Default true(enabled)
type: boolean
rolloutOnChange:
description: RolloutOnChange dictates whether annotated deployments
will be restarted when configuration changes are detected in this
Expand Down
Loading

0 comments on commit 41efb15

Please sign in to comment.