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/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/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