Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PENG-2186 Added and updated parameter configuration #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,26 @@ This project contains the democluster image producing codebase.


#### Tuning
Use environment variables to set parameters for the environment setup:
The environment variables `JG_VERSION` and `ENV` are exposed as tunables
to enable customizing the `democluster` for development purposes.

Non-optional environment variables:
- CLIENT_ID
- CLIENT_SECRET

Optional Environment Variables:
- ENV: The non-production environment to include in API URLs. (e.g. "staging", "dev", etc)
- DOMAIN: The non-standard domain for API URLs. (e.g. "private-vantage.io")
- JG_VERSION: The specific version of the jobbergate-agent to install (e.g. 4.4.0)

Example
```bash
ENV=dev JG_VERSION=4.3.1 \
./public-scripts/deploy-democluster.sh \
aset-fc8b1039-faa7-47b1-967a-c1a55c418740 \
9mWa98GbTJMcBZhinfy08aqHPyQWZUn7tH_XrAGLiYE
CLIENT_ID=aset-fc8b1039-faa7-47b1-967a-c1a55c418740 \
CLIENT_SECRET=9mWa98GbTJMcBZhinfy08aqHPyQWZUn7tH_XrAGLiYE \
ENV=staging \
JG_VERSION=4.3.1 \
./public-scripts/deploy-democluster.sh
```

###### Copyright
Expand Down
40 changes: 20 additions & 20 deletions democluster/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ write_files:
permissions: '0644'
content: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Hostname:
Comment: Hostname:
Version: Hockeypuck 2.1.0-223-gdc2762b

xsFNBGPKLe0BEADKAHtUqLFryPhZ3m6uwuIQvwUr4US17QggRrOaS+jAb6e0P8kN
1clzJDuh3C6GnxEZKiTW3aZpcrW/n39qO263OMoUZhm1AliqiViJgthnqYGSbMgZ
/OB6ToQeHydZ+MgI/jpdAyYSI4Tf4SVPRbOafLvnUW5g/vJLMzgTAxyyWEjvH9Lx
Expand Down Expand Up @@ -40,9 +40,9 @@ write_files:
permissions: '0644'
content: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Hostname:
Comment: Hostname:
Version: Hockeypuck 2.1.0-223-gdc2762b

xsFNBGTuZb8BEACtJ1CnZe6/hv84DceHv+a54y3Pqq0gqED0xhTKnbj/E2ByJpmT
NlDNkpeITwPAAN1e3824Me76Qn31RkogTMoPJ2o2XfG253RXd67MPxYhfKTJcnM3
CEkmeI4u2Lynh3O6RQ08nAFS2AGTeFVFH2GPNWrfOsGZW03Jas85TZ0k7LXVHiBs
Expand Down Expand Up @@ -159,22 +159,22 @@ write_files:
AuthInfo="socket=/var/run/munge/munge.socket.2"
AuthAltTypes=auth/jwt
AuthAltParameters="jwt_key=/var/lib/slurm/slurmctld/jwt_hs256.key"

SwitchType=switch/none

SlurmctldPidFile=/var/run/slurmctld.pid
SlurmdPidFile=/var/run/slurmd.pid

SlurmctldLogFile=/var/log/slurm/slurmctld.log
SlurmdLogFile=/var/log/slurm/slurmd.log

SlurmdSpoolDir=/var/lib/slurm/slurmd
StateSaveLocation=/var/lib/slurm/checkpoint

PluginDir=/usr/lib/x86_64-linux-gnu/slurm-wlm/

PlugStackConfig=/etc/slurm/plugstack.conf

ProctrackType=proctrack/linuxproc
ReturnToService=2

Expand Down Expand Up @@ -225,9 +225,9 @@ write_files:
SlurmUser=slurm

PluginDir=/usr/lib/x86_64-linux-gnu/slurm-wlm/

PidFile=/var/run/slurmdbd.pid

LogFile=/var/log/slurm/slurmdbd.log

StorageType=accounting_storage/mysql
Expand Down Expand Up @@ -319,11 +319,11 @@ runcmd:
- systemctl start mysql.service
- |
mysql << END

CREATE USER 'slurm'@'localhost' IDENTIFIED BY 'rats';
CREATE DATABASE IF NOT EXISTS slurm DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON slurm.* TO 'slurm'@'localhost';

END
# set up slurmrestd user and group
- groupadd --gid 64031 slurmrestd
Expand Down Expand Up @@ -353,7 +353,7 @@ runcmd:
After=network.target munge.service slurmctld.service
ConditionPathExists=/etc/slurm/slurm.conf
Documentation=man:slurmrestd(8)

[Service]
Type=simple
EnvironmentFile=-/etc/default/slurmrestd
Expand All @@ -365,7 +365,7 @@ runcmd:
ExecReload=/bin/kill -HUP $MAINPID
User=slurmrestd
Group=slurmrestd

[Install]
WantedBy=multi-user.target
EOF
Expand All @@ -375,12 +375,12 @@ runcmd:
# create jobbergate agent venv
- /usr/bin/python3 -m venv /srv/jobbergate-agent-venv
- /srv/jobbergate-agent-venv/bin/pip install -U pip
- /srv/jobbergate-agent-venv/bin/pip install jobbergate-agent==4.2.1
- /srv/jobbergate-agent-venv/bin/pip install jobbergate-agent
- |
cat <<EOF > /srv/jobbergate-agent-venv/.env
JOBBERGATE_AGENT_X_SLURM_USER_NAME=ubuntu
JOBBERGATE_AGENT_BASE_API_URL=https://apis.@ENVIRONMENT@vantagehpc.io
JOBBERGATE_AGENT_OIDC_DOMAIN=auth.@ENVIRONMENT@vantagehpc.io/realms/vantage
JOBBERGATE_AGENT_BASE_API_URL=https://apis.@ENVIRONMENT@@DOMAIN@
JOBBERGATE_AGENT_OIDC_DOMAIN=auth.@ENVIRONMENT@@DOMAIN@/realms/vantage
JOBBERGATE_AGENT_OIDC_AUDIENCE=https://apis.vantagehpc.io
JOBBERGATE_AGENT_OIDC_CLIENT_ID=@CLIENT_ID@
JOBBERGATE_AGENT_OIDC_CLIENT_SECRET=@CLIENT_SECRET@
Expand Down
83 changes: 50 additions & 33 deletions public-scripts/deploy-democluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# and sets up a customized environment for demonstrations.
#
# Usage:
# 1. Provide your CLIENT_ID and CLIENT_SECRET as command-line arguments:
# 1. Provide your CLIENT_ID and CLIENT_SECRET as environment variables:
# ```
# ./deploy-democluster.sh <CLIENT_ID> <CLIENT_SECRET>
# CLIENT_ID=<CLIENT_ID> CLIENT_SECRET=<CLIENT_SECRET> ./deploy-democluster.sh
# ```
# 2. The script will identify the host's operating system and install
# necessary dependencies (Multipass, Homebrew, etc.) accordingly.
Expand All @@ -22,7 +22,15 @@
# Prerequisites:
# - Bash shell
# - Internet connectivity for downloading dependencies (Multipass, Homebrew)
# - CLIENT_ID and CLIENT_SECRET obtained from Vantage
# - Non-optional environment variables set:
# - CLIENT_ID
# - CLIENT_SECRET
#
# Optional Environment Variables:
#
# - ENV: The non-production environment to include in API URLs. (e.g. "staging", "dev", etc)
# - DOMAIN: The non-standard domain for API URLs. (e.g. "private-vantage.io")
# - JG_VERSION: The specific version of the jobbergate-agent to install (e.g. 4.4.0)
#
# Configuration:
# - Modify the script's constants (e.g., NUM_CPUS, MEMORY, IMAGE_URL) to
Expand All @@ -35,38 +43,47 @@
#
################################################################################

