-
Notifications
You must be signed in to change notification settings - Fork 151
Add hook examples #359
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
Merged
jeremiaswerner
merged 6 commits into
IBM:main
from
Luke-Roy-IBM:experimental-fleet-hooks
Apr 21, 2026
Merged
Add hook examples #359
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
51041db
Add hook examples
Luke-Roy-IBM 974d30d
Update serverless-fleets/README.md
Luke-Roy-IBM e6f6b8b
Update serverless-fleets/run_hook_ollama
Luke-Roy-IBM 24b4357
update readme
Luke-Roy-IBM c96b71a
Apply suggestion from @Luke-Roy-IBM
Luke-Roy-IBM b828805
Apply suggestion from @Luke-Roy-IBM
Luke-Roy-IBM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| uuid=$(uuidgen | tr '[:upper:]' '[:lower:]' | awk -F- '{print $1}') | ||
|
|
||
| PREHOOK=$(cat <<'EOF' | ||
| #!/bin/bash | ||
|
|
||
| if nvidia-smi >/dev/null 2>&1; then | ||
| echo "NVIDIA GPU detected" | ||
| podman run -d --device nvidia.com/gpu=all -v ollama:/root/.ollama -p 11434:11434 --name ollama docker.io/ollama/ollama | ||
| else | ||
| echo "No NVIDIA GPU detected" | ||
| podman run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama docker.io/ollama/ollama:latest | ||
| fi | ||
|
|
||
| # pull the model into ollama | ||
| podman exec -it ollama ollama pull granite4:350m | ||
| EOF | ||
| ) | ||
|
|
||
| echo code-engine fleet create --name "fleet-${uuid}-1" | ||
| echo " "--tasks-state-store fleet-task-store | ||
| echo " "--subnetpool-name fleet-subnetpool | ||
| echo " "--image registry.access.redhat.com/ubi10/ubi-minimal | ||
| echo " "--max-scale 1 | ||
| echo " "--command="curl" | ||
| echo " "--arg "http://host.containers.internal:11434/api/tags" | ||
| echo " "--tasks 1 | ||
| echo " "--env __CE_INTERNAL_HOOK_AFTER_STARTUP="${PREHOOK}" | ||
| echo " "__CE_INTERNAL_HOOK_AFTER_STARTUP_RETRY_LIMIT=3 | ||
| echo " "__CE_INTERNAL_HOOK_AFTER_STARTUP_MAX_EXECUTION_TIME=10m | ||
| echo " "--cpu 2 | ||
| echo " "--memory 4G | ||
|
|
||
| ibmcloud code-engine fleet create --name "fleet-${uuid}-1" \ | ||
| --tasks-state-store fleet-task-store \ | ||
| --subnetpool-name fleet-subnetpool \ | ||
| --image registry.access.redhat.com/ubi10/ubi-minimal \ | ||
| --max-scale 1 \ | ||
| --command="curl" \ | ||
| --arg "http://host.containers.internal:11434/api/tags" \ | ||
| --tasks 1 \ | ||
| --env __CE_INTERNAL_HOOK_AFTER_STARTUP="${PREHOOK}" \ | ||
| --env __CE_INTERNAL_HOOK_AFTER_STARTUP_RETRY_LIMIT=3 \ | ||
| --env __CE_INTERNAL_HOOK_AFTER_STARTUP_MAX_EXECUTION_TIME=30m \ | ||
| --cpu 2 \ | ||
| --memory 4G |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| ibmcloud login --sso -a cloud.ibm.com -r eu-de -c 1260a3541bb44fefb9c58d5cc92aaddb -g luke-new-ce-fleet-sandbox--rg | ||
|
Luke-Roy-IBM marked this conversation as resolved.
Outdated
|
||
| ibmcloud ce project select -n luke-new-ce-fleet-sandbox--ce-project | ||
|
Luke-Roy-IBM marked this conversation as resolved.
Outdated
Luke-Roy-IBM marked this conversation as resolved.
Outdated
|
||
|
|
||
| uuid=$(uuidgen | tr '[:upper:]' '[:lower:]' | awk -F- '{print $1}') | ||
|
|
||
| PREHOOK=$(cat <<'EOF' | ||
| #!/bin/bash | ||
| podman pull docker.io/library/hello-world:latest | ||
| EOF | ||
| ) | ||
|
|
||
|
|
||
| echo ibmcloud code-engine fleet create --name "fleet-${uuid}-1" | ||
| echo " "--tasks-state-store fleet-task-store | ||
| echo " "--subnetpool-name fleet-subnetpool | ||
| echo " "--image quay.io/podman/stable:latest | ||
| echo " "--max-scale 1 | ||
| echo " "--command="podman" | ||
| echo " "--arg "run" | ||
| echo " "--arg "hello-world" | ||
| echo " "--tasks 1 | ||
| echo " "--env __CE_INTERNAL_HOOK_AFTER_STARTUP="${PREHOOK}" | ||
| echo " "__CE_INTERNAL_HOOK_AFTER_STARTUP_RETRY_LIMIT=3 | ||
| echo " "__CE_INTERNAL_HOOK_AFTER_STARTUP_MAX_EXECUTION_TIME=10m | ||
| echo " "--env __CE_INTERNAL_PRIVILEGED_CONTAINER=true | ||
| echo " "--env __CE_INTERNAL_HOSTPATH_MOUNTS=/var/lib/containers:/var/lib/containers | ||
| echo " "--cpu 2 | ||
| echo " "--memory 4G | ||
|
|
||
| ibmcloud code-engine fleet create --name "fleet-${uuid}-1" \ | ||
| --tasks-state-store fleet-task-store \ | ||
| --subnetpool-name fleet-subnetpool \ | ||
| --image quay.io/podman/stable:latest \ | ||
| --max-scale 1 \ | ||
| --command="podman" \ | ||
| --arg "run" \ | ||
| --arg "hello-world" \ | ||
| --tasks 1 \ | ||
| --env __CE_INTERNAL_HOOK_AFTER_STARTUP="${PREHOOK}" \ | ||
| --env __CE_INTERNAL_HOOK_AFTER_STARTUP_RETRY_LIMIT=3 \ | ||
| --env __CE_INTERNAL_HOOK_AFTER_STARTUP_MAX_EXECUTION_TIME=10m \ | ||
| --env __CE_INTERNAL_PRIVILEGED_CONTAINER=true \ | ||
| --env __CE_INTERNAL_HOSTPATH_MOUNTS=/var/lib/containers:/var/lib/containers \ | ||
| --cpu 2 \ | ||
| --memory 4G | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.