Skip to content

Commit 4652f10

Browse files
committed
Merge branch 'feat/flock-addon' of https://github.com/ray-ruisun/addon-contrib into feat/flock-addon
2 parents 1381123 + b1c86ca commit 4652f10

11 files changed

Lines changed: 337 additions & 499 deletions

File tree

dynamic-scoring-framework/charts/dynamic-scoring-framework/templates/addon-controller.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ spec:
2323
args:
2424
- "/dynamic-scoring-addon"
2525
- "controller"
26+
volumeMounts:
27+
{{- with .Values.hubSetting.extraVolumeMounts }}
28+
{{ toYaml . | nindent 10 }}
29+
{{- else }}
30+
[]
31+
{{- end }}
32+
volumes:
33+
{{- with .Values.hubSetting.extraVolumes }}
34+
{{ toYaml . | nindent 8 }}
35+
{{- else }}
36+
[]
37+
{{- end }}
2638
---
2739
apiVersion: v1
2840
kind: ServiceAccount

dynamic-scoring-framework/charts/dynamic-scoring-framework/templates/dynamic-scoring-controller.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,21 @@ spec:
392392
capabilities:
393393
drop:
394394
- ALL
395-
volumeMounts: []
395+
volumeMounts:
396+
{{- with .Values.hubSetting.extraVolumeMounts }}
397+
{{ toYaml . | nindent 10 }}
398+
{{- else }}
399+
[]
400+
{{- end }}
396401
securityContext:
397402
runAsNonRoot: true
398403
seccompProfile:
399404
type: RuntimeDefault
400405
serviceAccountName: dynamic-scoring-framework-controller
401406
terminationGracePeriodSeconds: 10
402-
volumes: []
407+
volumes:
408+
{{- with .Values.hubSetting.extraVolumes }}
409+
{{ toYaml . | nindent 8 }}
410+
{{- else }}
411+
[]
412+
{{- end }}

dynamic-scoring-framework/charts/dynamic-scoring-framework/values.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
hubSetting:
2+
# Additional pod volumes applied to all hub controller Deployments.
3+
# Example:
4+
# extraVolumes:
5+
# - name: scoring-config
6+
# configMap:
7+
# name: scoring-config
8+
# - name: scoring-secret
9+
# secret:
10+
# secretName: scoring-secret
11+
extraVolumes: []
12+
13+
# Additional volume mounts applied to all hub controller containers.
14+
# Example:
15+
# extraVolumeMounts:
16+
# - name: scoring-config
17+
# mountPath: /etc/dsf/config
18+
# readOnly: true
19+
# - name: scoring-secret
20+
# mountPath: /etc/dsf/secret
21+
# readOnly: true
22+
extraVolumeMounts: []
23+
224
# Namespace where the hub components (e.g. controllers) will be deployed
325
namespace: open-cluster-management
426

