You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: sections/docker-hpc-cloud.qmd
+62-18
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
-
title: "Containers in HPC and Cloud"
2
+
title: "Container orchestration"
3
3
---
4
4
5
5
## Learning Objectives
6
6
7
-
- Discuss containers in high performace computing environments
8
-
- Explore orchestration formats
7
+
- Discuss containers in high performace computing and cloud computing
8
+
- Explore orchestration approaches
9
9
- Learn how to use docker compose to build a workflow
10
10
- Explore a real world Kubernetes service
11
11
@@ -197,45 +197,75 @@ Like other container systems, Kubernetes is configured through a set of YAML con
197
197
198
198
::: {layout="[[70,30]]"}
199
199
200
-
Parsl is all about the beef...
200
+
Parsl provides a simple mechanism to decorate python functions to be executed concurrently on a variety of platforms and under different execution models, inlcuding the `ThreadPoolExecutor` and the `HighThroughputExecutor`, which we used previously.
201
201
202
202

203
203
204
204
:::
205
205
206
-
Remember the basic layout of a parsl app:
206
+
Remember the basic layout of a parsl app, in which the `@python_app` decorator is used to wrap task functions that should be executed by parsl.
207
207
208
208
```python
209
209
# Define the square task.
210
210
import parsl
211
211
@python_app
212
212
def square(x):
213
213
return x * x
214
+
```
214
215
215
-
# Launch four parallel square tasks.
216
-
futures = [square(i) for i in range(4)]
216
+
This works because parsl is configured ahead of time to use a particular type of execution environment on the nodes of a cluster. The `HighThroughPutExector` that we used previously with a `LocalProvider` can instead be easily configured to work using a `KubernetesProvider`. Here's a modification to our previous Config to use Kubernetes:
217
217
218
-
# Retrieve results.
219
-
squares = [future.result() for future in futures]
220
-
print(squares)
221
-
# -> [0, 1, 4, 9]
218
+
```python
219
+
activate_env = 'workon scomp'
220
+
htex_kube = Config(
221
+
executors=[
222
+
HighThroughputExecutor(
223
+
label='kube-htex',
224
+
cores_per_worker=cores_per_worker,
225
+
max_workers=5,
226
+
worker_logdir_root='/',
227
+
# Address for the pod worker to connect back
228
+
address=address_by_route(),
229
+
provider=KubernetesProvider(
230
+
231
+
# Namespace in K8S to use for the run
232
+
namespace='adccourse',
233
+
234
+
# Docker image url to use for pods
235
+
image='ghcr.io/mbjones/k8sparsl:0.3',
236
+
237
+
# Command to be run upon pod start
238
+
worker_init=activate_env,
239
+
240
+
# Should follow the Kubernetes naming rules
241
+
pod_name='parsl-worker',
242
+
243
+
nodes_per_block=1,
244
+
init_blocks=1,
245
+
min_blocks=1,
246
+
# Maximum number of pods to scale up
247
+
max_blocks=1,
248
+
# persistent_volumes (list[(str, str)]) – List of tuples
249
+
# describing persistent volumes to be mounted in the pod.
250
+
# The tuples consist of (PVC Name, Mount Directory).
251
+
# persistent_volumes=[('mypvc','/var/data')]
252
+
),
253
+
),
254
+
]
255
+
)
222
256
```
223
-
257
+
With that change, Parsl will send tasks to Kubernetes worker pods. Otherwise, the remaining parsl code is the smae as previously.
224
258
225
259
### Ray.io
226
260
227
261
::: {layout="[[60,40]]"}
228
262
229
-
[Ray](https://ray.io) is structured so similarly to Parsl...
263
+
[Ray](https://ray.io) is structured similarly to Parsl, and also uses decorators to wrap task functions that are to be executed. [Ray Core](https://docs.ray.io/en/latest/ray-core/walkthrough.html) is the part that is fairly analogous to Parsl, and provides the core functionality for distributed execution for any kind of compute jobs.
230
264
231
265

232
266
233
267
:::
234
268
235
-

236
-
237
-
[Ray Core](https://docs.ray.io/en/latest/ray-core/walkthrough.html) is fairly analogous to Parsl, and provides the core functionality for distributed execution.
238
-
239
269
```python
240
270
# Define the square task.
241
271
@ray.remote
@@ -250,11 +280,25 @@ print(ray.get(futures))
250
280
# -> [0, 1, 4, 9]
251
281
```
252
282
283
+
The execution model also returns a `Future`-like object that can be queried to get the function results when it is complete.
284
+
285
+
Ray Core defines `Tasks`, `Actors`, and `Objects`, all of which can be used on ditributed clusters such as Kubernetes. And like Parsl, Ray can be configured to use a wide variety of execution backends such as Kubernetes. Ray also provides a mature framework for training, tuning, and serving machine learning models and the associated data.
286
+
287
+

288
+
289
+
253
290
### Kubeflow
254
291
255
-
[Kubeflow](https://www.kubeflow.org/)
292
+
::: {layout="[[85,15]]"}
293
+
294
+
[Kubeflow](https://www.kubeflow.org/) is yet another orchestration package designed to asynchronously execute tasks from containers, but Kubeflow is specific to Kubernetes clusters.
295
+
256
296

257
297
298
+
:::
299
+
300
+
Here's the syntax for defining a Kubeflow component and pipeline to be executed on worker pods of a Kubernetes cluster. The similarities with the previous packages are striking. But unlike Parsl and Ray, a workflow built in Kubeflow can't be run on the rich variety of high performace computing clusters supported by the other libraries.
0 commit comments