Companion repository for Agent Zone's Temporal series. Fully tested Go examples demonstrating dependency injection, idempotency, and durable execution patterns with Temporal on Kubernetes.
| Tool | Version | Purpose |
|---|---|---|
| Go | 1.22+ | Build workflows and workers |
| Docker | 24+ | Container runtime |
| minikube | 1.32+ | Local Kubernetes clusters |
| kubectl | 1.28+ | Kubernetes CLI |
| Helm | 3.13+ | Temporal Helm chart |
| Temporal CLI | 1.0+ | Start workflows, query state (optional) |
Run make check-prereqs to verify your environment.
# Clone the repo
git clone https://github.com/statherm/temporal-examples.git
cd temporal-examples
# Check prerequisites
make check-prereqs
# Level 1: Start a single-cluster Temporal environment and run HelloWorkflow
make cluster-up temporal-up
make run-worker &
make start-hello
# Clean up
make clean-alltemporal-examples/
├── cmd/
│ ├── worker/ # Main Temporal worker binary
│ ├── bridge-worker/ # Cross-cluster bridge worker (Level 3)
│ └── starter/ # Workflow starter CLI
├── internal/
│ ├── activities/
│ │ ├── docker/ # Docker container activities
│ │ ├── azure/ # Azure resource activities
│ │ ├── bridge/ # Cross-cluster bridge activities
│ │ └── lookup/ # Service discovery activities
│ ├── config/
│ │ ├── config.go # Environment-based configuration
│ │ └── di.go # Dependency injection container
│ ├── idempotency/
│ │ └── keys.go # Deterministic idempotency key generation
│ └── workflows/
│ ├── hello/ # L1: HelloWorkflow
│ ├── container_lifecycle/ # L2: ContainerLifecycleWorkflow
│ ├── approval/ # L2: ApprovalWorkflow (signals)
│ ├── mutex/ # L2: MutexWorkflow (distributed locking)
│ └── cross_cluster/ # L3: CrossClusterWorkflow
├── deploy/
│ ├── minikube/
│ │ ├── single-cluster/ # L1: Single Temporal cluster setup
│ │ └── multi-cluster/ # L3: Dual-cluster bridge setup
│ └── docker-compose/ # Alternative: Temporal via Docker Compose
├── scripts/
│ ├── check-prereqs.sh # Prerequisite verification
│ ├── wait-for-temporal.sh # Readiness poller
│ ├── run-level1.sh # Automated Level 1 demo
│ ├── run-level2.sh # Automated Level 2 demo
│ └── run-level3.sh # Automated Level 3 demo
├── test/
│ └── e2e/ # End-to-end integration tests
├── Makefile # Top-level orchestration
├── go.mod
└── README.md
Get Temporal running on a single minikube cluster and execute your first workflow.
- HelloWorkflow: A minimal workflow that demonstrates activity registration, task queues, and workflow execution.
- Concepts: Workers, activities, task queues, workflow IDs, retry policies.
- Infrastructure: Single minikube cluster, Helm-installed Temporal server with PostgreSQL.
make cluster-up temporal-up
make run-worker &
make start-helloReal-world patterns: container lifecycle management, human-in-the-loop approvals, and distributed mutex.
- ContainerLifecycleWorkflow: Provisions, monitors, and tears down Docker containers with idempotent activities.
- ApprovalWorkflow: Demonstrates Temporal signals for human approval gates with configurable timeouts.
- MutexWorkflow: Implements distributed locking across concurrent workflow executions.
- Concepts: Signals, queries, child workflows, idempotency keys, dependency injection.
- Infrastructure: Docker Compose test containers alongside the Temporal cluster.
make setup-containers
make run-worker &
make start-container-workflow
make start-approval-workflow
make send-approval
make start-mutex-demoMulti-cluster durable execution with a bridge worker pattern.
- CrossClusterWorkflow: Orchestrates work across two independent Temporal clusters via a bridge worker.
- Concepts: Multi-cluster topologies, bridge workers, cross-cluster signals, failure domains.
- Infrastructure: Two minikube clusters, each running independent Temporal installations.
make clusters-up
make deploy-bridge
make start-cross-cluster-workflowAll examples are orchestrated through Make targets. Run make help to see every available target.
| Target | Description |
|---|---|
make check-prereqs |
Verify all required tools are installed |
make build |
Build all binaries |
make test |
Run all tests (unit + e2e) |
make test-unit |
Run unit tests only |
make test-e2e |
Run e2e tests (requires running Temporal) |
make test-level1 |
Run Level 1 tests only |
make test-level2 |
Run Level 2 tests only |
make test-level3 |
Run Level 3 tests only |
make cluster-up |
Start single minikube cluster |
make cluster-down |
Tear down single minikube cluster |
make temporal-up |
Install Temporal via Helm |
make temporal-ha-up |
Install Temporal in HA mode |
make clusters-up |
Start both multi-cluster minikube profiles |
make clusters-down |
Tear down both multi-cluster profiles |
make clean |
Remove built binaries |
make clean-all |
Full cleanup (binaries, clusters, containers) |
Alternatively, use the automated demo scripts:
./scripts/run-level1.sh # Full Level 1 walkthrough
./scripts/run-level2.sh # Full Level 2 walkthrough
./scripts/run-level3.sh # Full Level 3 walkthroughUnit tests use Temporal's test framework with mocked activities. No running Temporal server required.
make test-unitE2E tests run against real Temporal servers and require the appropriate infrastructure to be running.
# Level 1: requires a running Temporal server
export TEMPORAL_HOST=localhost:7233
make test-level1
# Level 2: requires Temporal + Docker Compose containers
make test-level2
# Level 3: requires both clusters running
export CLUSTER_A_HOST=localhost:7233
export CLUSTER_B_HOST=localhost:7234
make test-level3
# Or run all e2e tests at once
make test-e2eThese examples accompany the Temporal workflow orchestration series on Agent Zone:
- Workflow Orchestration Overview
- Getting Started with Temporal on Kubernetes
- Temporal Dependency Injection Patterns
- Idempotency in Temporal Activities
- Multi-Cluster Temporal Topologies
- Temporal Helm Chart Deep Dive
MIT