Skip to content

Commit d9c2d35

Browse files
committed
format into asciidoc
Signed-off-by: Meng Yan <myan@redhat.com>
1 parent 5aa4742 commit d9c2d35

1 file changed

Lines changed: 119 additions & 113 deletions

File tree

content/patterns/multicloud-federated-learning/getting-started.adoc

Lines changed: 119 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -21,96 +21,102 @@ include::modules/comm-attributes.adoc[]
2121

2222
=== Set Up the Environment
2323

24-
1. Install the `clusteradm` CLI tool:
25-
26-
```bash
27-
curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash
28-
```
29-
-
30-
2. Create hub and managed clusters using `kind`:
31-
32-
```bash
33-
curl -L https://raw.githubusercontent.com/open-cluster-management-io/OCM/main/solutions/setup-dev-environment/local-up.sh | bash
34-
```
35-
24+
. Install the `clusteradm` CLI tool:
25+
+
26+
[source,bash]
27+
----
28+
$ curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash
29+
----
30+
31+
. Create hub and managed clusters using `kind`:
32+
+
33+
[source,bash]
34+
----
35+
$ curl -L https://raw.githubusercontent.com/open-cluster-management-io/OCM/main/solutions/setup-dev-environment/local-up.sh | bash
36+
----
37+
+
3638
Verify the environment
37-
38-
```bash
39+
+
40+
[source,bash]
41+
----
3942
$ kubectl get mcl
4043
NAME HUB ACCEPTED MANAGED CLUSTER URLS JOINED AVAILABLE AGE
4144
cluster1 true https://cluster1-control-plane:6443 True True 3d22h
4245
cluster2 true https://cluster2-control-plane:6443 True True 3d22h
43-
```
44-
-
45-
3. Deploy Federated Learning Controller
46-
47-
a. Clone and navigate to the repository:
48-
49-
```bash
50-
git@github.com:open-cluster-management-io/addon-contrib.git
51-
cd federated-learning-controller
52-
```
53-
-
54-
b. Build and push the controller image (or use pre-built `quay.io/myan/federated-learning-controller:latest`):
55-
56-
```bash
57-
make docker-build docker-push IMG=<IMG>
58-
```
59-
-
60-
c. Deploy the controller:
61-
62-
63-
```bash
46+
----
47+
48+
. Deploy Federated Learning Controller
49+
50+
.. Clone and navigate to the repository:
51+
+
52+
[source,bash]
53+
----
54+
$ git@github.com:open-cluster-management-io/addon-contrib.git
55+
$ cd federated-learning-controller
56+
----
57+
58+
.. Build and push the controller image (or use pre-built `quay.io/myan/federated-learning-controller:latest`):
59+
+
60+
[source,bash]
61+
----
62+
$ make docker-build docker-push IMG=<IMG>
63+
----
64+
65+
.. Deploy the controller:
66+
+
67+
[source,bash]
68+
----
6469
# switch the context to hub cluster
65-
kubectl config use-context kind-hub
66-
67-
make deploy IMG=<controller-image> NAMESPACE=<controller-namespace(default is open-cluster-management)>
68-
```
69-
-
70-
d. Verify deployment:
71-
72-
```bash
73-
kubectl get pods -n open-cluster-management
74-
```
75-
76-
Example output, the federated learning controller is running in the open-cluster-management namespace by default.
77-
78-
```
70+
$ kubectl config use-context kind-hub
71+
72+
$ make deploy IMG=<controller-image> NAMESPACE=<controller-namespace(default is open-cluster-management)>
73+
----
74+
75+
.. Verify deployment:
76+
+
77+
The federated learning controller is running in the open-cluster-management namespace by default.
78+
+
79+
[source,bash]
80+
----
81+
$ kubectl get pods -n open-cluster-management
7982
NAME READY STATUS RESTARTS AGE
8083
cluster-manager-d9db64db5-c7kfj 1/1 Running 0 3d22h
8184
cluster-manager-d9db64db5-t7grh 1/1 Running 0 3d22h
8285
cluster-manager-d9db64db5-wndd8 1/1 Running 0 3d22h
8386
federated-learning-controller-d7df846c9-nb4wc 1/1 Running 0 3d22h
84-
```
85-
86-
=== Deploy the Federated Learning Application
87+
----
8788

88-
1. **Build the Federated Learning Application Image**
89+
=== Deploy the Application
8990

91+
. build the Federated Learning Application Image
92+
+
9093
*Note*: You can directly use the pre-built image `quay.io/myan/federated-learning-app:latest`.
9194

92-
**a.** Navigate to the Flower framework example:
93-
94-
```bash
95-
cd federated-learning-controller/examples/flower
96-
```
97-
98-
**b.** *(Optional)* Modify the model code located in `flower/app-torch`, then build and push the image:
99-
100-
```bash
101-
export REGISTRY=<your-registry>
102-
export IMAGE_TAG=<your-image-tag>
103-
make build-app-image
104-
make push-app-image
105-
```
106-
95+
.. Navigate to the Flower framework example:
96+
+
97+
[source,bash]
98+
----
99+
$ cd federated-learning-controller/examples/flower
100+
----
101+
102+
.. *(Optional)* Modify the model code located in `flower/app-torch`, then build and push the image:
103+
+
104+
[source,bash]
105+
----
106+
$ export REGISTRY=<your-registry>
107+
$ export IMAGE_TAG=<your-image-tag>
108+
$ make build-app-image
109+
$ make push-app-image
110+
----
111+
+
107112
The image will be named `<REGISTRY>/flower-app-torch:<IMAGE_TAG>`.
108-
-
109-
2. **Deploy the Application to the Hub Cluster**
110113

