Skip to content

Commit 39f7c67

Browse files
authored
Merge branch 'dev' into feature/multiple-values-files
2 parents 37bf2f0 + cebffd3 commit 39f7c67

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,33 @@ Galaxy will be available at `http://INSTANCE_IP/` once deployment completes
5454
- `-p, --project`: GCP project ID (default: anvil-and-terra-development)
5555
- `-s, --disk-size`: Size of persistent disk (default: 150GB)
5656
- `-z, --zone`: GCP zone (default: us-east4-c)
57+
- `-g, --git-repo`: Git repository URL (default: https://github.com/galaxyproject/galaxy-k8s-boot.git)
58+
- `-b, --git-branch`: Git branch to deploy (default: master)
5759
- `--ephemeral-only`: Create VM without persistent disk
5860

61+
#### Examples
62+
63+
**Basic deployment:**
64+
```bash
65+
bin/launch_vm.sh -k "ssh-rsa AAAAB3..." my-galaxy-vm
66+
```
67+
68+
**Custom git repository and branch (for testing/development):**
69+
```bash
70+
bin/launch_vm.sh -k "ssh-rsa AAAAB3..." \
71+
-g "https://github.com/username/galaxy-k8s-boot.git" \
72+
-b "feature-branch" \
73+
my-test-vm
74+
```
75+
76+
**With custom machine type and larger disk:**
77+
```bash
78+
bin/launch_vm.sh -k "ssh-rsa AAAAB3..." \
79+
-m "e2-standard-8" \
80+
-s "500GB" \
81+
my-production-vm
82+
```
83+
5984
### Manual Deployment
6085

6186
#### Prerequisites

bin/launch_vm.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ DISK_SIZE="150GB"
1515
DISK_TYPE="pd-balanced"
1616
GALAXY_CHART_VERSION="6.6.0"
1717
GALAXY_DEPS_VERSION="1.1.1"
18+
GIT_REPO="https://github.com/galaxyproject/galaxy-k8s-boot.git"
19+
GIT_BRANCH="master"
1820

1921
# Parse command line arguments
2022
INSTANCE_NAME=""
@@ -42,9 +44,11 @@ Options:
4244
-m, --machine-type TYPE Machine type (default: $MACHINE_TYPE)
4345
--galaxy-chart-version VERSION Galaxy Helm chart version (default: $GALAXY_CHART_VERSION)
4446
--galaxy-deps-version VERSION Galaxy dependencies chart version (default: $GALAXY_DEPS_VERSION)
47+
-g, --git-repo REPO Git repository URL (default: $GIT_REPO)
48+
-b, --git-branch BRANCH Git branch to deploy (default: $GIT_BRANCH)
4549
-f, --values FILE Helm values file (can be specified multiple times, default: values/values.yml)
46-
--ephemeral-only Create VM without persistent disk
47-
-h, --help Show this help message
50+
--ephemeral-only Create VM without persistent disk
51+
-h, --help Show this help message
4852
4953
Examples:
5054
# Launch VM with new or existing disk
@@ -65,6 +69,8 @@ Examples:
6569
# Launch VM with multiple Helm values files (order matters - later files override earlier ones)
6670
$0 -k "ssh-rsa AAAAB3..." -f values/values.yml -f values/gcp-batch.yml my-galaxy-vm
6771
$0 -k "ssh-rsa AAAAB3..." --values values/values.yml --values values/dev.yml --values values/v25.0.2.yml my-galaxy-vm
72+
# Launch VM with custom git repository and branch
73+
$0 -k "ssh-rsa AAAAB3..." -g "https://github.com/username/galaxy-k8s-boot.git" -b "feature-branch" my-galaxy-vm
6874
6975
EOF
7076
}
@@ -110,6 +116,12 @@ while [[ $# -gt 0 ]]; do
110116
;;
111117
-f|--values)
112118
GALAXY_VALUES_FILES+=("$2")
119+
-g|--git-repo)
120+
GIT_REPO="$2"
121+
shift 2
122+
;;
123+
-b|--git-branch)
124+
GIT_BRANCH="$2"
113125
shift 2
114126
;;
115127
--ephemeral-only)
@@ -174,6 +186,8 @@ echo "Machine Image: $MACHINE_IMAGE"
174186
echo "Galaxy Chart Version: $GALAXY_CHART_VERSION"
175187
echo "Galaxy Deps Version: $GALAXY_DEPS_VERSION"
176188
echo "Galaxy Values Files: ${GALAXY_VALUES_FILES[@]}"
189+
echo "Git Repository: $GIT_REPO"
190+
echo "Git Branch: $GIT_BRANCH"
177191

