Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
- name: Start the operator
run: |
if [[ "${{ inputs.test }}" == "test_flink_operator_ha.sh" ]]; then
sed -i "s/# kubernetes.operator.leader-election.enabled: false/kubernetes.operator.leader-election.enabled: true/" helm/flink-kubernetes-operator/conf/flink-conf.yaml
sed -i "s/# kubernetes.operator.leader-election.lease-name: flink-operator-lease/kubernetes.operator.leader-election.lease-name: flink-operator-lease/" helm/flink-kubernetes-operator/conf/flink-conf.yaml
sed -i "s/# kubernetes.operator.leader-election.enabled: false/kubernetes.operator.leader-election.enabled: true/" helm/flink-kubernetes-operator/conf/config.yaml
sed -i "s/# kubernetes.operator.leader-election.lease-name: flink-operator-lease/kubernetes.operator.leader-election.lease-name: flink-operator-lease/" helm/flink-kubernetes-operator/conf/config.yaml
sed -i "s/replicas: 1/replicas: 2/" helm/flink-kubernetes-operator/values.yaml
fi
if [[ "${{ inputs.test }}" == "test_dynamic_config.sh" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/development/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ basic-session-example-rest LoadBalancer 10.96.36.250 127.0.0.1 8081:30
```
The operator picks up the default log and flink configurations from `/opt/flink/conf`. You can put the rest configuration parameters here:
```bash
cat /opt/flink/conf/flink-conf.yaml
cat /opt/flink/conf/config.yaml
rest.port: 8081
rest.address: localhost
kubernetes.rest-service.exposed.type: LoadBalancer
Expand Down
17 changes: 17 additions & 0 deletions docs/content/docs/operations/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ defaultConfiguration:
kubernetes.operator.observer.progress-check.interval: 5 s
```

The configuration can also be supplied in Flink's modern YAML 1.2 `config.yaml` format (introduced in Flink 1.19 and the only format Flink 2.0 accepts) by defining the `config.yaml` key under `defaultConfiguration`:

```
defaultConfiguration:
create: true
append: true
config.yaml: |+
kubernetes.operator:
metrics.reporter.slf4j:
factory.class: org.apache.flink.metrics.slf4j.Slf4jReporterFactory
interval: 5 MINUTE
reconcile.interval: 15 s
observer.progress-check.interval: 5 s
```

When both `config.yaml` and `flink-conf.yaml` are set, `config.yaml` takes precedence. The operator always mounts the resolved configuration as `config.yaml`, so prefer the nested form shown above: a flat, dotted-key override of a key already present in the chart's default `conf/config.yaml` would otherwise be a duplicate key under Flink's strict YAML parser.

To learn more about metrics and logging configuration please refer to the dedicated [docs page]({{< ref "docs/operations/metrics-logging" >}}).

### Flink Version and Namespace specific defaults
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/operations/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ The configurable parameters of the Helm chart and which default values as detail
| Parameters | Description | Default Value |
|------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| defaultConfiguration.append | Whether to append configuration files with configs. | true |
| defaultConfiguration.config.yaml | The newer configuration file format for flink that will enforced in Flink 2.0. Note this was introduced in flink 1.19. | kubernetes.operator.metrics.reporter.slf4j.factory.class: org.apache.flink.metrics.slf4j.Slf4jReporterFactory<br/>kubernetes.operator.metrics.reporter.slf4j.interval: 5 MINUTE<br/>kubernetes.operator.reconcile.interval: 15 s<br/>kubernetes.operator.observer.progress-check.interval: 5 s |
| defaultConfiguration.config.yaml | Modern YAML 1.2 config format (introduced in Flink 1.19, required by Flink 2.0). Takes precedence over flink-conf.yaml when set; the resolved config is always mounted as config.yaml. | kubernetes.operator.metrics.reporter.slf4j.factory.class: org.apache.flink.metrics.slf4j.Slf4jReporterFactory<br/>kubernetes.operator.metrics.reporter.slf4j.interval: 5 MINUTE<br/>kubernetes.operator.reconcile.interval: 15 s<br/>kubernetes.operator.observer.progress-check.interval: 5 s |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chinese docs can be synced with the same english content.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

| defaultConfiguration.create | Whether to enable default configuration to create for flink-kubernetes-operator. | true |
| defaultConfiguration.flink-conf.yaml | The default configuration of flink-conf.yaml. | kubernetes.operator.metrics.reporter.slf4j.factory.class: org.apache.flink.metrics.slf4j.Slf4jReporterFactory<br/>kubernetes.operator.metrics.reporter.slf4j.interval: 5 MINUTE<br/>kubernetes.operator.reconcile.interval: 15 s<br/>kubernetes.operator.observer.progress-check.interval: 5 s |
| defaultConfiguration.flink-conf.yaml | Legacy flat config format. Used when config.yaml is not set; the resolved config is always mounted as config.yaml. | kubernetes.operator.metrics.reporter.slf4j.factory.class: org.apache.flink.metrics.slf4j.Slf4jReporterFactory<br/>kubernetes.operator.metrics.reporter.slf4j.interval: 5 MINUTE<br/>kubernetes.operator.reconcile.interval: 15 s<br/>kubernetes.operator.observer.progress-check.interval: 5 s |
| defaultConfiguration.log4j-console.properties | The default configuration of log4j-console.properties. | |
| defaultConfiguration.log4j-operator.properties | The default configuration of log4j-operator.properties. | |
| defaultConfiguration.logback-operator.xml | The default configuration of logback-operator.xml. Used when `logging.framework` is set to `logback`. | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
# limitations under the License.
################################################################################

# Flink job/cluster related configs
taskmanager.numberOfTaskSlots: 1
parallelism.default: 1

# These parameters are required for Java 17 support.
# Flink 1.18 uses env.java.opts.all, if a user supplies their own version of these opts in their FlinkDeployment the options below will be overridden.
# env.java.default-opts.all is used for 1.19 onwards so users can supply their own opts.all in their Job deployments and have these appended.
Expand Down
24 changes: 7 additions & 17 deletions helm/flink-kubernetes-operator/templates/controller/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,14 @@ metadata:
data:
config.yaml: |+
{{- if .Values.defaultConfiguration.append }}
{{- $.Files.Get "conf/flink-conf.yaml" | nindent 4 -}}
{{- $.Files.Get "conf/config.yaml" | nindent 4 -}}
{{- end }}
{{- if hasKey (.Values.defaultConfiguration) "config.yaml" }}
{{- index (.Values.defaultConfiguration) "config.yaml" | nindent 4 -}}
{{- end }}
{{- if .Values.watchNamespaces }}
kubernetes.operator.watched.namespaces: {{ join "," .Values.watchNamespaces }}
{{- end }}
{{- if index .Values "operatorHealth" }}
kubernetes.operator.health.probe.enabled: true
kubernetes.operator.health.probe.port: {{ .Values.operatorHealth.port }}
{{- end }}
flink-conf.yaml: |+
{{- if .Values.defaultConfiguration.append }}
{{- $.Files.Get "conf/flink-conf.yaml" | nindent 4 -}}
{{- end }}
Comment on lines -33 to -43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing these?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question — there are three separate edits in that hunk:

  1. The watchNamespaces / operatorHealth injections aren't actually dropped.
    The old template emitted two config-file keys (config.yaml and
    flink-conf.yaml) and appended both blocks to each, so they rendered twice.
    Collapsing to a single config.yaml key removes the duplicate — one copy still
    renders just below the resolver (lines 37–43); helm template confirms
    kubernetes.operator.health.probe.* and the watched.namespaces line still
    emit, once.

  2. The hasKey "config.yaml" block is replaced by the with-based resolver
    above it.
    That's the core of the ticket: hasKey keys off presence, and since
    the chart hardcodes a non-empty defaultConfiguration.flink-conf.yaml that a
    downstream -f values.yaml can't unset, the config.yaml branch was
    unreachable. with keys off value-truthiness (like the existing log4j/
    logback blocks), so the user's config.yaml actually wins.

  3. The flink-conf.yaml: key is removed so the ConfigMap emits a single,
    always-config.yaml file
    (the only name Flink 2.x reads), mounted statically.

The one behavioral consequence of (3) I'd like your read on before acting: runtime
patching of the operator ConfigMap now has to target the config.yaml key. In
particular e2e-tests/test_dynamic_flink_conf.sh patches the flink-conf.yaml
key and would no longer be picked up — its twin test_dynamic_config.sh already
covers the same dynamic-reload path via config.yaml. I'm inclined to drop
test_dynamic_flink_conf.sh (and its two ci.yml matrix rows) plus add a short
migration note, but since that removes legacy coverage I'd rather confirm with you
first.

(Aside, unrelated to this hunk: I've rebased onto latest main — the earlier
test_application_operations.sh smoke failure was a pipeline.jars/Flink 1.20.4
app-mode error on a stale base.)

{{- if hasKey (.Values.defaultConfiguration) "flink-conf.yaml" }}
{{- index (.Values.defaultConfiguration) "flink-conf.yaml" | nindent 4 -}}
{{- with (index .Values.defaultConfiguration "config.yaml") }}
{{- . | nindent 4 -}}
{{- else }}
{{- with (index .Values.defaultConfiguration "flink-conf.yaml") }}
{{- . | nindent 4 -}}
{{- end }}
{{- end }}
{{- if .Values.watchNamespaces }}
kubernetes.operator.watched.namespaces: {{ join "," .Values.watchNamespaces }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,8 @@ spec:
configMap:
name: flink-operator-config
items:
{{- if hasKey .Values.defaultConfiguration "flink-conf.yaml" }}
- key: flink-conf.yaml
path: flink-conf.yaml
{{- else }}
- key: config.yaml
path: config.yaml
{{- end }}
{{- if eq .Values.logging.framework "logback" }}
- key: logback-operator.xml
path: logback-operator.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,66 @@ tests:
asserts:
- isNotNull:
path: data["log4j-console.properties"]

# FLINK-39791: the ConfigMap emits a single config-file key, always named config.yaml,
# resolved as config.yaml (when set) > user flink-conf.yaml > the values.yaml default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment not needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- it: Emits a single config.yaml key with today's effective defaults and no redundant seed keys
asserts:
- isNotNull:
path: data["config.yaml"]
- notExists:
path: data["flink-conf.yaml"]
- matchRegex:
path: data["config.yaml"]
pattern: "(?m)^\\s*kubernetes.operator.metrics.reporter.slf4j.factory.class:"
- matchRegex:
path: data["config.yaml"]
pattern: "(?m)^\\s*kubernetes.operator.reconcile.interval: 15 s"
- matchRegex:
path: data["config.yaml"]
pattern: "(?m)^\\s*kubernetes.operator.health.probe.enabled: true"
- notMatchRegex:
path: data["config.yaml"]
pattern: "(?m)^\\s*taskmanager.numberOfTaskSlots:"
- notMatchRegex:
path: data["config.yaml"]
pattern: "(?m)^\\s*parallelism.default:"

- it: A user flink-conf.yaml override flows into config.yaml when config.yaml is unset
set:
defaultConfiguration:
flink-conf.yaml: |+
kubernetes.operator.reconcile.interval: 99 s
asserts:
- matchRegex:
path: data["config.yaml"]
pattern: "reconcile.interval: 99 s"

- it: When both are set, config.yaml wins and flink-conf.yaml is ignored
set:
defaultConfiguration:
config.yaml: |+
kubernetes.operator:
reconcile.interval: 30 s
flink-conf.yaml: |+
kubernetes.operator.reconcile.interval: 99 s
asserts:
- matchRegex:
path: data["config.yaml"]
pattern: "reconcile.interval: 30 s"
- notMatchRegex:
path: data["config.yaml"]
pattern: "reconcile.interval: 99 s"

- it: A flat config.yaml override of a former seed key is not duplicated (relies on dropping it from the seed)
set:
defaultConfiguration:
config.yaml: |+
taskmanager.numberOfTaskSlots: 2
asserts:
- matchRegex:
path: data["config.yaml"]
pattern: "taskmanager.numberOfTaskSlots: 2"
- notMatchRegex:
path: data["config.yaml"]
pattern: "taskmanager.numberOfTaskSlots: 1"
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,18 @@ tests:
key: log4j-operator.properties
path: log4j-operator.properties

# FLINK-39791: the operator config is always mounted as config.yaml (the only filename Flink 2.x
# reads), regardless of which defaultConfiguration key the user populates.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment not needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- it: Should mount the operator config as config.yaml by default
asserts:
- contains:
path: spec.template.spec.volumes[0].configMap.items
content:
key: config.yaml
path: config.yaml
- notContains:
path: spec.template.spec.volumes[0].configMap.items
content:
key: flink-conf.yaml
path: flink-conf.yaml

15 changes: 14 additions & 1 deletion helm/flink-kubernetes-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,27 @@ defaultConfiguration:
# This option has not effect, if create is equal to false.
append: true

# Uncomment to use the new config.yaml format, but also comment out the flink-config.yaml key.
# Operator configuration overrides go under ONE of the two keys below. If both are set,
# config.yaml wins; either way the operator mounts the result as config.yaml.
#
# config.yaml - modern YAML 1.2 format (Flink 1.19+, required by Flink 2.0). Recommended.
# flink-conf.yaml - legacy flat "key: value" format (shipped as the default below).
#
# Prefer the nested config.yaml form: a flat, dotted-key override of a key the chart already
# ships (e.g. the Java 17 opts in conf/config.yaml) would be a duplicate key under Flink's
# strict YAML parser and fail at operator startup. Example, equivalent to the default below:
#
# config.yaml: |+
# kubernetes.operator:
# metrics.reporter.slf4j:
# factory.class: org.apache.flink.metrics.slf4j.Slf4jReporterFactory
# interval: 5 MINUTE
# reconcile.interval: 15 s
# observer.progress-check.interval: 5 s
# taskmanager:
# numberOfTaskSlots: 1 # default for managed clusters; override per-job via spec.flinkConfiguration

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary to specify this property here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#
# Set job parallelism via spec.job.parallelism, not parallelism.default (the operator manages it).

flink-conf.yaml: |+
# Flink Config Overrides
Expand Down
Loading