Skip to content

Commit 6b6b48c

Browse files
authored
Updates to allow submitters to use multiple ParallelCluster clusters … (#140)
* Updates to allow submitters to use multiple ParallelCluster clusters at the same time Update the slurm config to add the ClusterName to the path. Enable multiple clusters to be used by submitters Change the mount point to include the cluster name so it is unique between clusters. Updates scripts and config paths to include the cluster name in the paths. Add a symbolic link so the head and compute nodes have access to the same path as the submitter. Resolves #139 * Add scripts and cron jobs to update users_groups.json Add the commands to configure/deconfigure an instance that has access to the users and groups so that the users_groups.json file can be created and updated each hour. * Fix fstab path, modulefiles config Also rename the CfnOutput names so commands are in the order that they are expected to run. * Add LOCALDOMAIN to the modulefile Fixes DNS resolution of cluster hostnames so srun doesn't fail. * Update documentation Put legacy docs at end.
1 parent aa8b9dc commit 6b6b48c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1060
-161
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains an AWS Cloud Development Kit (CDK) application that creates a Slurm cluster that is suitable for running production EDA workloads on AWS.
44

5-
The original version of this repo used a custom Python plugin to integrate Slurm with AWS.
5+
The original (legacy) version of this repo used a custom Python plugin to integrate Slurm with AWS.
66
The latest version of the repo uses AWS ParallelCluster for the core Slurm infrastructure and AWS integration.
77
The big advantage of moving to AWS ParallelCluster is that it is a supported AWS service.
88
Currently, some of the features of the legacy version are not supported in the ParallelCluster version, but
@@ -16,29 +16,32 @@ Key features are supported by both versions are:
1616
* Handling of spot terminations
1717
* Handling of insufficient capacity exceptions
1818
* Batch and interactive partitions (queues)
19-
* Managed tool licenses as a consumable resource
19+
* Manages tool licenses as a consumable resource
2020
* User and group fair share scheduling
2121
* Slurm accounting database
2222
* CloudWatch dashboard
2323
* Job preemption
2424
* Manage on-premises compute nodes
25-
* Configure partitions (queues) and nodes that are always on to support reserved instances RIs and savings plans.
25+
* Configure partitions (queues) and nodes that are always on to support reserved instances (RIs) and savings plans (SPs).
2626

2727
Features in the legacy version and not in the ParallelCluster version:
2828

29-
* Multi-AZ support. Supported by ParallelCluster, but not implemented.
29+
* Heterogenous clusters with mixed OSes and CPU architectures on compute nodes.
30+
* Multi-AZ support. Supported by ParallelCluster, but not currently implemented.
31+
* Multi-region support
3032
* AWS Fault Injection Simulator (FIS) templates to test spot terminations
31-
* Heterogenous cluster with mixed OSes and CPU architectures on compute nodes.
3233
* Support for MungeKeySsmParameter
3334
* Multi-cluster federation
34-
* Multi-region support
3535

3636
ParallelCluster Limitations
3737

38-
* Number of "Compute Resources" is limited to 50 which limits the number of instance types allowed in a cluster.
38+
* Number of "Compute Resources" (CRs) is limited to 50 which limits the number of instance types allowed in a cluster.
39+
ParallelCluster can have multiple instance types in a CR, but with memory based scheduling enabled, they must all have the same number of cores and amount of memory.
3940
* All Slurm instances must have the same OS and CPU architecture.
4041
* Stand-alone Slurm database daemon instance. Prevents federation.
41-
* Multi-region support. This is unlikely to change because multi-region services run against our archiectural philosophy. Federation may be a better option
42+
* Multi-region support. This is unlikely to change because multi-region services run against our archiectural philosophy.
43+
Federation may be an option but its current implementation limits scheduler performance and doesn't allow cluster prioritization so jobs land on
44+
random clusters.
4245

4346
Slurm Limitations
4447

@@ -96,14 +99,13 @@ Legacy:
9699
* Rocky Linux 8 and arm64
97100
* Rocky Linux 8 and x86_64
98101

99-
Note that in the ParallelCluster version all compute nodes must have the same OS and architecture.
102+
Note that in the ParallelCluster version, all compute nodes must have the same OS and architecture.
100103

101104
## Documentation
102105

103106
[View on GitHub Pages](https://aws-samples.github.io/aws-eda-slurm-cluster/)
104107

105-
To view the docs locally, clone the repository and run mkdocs:
106-
108+
You can also view the docs locally,
107109
The docs are in the docs directory. You can view them in an editor or using the mkdocs tool.
108110

109111
I recommend installing mkdocs in a python virtual environment.

docs/delete-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Delete Cluster
1+
# Delete Cluster (legacy)
22

33
Most of the resources can be deleted by simply deleting the cluster's CloudFormation stack.
44
However, there a couple of resources that must be manually deleted:
Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# Deploy the Cluster
1+
# Deploy Legacy Cluster
22

33
The original (legacy) version used a custom Slurm plugin for orchestrating the EC2 compute nodes.
44
The latest version uses ParallelCluster to provision the core Slurm infrastructure.
5-
When using ParallelCluster, a ParallelCluster configuration will be generated and use to create a ParallelCluster slurm cluster.
5+
When using ParallelCluster, a ParallelCluster configuration will be generated and used to create a ParallelCluster slurm cluster.
66
The first supported ParallelCluster version is 3.6.0.
7+
Version 3.7.0 is the recommended minimum version because it support compute node weighting that is proportional to instance type
8+
cost so that the least expensive instance types that meet job requirements are used.
79

810
## Prerequisites
911

@@ -15,6 +17,10 @@ You will needs AWS credentials that provide admin access to deploy the cluster.
1517

1618
Clone or download the aws-eda-slurm-cluster repository to your system.
1719

20+
```
21+
git clone [email protected]:aws-samples/aws-eda-slurm-cluster.git
22+
```
23+
1824
### Make sure required packages are installed
1925

2026
```
@@ -38,24 +44,25 @@ remediation or create a support ticket.
3844

3945
## Deploy Using ParallelCluster
4046

41-
### Create ParallelCluster UI
47+
### Create ParallelCluster UI (optional but recommended)
4248

4349
It is highly recommended to create a ParallelCluster UI to manage your ParallelCluster clusters.
4450
A different UI is required for each version of ParallelCluster that you are using.
4551
The versions are list in the [ParallelCluster Release Notes](https://docs.aws.amazon.com/parallelcluster/latest/ug/document_history.html).
4652
The minimum required version is 3.6.0 which adds support for RHEL 8 and increases the number of allows queues and compute resources.
47-
The suggested version is at least 3.7.0 because it adds configurate compute node weights which we use to prioritize the selection of
53+
The suggested version is at least 3.7.0 because it adds configurable compute node weights which we use to prioritize the selection of
4854
compute nodes by their cost.
4955

5056
The instructions are in the [ParallelCluster User Guide](https://docs.aws.amazon.com/parallelcluster/latest/ug/install-pcui-v3.html).
5157

5258
### Create ParallelCluster Slurm Database
5359

5460
The Slurm Database is required for configuring Slurm accounts, users, groups, and fair share scheduling.
55-
It you need these and other features then you will need to create ParallelCluster Slurm Database.
61+
It you need these and other features then you will need to create a ParallelCluster Slurm Database.
62+
You do not need to create a new database for each cluster; multiple clusters can share the same database.
5663
Follow the directions in this [ParallelCluster tutorial to configure slurm accounting](https://docs.aws.amazon.com/parallelcluster/latest/ug/tutorials_07_slurm-accounting-v3.html#slurm-accounting-db-stack-v3).
5764

58-
### Configuration File
65+
### Create Configuration File
5966

6067
The first step in deploying your cluster is to create a configuration file.
6168
A default configuration file is found in [source/resources/config/default_config.yml](https://github.com/aws-samples/aws-eda-slurm-cluster/blob/main/source/resources/config/default_config.yml).
@@ -170,10 +177,72 @@ with command line arguments, however it is better to specify all of the paramete
170177
./install.sh --config-file <config-file> --cdk-cmd create
171178
```
172179

173-
This will create the ParallelCuster configuration file, store it in S3, and use it to create a cluster.
180+
This will create the ParallelCuster configuration file, store it in S3, and then use a lambda function to create the cluster.
181+
182+
If you look in CloudFormation you will see 2 new stacks when deployment is finished.
183+
The first is the configuration stack and the second is the cluster.
184+
185+
## Create users_groups.json
186+
187+
Before you can use the cluster you must configure the Linux users and groups for the head and compute nodes.
188+
One way to do that would be to join the cluster to your domain.
189+
But joining each compute node to a domain effectively creates a distributed denial of service (DDOS) attack on the demain controller
190+
when the cluster rapidly scales out or in and each node tries to join or leave the domain.
191+
This can lead to domain controller timeouts and widespread havoc in your environment.
192+
193+
To solve this problem a script runs on a server that is joined to the domain which writes a JSON file with all
194+
of the non-privileged users and groups and their respective uids and gids.
195+
A script and cron job on the head and compute nodes reads this json file to create local users and groups that match the domain-joined servers.
196+
197+
Select the server that you want to use to create and update the JSON file.
198+
The outputs of the configuration stack have the commands required.
199+
200+
| Config Stack Output | Description
201+
|-----------------------------------------|------------------
202+
| Command01SubmitterMountHeadNode | Mounts the Slurm cluster's shared file system, adds it to /etc/fstab.
203+
| Command02CreateUsersGroupsJsonConfigure | Create /opt/slurm/{{ClusterName}}/config/users_groups.json and create a cron job to refresh it hourly.
204+
205+
Before deleting the cluster you can undo the configuration by running the commands in the following outputs.
206+
207+
| Config Stack Output | Description
208+
|-------------------------------------------|------------------
209+
| command10CreateUsersGroupsJsonDeconfigure | Removes the crontab that refreshes users_groups.json.
210+
211+
Now the cluster is ready to be used by sshing into the head node or a login node, if you configured one.
212+
213+
If you configured extra file systems for the cluster that contain the users' home directories, then they should be able to ssh
214+
in with their own ssh keys.
215+
216+
## Configure submission hosts to use the cluster
217+
218+
ParallelCluster was built assuming that users would ssh into the head node or login nodes to execute Slurm commands.
219+
This can be undesirable for a number of reasons.
220+
First, users shouldn't be given ssh access to a critical infrastructure like the cluster head node.
221+
With ParallelCluster 3.7.0 you can configure login nodes, but if you have already provisioned desktop nodes then
222+
it's wasteful to have to provision login nodes.
223+
Second, it's just inconvenient to have to use ssh to access the cluster and use it.
224+
225+
Fortunately, you can configure any server as a submission host so that users can run slurm commands.
226+
These commands must be run by an administrator that has root access to the submission host.
227+
The commands could also be run to create a custom AMI for user desktops so that they can access the clusters.
228+
The commands to configure submission hosts are in the outputs of the configuration CloudFormation stack.
229+
Run them in the following order:
230+
231+
| Config Stack Output | Description
232+
|-----------------------------------------|------------------
233+
| Command01SubmitterMountHeadNode | Mounts the Slurm cluster's shared file system, adds it to /etc/fstab.
234+
| Command03SubmitterConfigure | Configure the submission host so it can directly access the Slurm cluster.
235+
236+
The first command simply mounts the head node's NFS file system so you have access to the Slurm commands and configuration.
237+
238+
The second command runs an ansible playbook that configures the submission host so that it can run the Slurm commands for the cluster.
239+
It also configures the modulefile that sets up the environment to use the slurm cluster.
240+
241+
The clusters have been configured so that a submission host can use more than one cluster by simply changing the modulefile that is loaded.
174242

243+
On the submission host just open a new shell and load the modulefile for your cluster and you can access Slurm.
175244

176-
### Customize the compute node AMI
245+
## Customize the compute node AMI
177246

178247
The easiest way to create a custom AMI is to find the default ParallelCluster AMI in the UI.
179248
Create an instance using the AMI and make whatever customizations you require such as installing packages and

docs/deploy-parallel-cluster.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Deploy ParallelCluster
2+
3+
The original (legacy) version used a custom Slurm plugin for orchestrating the EC2 compute nodes.
4+
The latest version uses ParallelCluster to provision the core Slurm infrastructure.
5+
When using ParallelCluster, a ParallelCluster configuration will be generated and used to create a ParallelCluster slurm cluster.
6+
The first supported ParallelCluster version is 3.6.0.
7+
Version 3.7.0 is the recommended minimum version because it support compute node weighting that is proportional to instance type
8+
cost so that the least expensive instance types that meet job requirements are used.
9+
10+
## Prerequisites
11+
12+
See [Deployment Prerequisites](deployment-prerequisites.md) page.
13+
14+
The following are prerequisites that are specific to ParallelCluster.
15+
16+
### Create ParallelCluster UI (optional but recommended)
17+
18+
It is highly recommended to create a ParallelCluster UI to manage your ParallelCluster clusters.
19+
A different UI is required for each version of ParallelCluster that you are using.
20+
The versions are list in the [ParallelCluster Release Notes](https://docs.aws.amazon.com/parallelcluster/latest/ug/document_history.html).
21+
The minimum required version is 3.6.0 which adds support for RHEL 8 and increases the number of allows queues and compute resources.
22+
The suggested version is at least 3.7.0 because it adds configurable compute node weights which we use to prioritize the selection of
23+
compute nodes by their cost.
24+
25+
The instructions are in the [ParallelCluster User Guide](https://docs.aws.amazon.com/parallelcluster/latest/ug/install-pcui-v3.html).
26+
27+
### Create ParallelCluster Slurm Database
28+
29+
The Slurm Database is required for configuring Slurm accounts, users, groups, and fair share scheduling.
30+
It you need these and other features then you will need to create a ParallelCluster Slurm Database.
31+
You do not need to create a new database for each cluster; multiple clusters can share the same database.
32+
Follow the directions in this [ParallelCluster tutorial to configure slurm accounting](https://docs.aws.amazon.com/parallelcluster/latest/ug/tutorials_07_slurm-accounting-v3.html#slurm-accounting-db-stack-v3).
33+
34+
## Create the Cluster
35+
36+
To install the cluster run the install script. You can override some parameters in the config file
37+
with command line arguments, however it is better to specify all of the parameters in the config file.
38+
39+
```
40+
./install.sh --config-file <config-file> --cdk-cmd create
41+
```
42+
43+
This will create the ParallelCuster configuration file, store it in S3, and then use a lambda function to create the cluster.
44+
45+
If you look in CloudFormation you will see 2 new stacks when deployment is finished.
46+
The first is the configuration stack and the second is the cluster.
47+
48+
## Create users_groups.json
49+
50+
Before you can use the cluster you must configure the Linux users and groups for the head and compute nodes.
51+
One way to do that would be to join the cluster to your domain.
52+
But joining each compute node to a domain effectively creates a distributed denial of service (DDOS) attack on the demain controller
53+
when the cluster rapidly scales out or in and each node tries to join or leave the domain.
54+
This can lead to domain controller timeouts and widespread havoc in your environment.
55+
56+
To solve this problem a script runs on a server that is joined to the domain which writes a JSON file with all
57+
of the non-privileged users and groups and their respective uids and gids.
58+
A script and cron job on the head and compute nodes reads this json file to create local users and groups that match the domain-joined servers.
59+
60+
Select the server that you want to use to create and update the JSON file.
61+
The outputs of the configuration stack have the commands required.
62+
63+
| Config Stack Output | Description
64+
|-----------------------------------------|------------------
65+
| Command01SubmitterMountHeadNode | Mounts the Slurm cluster's shared file system, adds it to /etc/fstab.
66+
| Command02CreateUsersGroupsJsonConfigure | Create /opt/slurm/{{ClusterName}}/config/users_groups.json and create a cron job to refresh it hourly.
67+
68+
Before deleting the cluster you can undo the configuration by running the commands in the following outputs.
69+
70+
| Config Stack Output | Description
71+
|-------------------------------------------|------------------
72+
| command10CreateUsersGroupsJsonDeconfigure | Removes the crontab that refreshes users_groups.json.
73+
74+
Now the cluster is ready to be used by sshing into the head node or a login node, if you configured one.
75+
76+
If you configured extra file systems for the cluster that contain the users' home directories, then they should be able to ssh
77+
in with their own ssh keys.
78+
79+
## Configure submission hosts to use the cluster
80+
81+
ParallelCluster was built assuming that users would ssh into the head node or login nodes to execute Slurm commands.
82+
This can be undesirable for a number of reasons.
83+
First, users shouldn't be given ssh access to a critical infrastructure like the cluster head node.
84+
With ParallelCluster 3.7.0 you can configure login nodes, but if you have already provisioned desktop nodes then
85+
it's wasteful to have to provision login nodes.
86+
Second, it's just inconvenient to have to use ssh to access the cluster and use it.
87+
88+
Fortunately, you can configure any server as a submission host so that users can run slurm commands.
89+
These commands must be run by an administrator that has root access to the submission host.
90+
The commands could also be run to create a custom AMI for user desktops so that they can access the clusters.
91+
The commands to configure submission hosts are in the outputs of the configuration CloudFormation stack.
92+
Run them in the following order:
93+
94+
| Config Stack Output | Description
95+
|-----------------------------------------|------------------
96+
| Command01SubmitterMountHeadNode | Mounts the Slurm cluster's shared file system, adds it to /etc/fstab.
97+
| Command03SubmitterConfigure | Configure the submission host so it can directly access the Slurm cluster.
98+
99+
The first command simply mounts the head node's NFS file system so you have access to the Slurm commands and configuration.
100+
101+
The second command runs an ansible playbook that configures the submission host so that it can run the Slurm commands for the cluster.
102+
It also configures the modulefile that sets up the environment to use the slurm cluster.
103+
104+
The clusters have been configured so that a submission host can use more than one cluster by simply changing the modulefile that is loaded.
105+
106+
On the submission host just open a new shell and load the modulefile for your cluster and you can access Slurm.
107+
108+
## Customize the compute node AMI
109+
110+
The easiest way to create a custom AMI is to find the default ParallelCluster AMI in the UI.
111+
Create an instance using the AMI and make whatever customizations you require such as installing packages and
112+
configuring users and groups.
113+
114+
Custom file system mounts can be configured in the aws-eda-slurm-cluster config file which will add it to the
115+
ParallelCluster config file so that ParallelCluster can manage them for you.
116+
117+
When you are done create a new AMI and wait for the AMI to become available.
118+
After it is available you can add the custom ami to the aws-eda-slurm-cluster config file.
119+
120+
```
121+
slurm:
122+
ParallelClusterConfig:
123+
ComputeNodeAmi: ami-0fdb972bda05d2932
124+
```
125+
126+
Then update your aws-eda-slurm-cluster stack by running the install script again.
127+
128+
## Run Your First Job
129+
130+
Run the following command in a shell to configure your environment to use your slurm cluster.
131+
132+
```
133+
module load {{ClusterName}}
134+
```
135+
136+
To submit a job run the following command.
137+
138+
```
139+
sbatch /opt/slurm/$SLURM_CLUSTER_NAME/test/job_simple_array.sh
140+
```
141+
142+
To check the status run the following command.
143+
144+
```
145+
squeue
146+
```
147+
148+
To open an interactive shell on a slurm node.
149+
150+
```
151+
srun --pty /bin/bash
152+
```
153+
154+
## Slurm Documentation
155+
156+
[https://slurm.schedmd.com](https://slurm.schedmd.com)

0 commit comments

Comments
 (0)