CLIENT_ID=$1
CLIENT_SECRET=$2
# Check for the required environment variables
if [ -z $CLIENT_ID ]; then
echo "You must set the CLIENT_ID variable."
exit 1
fi
if [ -z $CLIENT_SECRET ]; then
echo "You must set the CLIENT_SECRET variable."
exit 1
fi

# Set the environment to the empty string if not supplied in the optional ENV variable
if [ -z $ENV ]; then
ENVIRONMENT=""
else
echo "Using optional setting ENV=$ENV for vantage URLs."
ENVIRONMENT="${ENV}."
fi

# Set the environment to the empty string if not supplied in the optional ENV variable
if [ -z $DOMAIN ]; then
DOMAIN="vantagehpc.io"
fi
echo "Using setting DOMAIN=$DOMAIN for vantage URLs."


IMAGE_CACHE=$HOME/democluster/image_cache
MOUNTED_DIR=$HOME/democluster/mount

mkdir -p $IMAGE_CACHE $MOUNTED_DIR/tmp

CLOUD_IMAGE_URL=https://omnivector-public-assets.s3.us-west-2.amazonaws.com/cloud-images/democluster/latest/democluster.img
CLOUD_IMAGE_DEST=/tmp/democluster.img

download_cloud_image () {
# Download the demo cluster cloud image and outputs to $1.
if [ -a $1 ]
then
echo "The demo cluster cloud image already exists. Proceeding..."
else
LOCAL_DEMOCLUSTER_IMG=$IMAGE_CACHE/democluster.img

if ! [ -f $LOCAL_DEMOCLUSTER_IMG ]; then
echo "Downloading the demo cluster cloud image, hang tight..."
curl -s --output $1 $CLOUD_IMAGE_URL
curl --progress-bar --output $LOCAL_DEMOCLUSTER_IMG $CLOUD_IMAGE_URL
echo "Download finished. Proceeding..."
fi
}

launch_instance () {
# Check whether to install from remote URL or local file. If $1, then installs from file.
if [ -z $1 ]; then
IMAGE_ORIGIN=$CLOUD_IMAGE_URL
else
IMAGE_ORIGIN=file://$1
fi
fi

# Set the environment to the empty string if not supplied
if [ -z $ENV ]; then
ENVIRONMENT=""
else
ENVIRONMENT="${ENV}."
fi

launch_instance () {
# Create the cloud-init file and launch the demo cluster instance.
cat <<EOF > /tmp/cloud-init.yaml
#cloud-config
Expand Down Expand Up @@ -94,6 +111,7 @@ runcmd:
- |
sed -i "s|@CLIENT_ID@|$CLIENT_ID|g" /srv/jobbergate-agent-venv/.env
sed -i "s|@CLIENT_SECRET@|$CLIENT_SECRET|g" /srv/jobbergate-agent-venv/.env
sed -i "s|@DOMAIN@|$DOMAIN|g" /srv/jobbergate-agent-venv/.env
sed -i "s|@ENVIRONMENT@|$ENVIRONMENT|g" /srv/jobbergate-agent-venv/.env
- systemctl start slurmrestd
- systemctl restart slurmdbd
Expand All @@ -109,13 +127,12 @@ EOF
echo " - /srv/jobbergate-agent-venv/bin/pip install -U jobbergate-agent==$JG_VERSION" >> /tmp/cloud-init.yaml
echo " - systemctl start jobbergate-agent" >> /tmp/cloud-init.yaml
fi
mkdir -p $HOME/democluster/tmp

cat /tmp/cloud-init.yaml | multipass launch -c$(nproc) \
-m4GB \
--mount=$HOME/democluster:/home/ubuntu/democluster \
--mount=$MOUNTED_DIR:/home/ubuntu/democluster \
-n democluster-`echo "$CLIENT_ID" | sed 's/-[0-9a-f]\{8\}-[0-9a-f]\{4\}-4[0-9a-f]\{3\}-[89abAB][0-9a-f]\{3\}-[0-9a-f]\{12\}//'` \
$IMAGE_ORIGIN \
file://$LOCAL_DEMOCLUSTER_IMG \
--cloud-init -

rm -f /tmp/cloud-init.yaml
Expand Down
Loading