Skip to content

Add hook examples#359

Open
Luke-Roy-IBM wants to merge 6 commits intoIBM:mainfrom
Luke-Roy-IBM:experimental-fleet-hooks
Open

Add hook examples#359
Luke-Roy-IBM wants to merge 6 commits intoIBM:mainfrom
Luke-Roy-IBM:experimental-fleet-hooks

Conversation

@Luke-Roy-IBM
Copy link
Copy Markdown
Member

@Luke-Roy-IBM Luke-Roy-IBM commented Apr 16, 2026

PR Description

Add Fleet Worker Customization Examples to Documentation

This PR adds documentation for two experimental examples that demonstrate how to customize fleet workers using startup hooks.

Changes Made

Added new section to serverless-fleets/README.md:

  • Title: "How to customize fleet workers"
  • Location: Added in the HowTo section, between "How to access logs" and "Cleanup the Environment"

New Examples Documented

  1. Running Ollama on Fleet Workers (run_hook_ollama)

    • Demonstrates running Ollama (local LLM runtime) on fleet workers
    • Includes automatic GPU detection and configuration
    • Shows how to preload AI models during worker startup
    • Example use case: Running inference workloads with pre-configured LLM models
  2. Running Podman-in-Podman (run_hook_podman_in_podman)

    • Demonstrates nested containerization within fleet workers
    • Shows how to preload container images during startup
    • Includes configuration for privileged containers and host path mounts
    • Example use case: Running containerized workloads within fleet tasks

Key Features Documented

  • Startup Hooks: Using __CE_INTERNAL_HOOK_AFTER_STARTUP to execute setup scripts before tasks run
  • Hook Configuration: Retry limits and maximum execution time settings
  • Advanced Options: Privileged container mode and host path mounting for specialized workloads

Important Note

The documentation includes a clear note that this is an experimental feature that may change or be deprecated in the future, setting appropriate expectations for users.

Files Modified

  • serverless-fleets/README.md - Added new "How to customize fleet workers" section

Files Referenced

  • serverless-fleets/run_hook_ollama - Ollama example script
  • serverless-fleets/run_hook_podman_in_podman - Podman-in-Podman example script

Signed-off-by: Luke Roy <luke.roy@ibm.com>
Copy link
Copy Markdown
Collaborator

@reggeenr reggeenr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff - And very very useful use cases.

Comment thread serverless-fleets/README.md Outdated
Comment thread serverless-fleets/README.md Outdated
Comment thread serverless-fleets/run_hook_ollama Outdated
Luke-Roy-IBM and others added 3 commits April 16, 2026 17:19
Co-authored-by: Enrico Regge <36001299+reggeenr@users.noreply.github.com>
Co-authored-by: Enrico Regge <36001299+reggeenr@users.noreply.github.com>
Signed-off-by: Luke Roy <luke.roy@ibm.com>
reggeenr
reggeenr previously approved these changes Apr 16, 2026
Copy link
Copy Markdown
Collaborator

@reggeenr reggeenr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Soon we should add an example that demonstrates the BEFORE_SHUTDOWN, like mimic a worker registration and de-registration

PREHOOK=$(cat <<'EOF'
#!/bin/bash

echo "Registering fleet worker '${hostname}' ..."
// TODO implement your fleet worker registration logic

EOF
)

POSTHOOK=$(cat <<'EOF'
#!/bin/bash

echo "Deregistering fleet worker '${hostname}' ..."
// TODO implement your fleet worker deregistration logic

EOF
)

Furthermore, we should add a link to the automatically injected variables, once we merged the docs PR: https://github.ibm.com/cloud-docs/codeengine/pull/1100

Copy link
Copy Markdown
Collaborator

@jeremiaswerner jeremiaswerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Luke-Roy-IBM cool, thanks a lot! this is fantastic and will help users to experiment advanced use cases... looking forward to more examples like mounting remote HPC storage systems.

Just two small changes to remove the login logic.

Comment thread serverless-fleets/run_hook_podman_in_podman Outdated
Comment thread serverless-fleets/run_hook_podman_in_podman Outdated
Comment thread serverless-fleets/run_hook_podman_in_podman Outdated
Comment thread serverless-fleets/run_hook_podman_in_podman Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants