diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 95051b0d4..b0fe2ccc6 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,4 +1,4 @@ { - ".": "0.8.2", + ".": "0.8.3", "apis": "0.2.44" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 287ed69e5..7c6b24906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [0.8.3](https://github.com/open-feature/open-feature-operator/compare/v0.8.2...v0.8.3) (2025-01-13) + + +### 🐛 Bug Fixes + +* Add --port argument in flagd pods for set flagd service port ([#710](https://github.com/open-feature/open-feature-operator/issues/710)) ([674dd16](https://github.com/open-feature/open-feature-operator/commit/674dd16ac4dca94f04160247c55121e266979e25)) +* flagd environment variables missing prefix ([#730](https://github.com/open-feature/open-feature-operator/issues/730)) ([0aa61ec](https://github.com/open-feature/open-feature-operator/commit/0aa61ec1419ec1d99f3c875dd6526ec8ca8e6014)) + ## [0.8.2](https://github.com/open-feature/open-feature-operator/compare/v0.8.1...v0.8.2) (2025-01-13) diff --git a/Makefile b/Makefile index 2d49d6c2b..46628b284 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ ARCH?=amd64 IMG?=$(RELEASE_REGISTRY)/$(RELEASE_IMAGE) # customize overlay to be used in the build, DEFAULT or HELM KUSTOMIZE_OVERLAY ?= DEFAULT -CHART_VERSION=v0.8.2# x-release-please-version +CHART_VERSION=v0.8.3# x-release-please-version # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. ENVTEST_K8S_VERSION = 1.26.1 WAIT_TIMEOUT_SECONDS?=60 diff --git a/apis/core/v1beta1/featureflagsource_types.go b/apis/core/v1beta1/featureflagsource_types.go index 7aff2fe05..5519a6fbc 100644 --- a/apis/core/v1beta1/featureflagsource_types.go +++ b/apis/core/v1beta1/featureflagsource_types.go @@ -28,10 +28,12 @@ import ( type FeatureFlagSourceSpec struct { // ManagemetPort defines the port to serve management on, defaults to 8014 // +optional + // +kubebuilder:default:=8014 ManagementPort int32 `json:"managementPort"` // Port defines the port to listen on, defaults to 8013 // +optional + // +kubebuilder:default:=8013 Port int32 `json:"port"` // SocketPath defines the unix socket path to listen on @@ -40,6 +42,7 @@ type FeatureFlagSourceSpec struct { // Evaluator sets an evaluator, defaults to 'json' // +optional + // +kubebuilder:default:="json" Evaluator string `json:"evaluator"` // SyncProviders define the syncProviders and associated configuration to be applied to the sidecar @@ -61,10 +64,12 @@ type FeatureFlagSourceSpec struct { // LogFormat allows for the sidecar log format to be overridden, defaults to 'json' // +optional + // +kubebuilder:default:="json" LogFormat string `json:"logFormat"` // EnvVarPrefix defines the prefix to be applied to all environment variables applied to the sidecar, default FLAGD // +optional + // +kubebuilder:default:="FLAGD" EnvVarPrefix string `json:"envVarPrefix"` // RolloutOnChange dictates whether annotated deployments will be restarted when configuration changes are diff --git a/chart/open-feature-operator/Chart.yaml b/chart/open-feature-operator/Chart.yaml index 5010f9a2b..c41b7337c 100755 --- a/chart/open-feature-operator/Chart.yaml +++ b/chart/open-feature-operator/Chart.yaml @@ -13,12 +13,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: "v0.8.2" # x-release-please-version +version: "v0.8.3" # x-release-please-version # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "v0.8.2" # x-release-please-version +appVersion: "v0.8.3" # x-release-please-version home: https://openfeature.dev icon: https://open-feature.github.io/open-feature-operator/chart/open-feature-operator/openfeature-logo.png diff --git a/chart/open-feature-operator/values.yaml b/chart/open-feature-operator/values.yaml index edb324f7b..30c3605b1 100644 --- a/chart/open-feature-operator/values.yaml +++ b/chart/open-feature-operator/values.yaml @@ -146,7 +146,7 @@ controllerManager: ## @param controllerManager.manager.image.repository Sets the image for the operator. repository: ghcr.io/open-feature/open-feature-operator ## @param controllerManager.manager.image.tag Sets the version tag for the operator. - tag: v0.8.2 # x-release-please-version + tag: v0.8.3 # x-release-please-version resources: limits: ## @param controllerManager.manager.resources.limits.cpu Sets cpu resource limits for operator. diff --git a/common/flagdinjector/flagdinjector.go b/common/flagdinjector/flagdinjector.go index 9bc8762d8..a5fb545a7 100644 --- a/common/flagdinjector/flagdinjector.go +++ b/common/flagdinjector/flagdinjector.go @@ -394,6 +394,8 @@ func (fi *FlagdContainerInjector) generateBasicFlagdContainer(flagSourceConfig * "start", "--management-port", fmt.Sprintf("%d", flagSourceConfig.ManagementPort), + "--port", + fmt.Sprintf("%d", flagSourceConfig.Port), }, ImagePullPolicy: common.FlagdImagePullPolicy, VolumeMounts: []corev1.VolumeMount{}, @@ -403,6 +405,10 @@ func (fi *FlagdContainerInjector) generateBasicFlagdContainer(flagSourceConfig * Name: "management", ContainerPort: flagSourceConfig.ManagementPort, }, + { + Name: "flagd", + ContainerPort: flagSourceConfig.Port, + }, }, SecurityContext: getSecurityContext(), Resources: fi.FlagdResourceRequirements, diff --git a/common/flagdinjector/flagdinjector_test.go b/common/flagdinjector/flagdinjector_test.go index 75f290831..1f658c5df 100644 --- a/common/flagdinjector/flagdinjector_test.go +++ b/common/flagdinjector/flagdinjector_test.go @@ -58,7 +58,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider(t *testing.T) { expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]"} require.Equal(t, expectedPod, pod) } @@ -93,7 +93,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithDebugLogging(t *te expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]", "--debug"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]", "--debug"} require.Equal(t, expectedPod, pod) } @@ -128,7 +128,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithOtelCollectorUri(t expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]", "--metrics-exporter", "otel", "--otel-collector-uri", "localhost:4317"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]", "--metrics-exporter", "otel", "--otel-collector-uri", "localhost:4317"} require.Equal(t, expectedPod, pod) } @@ -172,7 +172,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithResources(t *testi expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]"} expectedPod.Spec.Containers[1].Resources = flagSourceConfig.Resources require.Equal(t, expectedPod, pod) @@ -208,7 +208,7 @@ func TestFlagdContainerInjector_InjectDefaultSyncProvider_WithSyncProviderArgs(t expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]", "--sync-provider-args", "arg-1", "--sync-provider-args", "arg-2"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"\",\"provider\":\"grpc\"}]", "--sync-provider-args", "arg-1", "--sync-provider-args", "arg-2"} require.Equal(t, expectedPod, pod) } @@ -243,7 +243,7 @@ func TestFlagdContainerInjector_InjectFlagdKubernetesSource(t *testing.T) { expectedPod := getExpectedPod(namespace) - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"my-namespace/server-side\",\"provider\":\"kubernetes\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"my-namespace/server-side\",\"provider\":\"kubernetes\"}]"} require.Equal(t, expectedPod, pod) @@ -305,7 +305,7 @@ func TestFlagdContainerInjector_InjectFlagdFilePathSource(t *testing.T) { }, } - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"/etc/flagd/my-namespace_server-side/my-namespace_server-side.flagd.json\",\"provider\":\"file\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"/etc/flagd/my-namespace_server-side/my-namespace_server-side.flagd.json\",\"provider\":\"file\"}]"} expectedPod.Spec.Containers[1].VolumeMounts = []v1.VolumeMount{ { Name: "server-side", @@ -385,7 +385,7 @@ func TestFlagdContainerInjector_InjectFlagdFilePathSource_UpdateReferencedConfig }, } - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"/etc/flagd/my-namespace_server-side/my-namespace_server-side.flagd.json\",\"provider\":\"file\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"/etc/flagd/my-namespace_server-side/my-namespace_server-side.flagd.json\",\"provider\":\"file\"}]"} expectedPod.Spec.Containers[1].VolumeMounts = []v1.VolumeMount{ { Name: "server-side", @@ -441,7 +441,7 @@ func TestFlagdContainerInjector_InjectHttpSource(t *testing.T) { expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"http://localhost:8013\",\"provider\":\"http\",\"bearerToken\":\"my-token\",\"interval\":8}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"http://localhost:8013\",\"provider\":\"http\",\"bearerToken\":\"my-token\",\"interval\":8}]"} require.Equal(t, expectedPod, pod) } @@ -482,7 +482,7 @@ func TestFlagdContainerInjector_InjectGrpcSource(t *testing.T) { expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"grpc://localhost:8013\",\"provider\":\"grpc\",\"certPath\":\"cert-path\",\"tls\":true,\"providerID\":\"provider-id\",\"selector\":\"selector\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"grpc://localhost:8013\",\"provider\":\"grpc\",\"certPath\":\"cert-path\",\"tls\":true,\"providerID\":\"provider-id\",\"selector\":\"selector\"}]"} require.Equal(t, expectedPod, pod) } @@ -594,7 +594,7 @@ func TestFlagdContainerInjector_InjectProxySource_ProxyIsReady(t *testing.T) { expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--sources", "[{\"uri\":\"flagd-proxy-svc.my-namespace.svc.cluster.local:8013\",\"provider\":\"grpc\",\"selector\":\"core.openfeature.dev/my-namespace/\"}]"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013", "--sources", "[{\"uri\":\"flagd-proxy-svc.my-namespace.svc.cluster.local:8013\",\"provider\":\"grpc\",\"selector\":\"core.openfeature.dev/my-namespace/\"}]"} require.Equal(t, expectedPod, pod) } @@ -624,7 +624,7 @@ func TestFlagdContainerInjector_Inject_FlagdContainerAlreadyPresent(t *testing.T expectedPod := getExpectedPod(namespace) expectedPod.Annotations = nil - expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014"} + expectedPod.Spec.Containers[1].Args = []string{"start", "--management-port", "8014", "--port", "8013"} require.Equal(t, expectedPod, pod) } @@ -831,6 +831,10 @@ func getExpectedPod(namespace string) v1.Pod { Name: "management", ContainerPort: int32(8014), }, + { + Name: "flagd", + ContainerPort: int32(8013), + }, }, Env: []v1.EnvVar{ { diff --git a/config/crd/bases/core.openfeature.dev_featureflagsources.yaml b/config/crd/bases/core.openfeature.dev_featureflagsources.yaml index 68a28d342..c1288dbff 100644 --- a/config/crd/bases/core.openfeature.dev_featureflagsources.yaml +++ b/config/crd/bases/core.openfeature.dev_featureflagsources.yaml @@ -49,6 +49,7 @@ spec: description: DefaultSyncProvider defines the default sync provider type: string envVarPrefix: + default: FLAGD description: EnvVarPrefix defines the prefix to be applied to all environment variables applied to the sidecar, default FLAGD type: string @@ -173,13 +174,16 @@ spec: type: object type: array evaluator: + default: json description: Evaluator sets an evaluator, defaults to 'json' type: string logFormat: + default: json description: LogFormat allows for the sidecar log format to be overridden, defaults to 'json' type: string managementPort: + default: 8014 description: ManagemetPort defines the port to serve management on, defaults to 8014 format: int32 @@ -189,6 +193,7 @@ spec: flag of flagd sidecar. Default false (disabled). type: string port: + default: 8013 description: Port defines the port to listen on, defaults to 8013 format: int32 type: integer diff --git a/docs/crds.md b/docs/crds.md index ec676eaa4..d4c17eb09 100644 --- a/docs/crds.md +++ b/docs/crds.md @@ -279,6 +279,8 @@ FeatureFlagSourceSpec defines the desired state of FeatureFlagSource string EnvVarPrefix defines the prefix to be applied to all environment variables applied to the sidecar, default FLAGD
+
+ Default: FLAGD
false @@ -294,6 +296,8 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de string Evaluator sets an evaluator, defaults to 'json'
+
+ Default: json
false @@ -301,6 +305,8 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de string LogFormat allows for the sidecar log format to be overridden, defaults to 'json'
+
+ Default: json
false @@ -310,6 +316,7 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de ManagemetPort defines the port to serve management on, defaults to 8014

Format: int32
+ Default: 8014
false @@ -326,6 +333,7 @@ are added at the lowest index, all values will have the EnvVarPrefix applied, de Port defines the port to listen on, defaults to 8013

Format: int32
+ Default: 8013
false diff --git a/docs/installation.md b/docs/installation.md index c62ce216b..919c53113 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -62,13 +62,13 @@ Apply the release yaml directly via kubectl ```sh kubectl create namespace open-feature-operator-system && -kubectl apply -f https://github.com/open-feature/open-feature-operator/releases/download/v0.8.2/release.yaml +kubectl apply -f https://github.com/open-feature/open-feature-operator/releases/download/v0.8.3/release.yaml ``` ### Uninstall ```sh -kubectl delete -f https://github.com/open-feature/open-feature-operator/releases/download/v0.8.2/release.yaml && +kubectl delete -f https://github.com/open-feature/open-feature-operator/releases/download/v0.8.3/release.yaml && kubectl delete namespace open-feature-operator-system ``` diff --git a/docs/quick_start.md b/docs/quick_start.md index 8ebe79bf9..904309fbe 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -40,7 +40,7 @@ helm upgrade --install openfeature openfeature/open-feature-operator ```sh kubectl create namespace open-feature-operator-system && -kubectl apply -f https://github.com/open-feature/open-feature-operator/releases/download/v0.8.2/release.yaml +kubectl apply -f https://github.com/open-feature/open-feature-operator/releases/download/v0.8.3/release.yaml ``` diff --git a/test/e2e/chainsaw/flagd-with-custom-ports/00-assert.yaml b/test/e2e/chainsaw/flagd-with-custom-ports/00-assert.yaml new file mode 100644 index 000000000..be38eaf0e --- /dev/null +++ b/test/e2e/chainsaw/flagd-with-custom-ports/00-assert.yaml @@ -0,0 +1,90 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: flagd-sample + app.kubernetes.io/managed-by: open-feature-operator + app.kubernetes.io/name: flagd-sample + name: flagd-sample + namespace: ($namespace) + ownerReferences: + - apiVersion: core.openfeature.dev/v1beta1 + kind: Flagd + name: flagd-sample +spec: + replicas: 1 + selector: + matchLabels: + app: flagd-sample + template: + metadata: + labels: + app: flagd-sample + app.kubernetes.io/managed-by: open-feature-operator + app.kubernetes.io/name: flagd-sample + spec: + containers: + - name: flagd + # renovate: datasource=github-tags depName=open-feature/flagd/flagd + image: ghcr.io/open-feature/flagd:v0.11.1 + ports: + - containerPort: 8014 + name: management + protocol: TCP + - containerPort: 8013 + name: flagd + protocol: TCP + - containerPort: 8016 + name: ofrep + protocol: TCP + - containerPort: 8015 + name: sync + protocol: TCP + env: + - name: FLAGD_MANAGEMENT_PORT + value: "9999" + - name: FLAGD_PORT + value: "8888" + - name: FLAGD_EVALUATOR + value: json + - name: FLAGD_LOG_FORMAT + value: json + - name: FLAGD_RESOLVER + value: rpc + serviceAccount: default + serviceAccountName: default +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: flagd-sample + app.kubernetes.io/managed-by: open-feature-operator + app.kubernetes.io/name: flagd-sample + name: flagd-sample + namespace: ($namespace) + ownerReferences: + - apiVersion: core.openfeature.dev/v1beta1 + kind: Flagd + name: flagd-sample +spec: + ports: + - name: flagd + port: 8013 + protocol: TCP + targetPort: 8013 + - name: ofrep + port: 8016 + protocol: TCP + targetPort: 8016 + - name: sync + port: 8015 + protocol: TCP + targetPort: 8015 + - name: metrics + port: 8014 + protocol: TCP + targetPort: 8014 + selector: + app: flagd-sample + type: ClusterIP diff --git a/test/e2e/chainsaw/flagd-with-custom-ports/00-install.yaml b/test/e2e/chainsaw/flagd-with-custom-ports/00-install.yaml new file mode 100644 index 000000000..75d860cf2 --- /dev/null +++ b/test/e2e/chainsaw/flagd-with-custom-ports/00-install.yaml @@ -0,0 +1,34 @@ +apiVersion: core.openfeature.dev/v1beta1 +kind: FeatureFlag +metadata: + name: featureflag-sample +spec: + flagSpec: + flags: + "simple-flag": + state: "ENABLED" + variants: + "on": true + "off": false + defaultVariant: "on" +--- +apiVersion: core.openfeature.dev/v1beta1 +kind: FeatureFlagSource +metadata: + name: end-to-end +spec: + sources: + - source: featureflag-sample + provider: kubernetes + port: 8888 + managementPort: 9999 + evaluator: json +--- +apiVersion: core.openfeature.dev/v1beta1 +kind: Flagd +metadata: + name: flagd-sample +spec: + serviceType: ClusterIP + serviceAccountName: default + featureFlagSource: end-to-end diff --git a/test/e2e/chainsaw/flagd-with-custom-ports/chainsaw-test.yaml b/test/e2e/chainsaw/flagd-with-custom-ports/chainsaw-test.yaml new file mode 100644 index 000000000..63a4a9cc6 --- /dev/null +++ b/test/e2e/chainsaw/flagd-with-custom-ports/chainsaw-test.yaml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: flagd-custom-ports +spec: + steps: + - name: step-00 + try: + - apply: + file: ../assets/gateway-api.yaml + - name: step-01 + try: + - apply: + file: 00-install.yaml + - assert: + file: 00-assert.yaml