federated-learning-controller/README.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,31 @@ cluster1 true https://cluster1-control-plane:6443 True True
7979
cluster2 true https://cluster2-control-plane:6443 True True 3m
8080
```
8181

82-
#### 4. Deploy the Flower Addon (required for Flower framework)
82+
#### 4. Enable the `ManifestWorkReplicaSet` feature gate
83+
84+
The Flower path distributes ClientApps to managed clusters via a
85+
`ManifestWorkReplicaSet`. The feature gate is **disabled by default** in OCM
86+
v1.2.x, so enable it on the hub before deploying any Flower instance:
87+
88+
```bash
89+
kubectl patch clustermanager cluster-manager --type=merge -p '{
90+
"spec": {
91+
"workConfiguration": {
92+
"featureGates": [
93+
{"feature": "ManifestWorkReplicaSet", "mode": "Enable"}
94+
]
95+
}
96+
}
97+
}'
98+
```
99+
100+
Verify the work controller restarted with the feature gate on:
101+
102+
```bash
103+
kubectl -n open-cluster-management-hub get pods | grep work-controller
104+
```
105+
106+
#### 5. Deploy the Flower Addon (required for Flower framework)
83107

84108
The Flower addon pre-deploys SuperLink on the hub and SuperNode on managed clusters:
85109

@@ -183,6 +207,12 @@ federated-learning-controller-d7df846c9-nb4wc 1/1 Running 0 3
183207

184208
The Flower path requires the Flower addon to be installed. The controller deploys a SuperExec-ServerApp on the hub and SuperExec-ClientApp Deployments on managed clusters via ManifestWorkReplicaSet.
185209

210+
> **Image prerequisite**: `server.image` / `client.image` must be a
211+
> **SuperExec-compatible Flower app** image (Flower ≥ 1.26.x, `ServerApp` and
212+
> `ClientApp` registered via `[tool.flwr.app.components]`). See
213+
> [Build Your Own Flower App Image](#build-your-own-flower-app-image) below to
214+
> build the reference MNIST example.
215+
186216
```yaml
187217
apiVersion: federation-ai.open-cluster-management.io/v1alpha1
188218
kind: FederatedLearning
@@ -191,11 +221,11 @@ metadata:
191221
spec:
192222
framework: flower
193223
server:
194-
image: quay.io/open-cluster-management/flower-app:cifar10-v1.0.0
224+
image: quay.io/open-cluster-management/federated-learning-application:flower-mnist-latest
195225
minAvailableClients: 2
196226
# superlink: superlink.flower-system:9091 # default, can be omitted
197227
client:
198-
image: quay.io/open-cluster-management/flower-app:cifar10-v1.0.0
228+
image: quay.io/open-cluster-management/federated-learning-application:flower-mnist-latest
199229
# supernode: flower-supernode.flower-addon:9094 # default, can be omitted
200230
placement:
201231
clusterSets:
@@ -259,17 +289,22 @@ flwr run --insecure --run-config 'num-server-rounds=3' \
259289
<superlink-connection>
260290
```
261291

262-
<details>
292+
<details id="build-your-own-flower-app-image">
263293

264294
<summary><strong>Build Your Own Flower App Image</strong></summary>
265295

266-
You can use the [Flower PyTorch App](./examples/flower/) as a reference. The app image must contain a Flower `ServerApp` and `ClientApp` that are compatible with the SuperExec architecture.
296+
The reference [Flower PyTorch MNIST app](./examples/flower/app-torch/) is a
297+
SuperExec-compatible Flower app — its `Dockerfile` uses
298+
`flwr/superexec:1.26.1` as the base image and registers
299+
`ServerApp` / `ClientApp` via `[tool.flwr.app.components]` in
300+
`pyproject.toml`. Dependencies are baked into the image at build time so pods
301+
start without re-downloading PyTorch on every restart.
267302

268303
```bash
269304
cd examples/flower
270305
export IMAGE_REGISTRY=<your-registry>
271306
export IMAGE_TAG=<your-tag>
272-
export APP_NAME=cifar10
307+
export APP_NAME=flower-mnist
273308
make build-app-image
274309
make push-app-image
275310
```
Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
# Use a smaller base image
2-
FROM python:3.11-slim
1+
FROM flwr/superexec:1.26.1-py3.13-ubuntu24.04
32

4-
# Set environment variables to reduce image size and improve pip behavior
5-
ENV PYTHONUNBUFFERED=1 \
6-
PIP_NO_CACHE_DIR=1 \
7-
PIP_DISABLE_PIP_VERSION_CHECK=1 \
8-
PIP_DEFAULT_TIMEOUT=100 \
9-
MPLCONFIGDIR=/tmp \
10-
HF_HOME=/app/.cache/huggingface \
11-
TRANSFORMERS_CACHE=/app/.cache/transformers
12-
13-
# Set the working directory
143
WORKDIR /app
4+
COPY pyproject.toml .
5+
COPY app_torch/ ./app_torch/
156

16-
# Copy only necessary files (excluding pyproject.toml to defer dependency installation)
17-
COPY . /app
18-
19-
# Ensure the cache directories have the correct permissions
20-
RUN chown -R root:root /app && chmod -R 777 /app
21-
22-
23-
# Set the PYTHONPATH environment variable
24-
ENV PYTHONPATH=/app
25-
26-
# Ensure the entrypoint script is executable
27-
RUN chmod +x /app/entrypoint.sh
7+
# Bake all dependencies into the image (flwr already in base).
8+
RUN pip install --no-cache-dir \
9+
"flwr-datasets[vision]>=0.6.0" \
10+
"torch==2.10.0" \
11+
"torchvision==0.25.0" \
12+
-e .
2813

29-
# Install dependencies at runtime
30-
# ENTRYPOINT ["sh", "-c", "pip install -e . && /app/entrypoint.sh"]
31-
ENTRYPOINT ["/app/entrypoint.sh"]
14+
ENTRYPOINT ["flower-superexec"]

0 commit comments

Comments
 (0)