Skip to content

Commit

Permalink
Merge pull request #120 from heyealex/spack-example
Browse files Browse the repository at this point in the history
Add Spack example
  • Loading branch information
heyealex authored Mar 4, 2022
2 parents 14f0e6e + 04013bd commit 057011d
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 30 deletions.
35 changes: 34 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ config.
Please note that global variables defined under `vars` are automatically
passed to resources if the resources have an input that matches the variable name.

### (Optional) Setting up a remote terraform state

The following commented block will setup a GCS bucket to store and manage the
terraform state. Add your own bucket name and (optionally) a service account
in the configuration. If not set, the terraform state will be stored locally
within the generated blueprint.

Add this block to the top-level of your input YAML:

```yaml
terraform_backend_defaults:
type: gcs
configuration:
bucket: a_bucket
impersonate_service_account: a_bucket_reader@project.iam.gserviceaccount.com
```
## Config Descriptions
### hpc-cluster-small.yaml
Expand Down Expand Up @@ -84,9 +101,25 @@ Quota required for this example:
* Compute Engine API: Resource policies: **one for each job in parallel** -
_only needed for `compute` partition_

### spack-build.yaml

Creates a [Spack](../resources/scripts/spack-install/README.md)
build VM and a workstation for testing and validating a spack build. The build
VM will install spack as configured in the spack-install resource in a shared
location (/apps), then shutdown. Spack supports HPC software package
installation and management. This build leverages the startup-script resource
and can be applied in any cluster by using the output of spack-install or
startup-script resources.

Note: Installing spack compilers and libraries in this example can take 1-2
hours to run on startup. To decrease this time in future deployments, consider
including a spack build cache as described in the comments of the example.

### Experimental

**omnia-cluster-simple.yaml**: Creates a simple omnia cluster, with an
#### omnia-cluster-simple.yaml

Creates a simple omnia cluster, with an
omnia-manager node and 8 omnia-compute nodes, on the pre-existing default
network. Omnia will be automatically installed after the nodes are provisioned.
All nodes mount a filestore instance on `/home`.
Expand Down
4 changes: 2 additions & 2 deletions examples/hpc-cluster-high-io.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
blueprint_name: hpc-cluster-high-io

vars:
project_id: ## Set GCP Project ID Here ##
deployment_name: hpc-slurm-io
project_id: ## Set GCP Project ID Here ##
deployment_name: hpc-high-io
region: us-central1
zone: us-central1-c

Expand Down
2 changes: 1 addition & 1 deletion examples/hpc-cluster-small.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ blueprint_name: hpc-cluster-small

vars:
project_id: ## Set GCP Project ID Here ##
deployment_name: hpc-slurm-small
deployment_name: hpc-small
region: us-central1
zone: us-central1-c

Expand Down
119 changes: 119 additions & 0 deletions examples/spack-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

blueprint_name: spack-build

vars:
project_id: ## Set GCP Project ID Here ##
deployment_name: spack
region: us-central1
zone: us-central1-a

resource_groups:
- group: primary
resources:
- source: resources/network/pre-existing-vpc
kind: terraform
id: network1

- source: resources/file-system/filestore
kind: terraform
id: appsfs
use: [network1]
settings:
local_mount: /apps

- source: resources/scripts/spack-install
kind: terraform
id: spack
settings:
install_dir: /apps/spack
spack_url: https://github.com/spack/spack
spack_ref: v0.17.1
log_file: /var/log/spack.log
compilers:
- gcc@10.3.0 target=x86_64
packages:
- cmake%gcc@10.3.0 target=x86_64
- intel-mkl%gcc@10.3.0 target=cascadelake
- git%gcc@10.3.0 target=x86_64
- intel-mpi@2018.4.274%gcc@10.3.0 target=cascadelake
# Uncomment and update the name and path to add a shared or personal Spack
# cache location to speed up future deployments.
# spack_cache_url:
# - mirror_name: gcs_cache
# mirror_url: gs://bucket-name/...

- source: resources/scripts/startup-script
kind: terraform
id: spack-startup
settings:
runners:
- type: shell
source: modules/startup-script/examples/install_ansible.sh
destination: install_ansible.sh
- type: shell
content: $(appsfs.install_nfs_client)
destination: install-nfs.sh
- type: ansible-local
source: modules/startup-script/examples/mount.yaml
destination: "mount.yaml"
- type: ansible-local
source: modules/spack-install/scripts/install_spack_deps.yml
destination: install_spack_deps.yml
- type: shell
content: $(spack.startup_script)
destination: install_spack.sh
- type: shell
destination: shutdown.sh
content: shutdown -h

- source: resources/compute/simple-instance
kind: terraform
id: spack-build
use:
- network1
- appsfs
- spack-startup
settings:
name_prefix: spack-builder
machine_type: n2-standard-8

- source: resources/scripts/startup-script
kind: terraform
id: mount-startup
settings:
runners:
- type: shell
source: modules/startup-script/examples/install_ansible.sh
destination: install_ansible.sh
- type: shell
content: $(appsfs.install_nfs_client)
destination: install-nfs.sh
- type: ansible-local
source: modules/startup-script/examples/mount.yaml
destination: "mount.yaml"

- source: resources/compute/simple-instance
kind: terraform
id: workstation
use:
- network1
- appsfs
- mount-startup
settings:
name_prefix: workstation
machine_type: n2-standard-8
3 changes: 3 additions & 0 deletions resources/scripts/spack-install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Alternatively, it can be added as a startup script via:
id: startup
settings:
runners:
- type: ansible-local
source: modules/spack-install/scripts/install_spack_deps.yml
destination: install_spack_deps.yml
- type: shell
content: $(spack.startup_script)
destination: "/apps/spack-install.sh"
Expand Down
28 changes: 28 additions & 0 deletions resources/scripts/spack-install/scripts/install_spack_deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Install dependencies for spack installation
hosts: localhost
tasks:
- name: Install pip3 and git
package:
name:
- python3-pip
- git
- name: Install google cloud storage
pip:
name: google-cloud-storage
executable: pip3
8 changes: 8 additions & 0 deletions resources/scripts/spack-install/templates/.shellcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ disable=SC2154
# Disabled because paths will not be known until runtime (and will not be local)
# https://github.com/koalaman/shellcheck/wiki/SC1090
disable=SC1090

# Disabled because variable is used with $$ for template
# https://github.com/koalaman/shellcheck/wiki/SC2034
disable=SC2034

# Disabled because string is not literal, variable is prefaced with $$ for template
# https://github.com/koalaman/shellcheck/wiki/SC2157
disable=SC2157
26 changes: 0 additions & 26 deletions resources/scripts/spack-install/templates/install_spack.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,6 @@ fi
# Only install and configure spack if ${INSTALL_DIR} doesn't exist
if [ ! -d ${INSTALL_DIR} ]; then

DEPS=""
if [ ! "$(which pip3)" ]; then
DEPS="$DEPS pip3"
fi

if [ ! "$(which git)" ]; then
DEPS="$DEPS git"
fi

if [ -n "$DEPS" ]; then
echo "$PREFIX Installing dependencies"
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ] || [ -f /etc/system-release ]; then
yum -y install $DEPS
elif [ -f /etc/debian_version ] || grep -qi ubuntu /etc/lsb-release || grep -qi ubuntu /etc/os-release; then
echo "$PREFIX WARNING: unsupported installation in debian / ubuntu"
apt install -y $DEPS
else
echo "$PREFIX Unsupported distribution"
exit 1
fi
fi

# Install google-cloud-storage
echo "$PREFIX Installing Google Cloud Storage via pip3..."
pip3 install google-cloud-storage > ${LOG_FILE} 2>&1

# Install spack
echo "$PREFIX Installing spack from ${SPACK_URL}..."
{
Expand Down

0 comments on commit 057011d

Please sign in to comment.