Skip to content

🌱 Enable TLS for Flower addon SuperLink-SuperNode communication - #112

Merged
openshift-merge-bot[bot] merged 4 commits into
open-cluster-management-io:mainfrom
yanmxa:flower-addon-tls
Mar 31, 2026
Merged

🌱 Enable TLS for Flower addon SuperLink-SuperNode communication#112
openshift-merge-bot[bot] merged 4 commits into
open-cluster-management-io:mainfrom
yanmxa:flower-addon-tls

Conversation

@yanmxa

@yanmxa yanmxa commented Mar 31, 2026

Copy link
Copy Markdown
Member

Summary

  • Add hack/generate-certs.sh script to generate CA + server cert and create K8s Secrets
  • SuperLink: mount server cert secret, switch from --insecure to --ssl-* TLS flags
  • SuperNode: distribute CA cert as Secret via AddOnTemplate, use --root-certificates
  • Add tls.enabled toggle in values.yaml (default: false) for backward compatibility
  • Helm lookup with fail guard for clear error if certs not generated before install

Usage

# Generate certs
./flower-addon/hack/generate-certs.sh --hub-ip <HUB_NODE_IP>

# Deploy with TLS
helm install flower-addon ./flower-addon/charts/flower-addon \
  --set tls.enabled=true \
  --set deploymentConfig.superlinkAddress=<HUB_NODE_IP>

Verified

End-to-end TLS verification passed with CIFAR-10 federated learning (FedAvg, 3 rounds, 2 managed clusters):

Round Accuracy Loss
0 (initial) 9.98% 2.3062
1 19.00% 2.1262
2 15.57% 2.0893
3 (final) 18.07% 2.0968
  • SuperLink starts with --ssl-ca-certfile, --ssl-certfile, --ssl-keyfile
  • SuperNodes on managed clusters connect with --root-certificates (CA cert distributed via AddOnTemplate Secret)
  • flwr run submits jobs over TLS using ~/.flwr/config.toml with insecure = false and root-certificates
  • ClientApps successfully run in process isolation mode across both clusters

Test plan

  • Deploy without TLS (tls.enabled=false) — verify existing insecure behavior unchanged
  • Run generate-certs.sh — verify secrets created in flower-system
  • Deploy with TLS (tls.enabled=true) — verify SuperLink and SuperNode args
  • Run cifar10 federated learning example end-to-end over TLS

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added optional TLS-secured connections between SuperNode and SuperLink with CA and server certificate support.
  • Documentation

    • Added step-by-step guide for enabling and configuring TLS, including certificate provisioning and client configuration.
  • Chores

    • Added certificate generation tooling and updated deployment configuration to support enabling TLS and supplying certificate secrets.

Add TLS support for securing gRPC communication between SuperLink (hub)
and SuperNode (managed clusters). Includes a certificate generation
script and Helm chart conditional TLS configuration.

- Add hack/generate-certs.sh to generate CA + server cert as K8s Secrets
- SuperLink: mount server cert, switch from --insecure to --ssl-* flags
- SuperNode: distribute CA cert via AddOnTemplate Secret, use --root-certificates
- Add tls.enabled toggle (default: false) for backward compatibility
- Helm lookup with fail guard ensures clear error if certs not generated

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>
@openshift-ci
openshift-ci Bot requested review from ldpliu and zhujian7 March 31, 2026 09:54
@openshift-ci

openshift-ci Bot commented Mar 31, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yanmxa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Add instructions for configuring TLS in ~/.flwr/config.toml when
submitting FL jobs via flwr run to the TLS-secured SuperLink control API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>
@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown

Walkthrough

Marked TLS as enabled in README roadmap; added Helm TLS values and conditional template logic for CA and server certs; added a cert-generation script; added docs describing how to generate certs, create Secrets, and enable TLS for SuperNode–SuperLink communication.

Changes