114+
. Deploy the Application to the Hub Cluster
115+
+
111116
The current server and client use the same image. You can also use the pre-built image `quay.io/myan/flower-app-torch:latest`. After creating the resource, the server will deploy to the hub cluster, and the clients will deploy to managed clusters.
112-
113-
```yaml
117+
+
118+
[source,yaml]
119+
----
114120
apiVersion: federation-ai.open-cluster-management.io/v1alpha1
115121
kind: FederatedLearning
116122
metadata:
@@ -141,73 +147,71 @@ spec:
141147
matchExpressions:
142148
- key: federated-learning-sample.client-data
143149
operator: Exists
144-
```
145-
-
146-
3. **Schedule the Application on Managed Clusters**
150+
----
147151

152+
. Schedule the Application on Managed Clusters
153+
+
148154
The above configuration schedules only clusters with a `ClusterClaim` having the key `federated-learning-sample.client-data`. You can combine this with other scheduling policies (refer to the Placement API for details).
149155

150-
**a.** Managed Cluster 1 claims data:
156+
.. Managed Cluster 1 claims data:
157+
+
158+
[source,bash]
159+
----
160+
$ kubectl config use-context kind-cluster1
151161
152-
```bash
153-
kubectl config use-context kind-cluster1
154-
155-
cat <<EOF | kubectl apply -f -
162+
$ cat <<EOF | kubectl apply -f -
156163
apiVersion: cluster.open-cluster-management.io/v1alpha1
157164
kind: ClusterClaim
158165
metadata:
159166
name: federated-learning-sample.client-data
160167
spec:
161168
value: /data/private/cluster1
162169
EOF
163-
```
164-
165-
**b.** Managed Cluster 2 claims data:
166-
167-
```bash
168-
kubectl config use-context kind-cluster2
169-
170-
cat <<EOF | kubectl apply -f -
170+
----
171+
172+
.. Managed Cluster 2 claims data:
173+
+
174+
[source,bash]
175+
----
176+
$ kubectl config use-context kind-cluster2
177+
$ cat <<EOF | kubectl apply -f -
171178
apiVersion: cluster.open-cluster-management.io/v1alpha1
172179
kind: ClusterClaim
173180
metadata:
174181
name: federated-learning-sample.client-data
175182
spec:
176183
value: /data/private/cluster2
177184
EOF
178-
```
179-
-
180-
4. **Check the Application Status**
185+
----
181186

182-
**a.** After creating the instance, the server initially shows a status of `Waiting`:
187+
. Check the Application Status
183188

189+
.. After creating the instance, the server initially shows a status of `Waiting`:
190+
+
184191
*Hub cluster server example:*
185-
186-
```bash
187-
kubectl get pods
188-
```
189-
190-
```
192+
+
193+
[source,bash]
194+
----
195+
$ kubectl get pods
191196
NAME READY STATUS RESTARTS AGE
192197
federated-learning-sample-server-7jnfs 0/1 Completed 0 5d3h
193-
```
194-
195-
**b.** Once the required clients are ready, status changes to `Running`:
198+
----
196199

200+
.. Once the required clients are ready, status changes to `Running`:
201+
+
197202
*Managed cluster client example:*
198-
199-
```bash
200-
kubectl get pods -n open-cluster-management
201-
```
202-
203-
```
203+
+
204+
[source,bash]
205+
----
206+
$ kubectl get pods -n open-cluster-management
204207
NAME READY STATUS RESTARTS AGE
205208
federated-learning-sample-client-75sc8 0/1 Completed 0 5d3h
206-
```
207-
208-
**c.** After the training and aggregation rounds complete, the status becomes `Completed`:
209+
----
209210

210-
```
211+
.. After the training and aggregation rounds complete, the status becomes `Completed`:
212+
+
213+
[source,bash]
214+
----
211215
status:
212216
listeners:
213217
- address: 172.18.0.2:31166
@@ -216,6 +220,8 @@ status:
216220
type: NodePort
217221
message: Model training successful. Check storage for details
218222
phase: Completed
219-
```
223+
----
220224

221-
**d.** The MNIST model is saved in the PVC `model-pvc`. You can download and verify it, here is a sample for [verification](https://github.com/open-cluster-management-io/addon-contrib/blob/main/federated-learning-controller/examples/notebooks/1.hub-evaluation.ipynb).
225+
.. Download and Verify the Trained Model
226+
+
227+
After training is complete and the status is Completed, the MNIST model is saved in the `model-pvc` PersistentVolumeClaim. You can download and evaluate the trained model by following this link:https://github.com/open-cluster-management-io/addon-contrib/blob/main/federated-learning-controller/examples/notebooks/1.hub-evaluation.ipynb[verification notebook].

0 commit comments

Comments
 (0)