178192
if [ "$EPHEMERAL_ONLY" = false ]; then
179193
echo "Disk Name: $DISK_NAME"
@@ -329,6 +343,15 @@ GCLOUD_CMD=(
329343
--metadata=ssh-keys="ubuntu:$SSH_KEY"
330344
)
331345

346+
# Build metadata string
347+
METADATA="ssh-keys=ubuntu:$SSH_KEY,git-repo=${GIT_REPO},git-branch=${GIT_BRANCH}"
348+
if [ "$EPHEMERAL_ONLY" = false ]; then
349+
METADATA="${METADATA},persistent-volume-size=${PV_SIZE}Gi"
350+
fi
351+
352+
# Add combined metadata
353+
GCLOUD_CMD+=(--metadata="$METADATA")
354+
332355
# Add disk flag if not ephemeral only
333356
if [ "$EPHEMERAL_ONLY" = false ]; then
334357
GCLOUD_CMD+=($DISK_FLAG)

bin/user_data.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ runcmd:
4444
4545
# Convert semicolon-separated values files to JSON array for Ansible
4646
GALAXY_VALUES_FILES_JSON=$(echo "$GALAXY_VALUES_FILES_LIST" | sed -e 's/;/","/g' -e 's/^/["/' -e 's/$/"]/')
47+
GIT_REPO=$(curl -s -f "http://metadata.google.internal/computeMetadata/v1/instance/attributes/git-repo" -H "Metadata-Flavor: Google" 2>/dev/null || echo "https://github.com/galaxyproject/galaxy-k8s-boot.git")
48+
GIT_BRANCH=$(curl -s -f "http://metadata.google.internal/computeMetadata/v1/instance/attributes/git-branch" -H "Metadata-Flavor: Google" 2>/dev/null || echo "master")
4749
4850
mkdir -p /tmp/ansible-inventory
4951
cat > /tmp/ansible-inventory/localhost << EOF
@@ -65,9 +67,11 @@ runcmd:
6567
echo "[`date`] - Galaxy Chart Version: ${GALAXY_CHART_VERSION}"
6668
echo "[`date`] - Galaxy Deps Version: ${GALAXY_DEPS_VERSION}"
6769
echo "[`date`] - Galaxy Values Files: ${GALAXY_VALUES_FILES_LIST}"
70+
echo "[`date`] - Git Repository: ${GIT_REPO}"
71+
echo "[`date`] - Git Branch: ${GIT_BRANCH}"
6872
echo "[`date`] - Inventory file created at /tmp/ansible-inventory/localhost; running ansible-pull..."
6973
70-
ANSIBLE_CALLBACKS_ENABLED=profile_tasks ANSIBLE_HOST_PATTERN_MISMATCH=ignore ansible-pull -U https://github.com/galaxyproject/galaxy-k8s-boot.git -C master -d /home/ubuntu/ansible -i /tmp/ansible-inventory/localhost --accept-host-key --limit 127.0.0.1 --extra-vars "galaxy_chart_version=${GALAXY_CHART_VERSION}" --extra-vars "galaxy_deps_version=${GALAXY_DEPS_VERSION}" --extra-vars "galaxy_values_files=${GALAXY_VALUES_FILES_JSON}" playbook.yml
74+
ANSIBLE_CALLBACKS_ENABLED=profile_tasks ANSIBLE_HOST_PATTERN_MISMATCH=ignore ansible-pull -U ${GIT_REPO} -C ${GIT_BRANCH} -d /home/ubuntu/ansible -i /tmp/ansible-inventory/localhost --accept-host-key --limit 127.0.0.1 --extra-vars "galaxy_chart_version=${GALAXY_CHART_VERSION}" --extra-vars "galaxy_deps_version=${GALAXY_DEPS_VERSION}" --extra-vars "galaxy_values_files=${GALAXY_VALUES_FILES_JSON}" playbook.yml
7175
7276
echo "[`date`] - User data script completed."
7377
'

0 commit comments

Comments
 (0)