Cohort / File(s) Summary
Docs / README
flower-addon/README.md, flower-addon/docs/enable-tls.md
Roadmap checklist updated to mark TLS enabled; new enable-tls.md documents certificate generation, Secrets created, Helm values to enable TLS, and client config for running FL jobs.
Helm values
flower-addon/charts/flower-addon/values.yaml
Adds tls block with tls.enabled, tls.ca.secretName, and tls.serverCert.secretName.
Helm templates
flower-addon/charts/flower-addon/templates/addon-template.yaml, flower-addon/charts/flower-addon/templates/superlink.yaml
Conditional TLS support: when enabled, SuperNode uses --root-certificates (instead of --insecure) and mounts CA secret; SuperLink Deployment looks up server cert secret, fails render if missing, filters out --insecure, adds --ssl-ca-certfile/--ssl-certfile/--ssl-keyfile args and mounts server cert secret; templates conditionally create/lookup flower-tls-ca secret and add volumes.
Certificate tooling
flower-addon/hack/generate-certs.sh
New script to generate a self-signed Flower CA and a SuperLink server cert (with SANs), and create/update flower-tls-ca and flower-superlink-tls Kubernetes Secrets in the target namespace.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling TLS for Flower addon SuperLink-SuperNode communication, which is the primary objective of the PR.
Description check ✅ Passed The description is comprehensive and well-structured, covering summary of changes, usage examples, verification with test results, and a detailed test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@flower-addon/charts/flower-addon/templates/superlink.yaml`:
- Around line 62-66: When tls.enabled is true the template mounts a Secret named
by .Values.tls.serverCert.secretName but does not validate it; add a Helm lookup
+ fail guard (the same lookup/fail pattern used for the CA Secret) at the top of
this template so installation fails fast if the server-cert Secret is missing.
Specifically, introduce a lookup on Secret with the namespace and
.Values.tls.serverCert.secretName and call fail with a clear message if the
lookup returns nil before the volumes: - name: tls-certs block that references
.Values.tls.serverCert.secretName.

In `@flower-addon/hack/generate-certs.sh`:
- Around line 111-116: The script currently uploads the CA private key into the
cluster Secret "flower-tls-ca" (via --from-file=ca.key), which is unnecessary
and increases blast radius; change the kubectl create secret generic invocation
in generate-certs.sh to only include the public certificate
(--from-file=ca.crt="${CERT_DIR}/ca.crt") and remove the --from-file=ca.key
option so the CA private key stays only on disk (CERT_DIR) and is not stored in
the Secret.

In `@flower-addon/README.md`:
- Around line 76-78: Update the README note to call out that the shown commands
assume the default SuperLink namespace and advise operators to either run the
commands with --namespace to match their deployment or set the Helm value
superlink.namespace to the same namespace; mention that mismatched namespaces
will break the CA lookup in addon-template.yaml and the SuperLink Secret mount
(flower-superlink-tls). Ensure the text around the two Secret descriptions (and
the repeated section at lines ~103-105) instructs users to use the same
namespace or show an example using --namespace to keep the CA and Secret
references consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5643c90b-cad8-4d17-b3d0-cdb5fe2bd8fe

📥 Commits

Reviewing files that changed from the base of the PR and between c6e505e and cf7c319.

📒 Files selected for processing (5)
  • flower-addon/README.md
  • flower-addon/charts/flower-addon/templates/addon-template.yaml
  • flower-addon/charts/flower-addon/templates/superlink.yaml
  • flower-addon/charts/flower-addon/values.yaml
  • flower-addon/hack/generate-certs.sh

Comment thread flower-addon/charts/flower-addon/templates/superlink.yaml
Comment thread flower-addon/hack/generate-certs.sh
Comment thread flower-addon/README.md Outdated
yanmxa and others added 2 commits March 31, 2026 21:27
Move the Enable TLS section from README into a dedicated doc file
under docs/ for consistency with other guides, and reference it
from the Roadmap section.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>
- Add lookup/fail guard for server-cert Secret in superlink.yaml to fail
  fast when the Secret is missing (mirrors existing CA Secret validation)
- Update TLS docs to clarify namespace assumptions and guide users to pass
  matching --namespace when overriding superlink.namespace

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
flower-addon/charts/flower-addon/templates/superlink.yaml (1)

25-27: Consider adding security context hardening.

Static analysis flagged that the superlink container lacks security context configuration. While out of scope for this TLS-focused PR, consider adding these hardening measures in a follow-up:

containers:
- name: superlink
  securityContext:
    readOnlyRootFilesystem: true
    runAsNonRoot: true
    allowPrivilegeEscalation: false
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flower-addon/charts/flower-addon/templates/superlink.yaml` around lines 25 -
27, Add a securityContext to the superlink container in the Helm template to
harden runtime privileges: update the containers entry for the "superlink"
container in superlink.yaml to include a securityContext block with
readOnlyRootFilesystem: true, runAsNonRoot: true and allowPrivilegeEscalation:
false (optionally make these values configurable via
.Values.superlink.securityContext so they can be toggled in values.yaml).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@flower-addon/charts/flower-addon/templates/superlink.yaml`:
- Around line 25-27: Add a securityContext to the superlink container in the
Helm template to harden runtime privileges: update the containers entry for the
"superlink" container in superlink.yaml to include a securityContext block with
readOnlyRootFilesystem: true, runAsNonRoot: true and allowPrivilegeEscalation:
false (optionally make these values configurable via
.Values.superlink.securityContext so they can be toggled in values.yaml).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc289dcd-1196-4595-8e2a-f3b69533d215

📥 Commits

Reviewing files that changed from the base of the PR and between 7a4262a and 5d9281c.

📒 Files selected for processing (2)
  • flower-addon/charts/flower-addon/templates/superlink.yaml
  • flower-addon/docs/enable-tls.md
✅ Files skipped from review due to trivial changes (1)
  • flower-addon/docs/enable-tls.md

@ldpliu

ldpliu commented Mar 31, 2026

Copy link
Copy Markdown

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Mar 31, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit dce6471 into open-cluster-management-io:main Mar 31, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants