Examples
Learn how to use Conductor Framework through practical examples.
Introduction
The examples demonstrate real-world usage of Conductor Framework for managing Kubernetes applications. They show how to structure manifests, configure parameters, and deploy services.
Prerequisites
- Go 1.25.4+ (or latest stable version)
- Docker (or compatible container runtime)
- Kubernetes cluster (local or remote)
- kubectl configured to access your cluster
Guestbook Conductor Example
The Guestbook Conductor is a working example that demonstrates how to use the conductor-framework to manage a multi-service Kubernetes application. The Guestbook application is a classic Kubernetes example consisting of:
- Frontend: Web server (PHP) serving the guestbook UI
- Redis Master: Primary Redis instance for data storage
- Redis Slave: Redis replica for read scaling
This conductor manages all three services using the conductor-framework's manifest reconciliation capabilities.
What It Demonstrates
- Manifest reconciliation for multiple services
- Template-based manifest generation with parameters
- CRD-based parameter management
- Service deployment and monitoring
- Event tracking and error handling
Project Structure
guestbook-conductor/
├── main.go # Conductor entry point
├── Dockerfile # Container build
├── README.md # Documentation
├── go.mod # Go module file
├── manifests/ # Kubernetes manifests
│ ├── frontend/
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ ├── redis-master/
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ └── redis-slave/
│ ├── deployment.yaml
│ └── service.yaml
└── deploy/ # Deployment configurations
├── conductor.yaml
├── build.sh
├── up.sh
└── down.sh
Step-by-Step Walkthrough
1. Setup: Embedding Manifests
The first step is to embed your Kubernetes manifests using Go's embed directive:
package main
import (
"context"
"embed"
"log"
"os"
"github.com/garunski/conductor-framework/pkg/framework"
)
//go:embed manifests
var manifestFS embed.FS
func main() {
ctx := context.Background()
cfg := framework.DefaultConfig()
cfg.AppName = "guestbook-conductor"
cfg.AppVersion = getVersion()
cfg.ManifestFS = manifestFS
cfg.ManifestRoot = "manifests"
if err := framework.Run(ctx, cfg); err != nil {
log.Fatalf("Error: %v", err)
}
}
func getVersion() string {
if v := os.Getenv("VERSION"); v != "" {
return v
}
return "dev"
}
2. Manifests: Structure and Template Syntax
Manifests are organized by service in the manifests/ directory. Each service has deployment and service YAML files that use Go template syntax for parameter substitution:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{if .NamePrefix}}{{.NamePrefix}}-{{end}}frontend
namespace: {{.Namespace}}
spec:
replicas: {{.Replicas | default 1}}
template:
spec:
containers:
- name: frontend
image: {{.ImageTag | default "latest"}}
Parameters are provided via the DeploymentParameters CRD or extracted from manifest defaults.
3. Parameters: Using DeploymentParameters CRD
Configure deployment parameters using a Kubernetes CRD:
apiVersion: conductor.io/v1alpha1
kind: DeploymentParameters
metadata:
name: default
namespace: default
spec:
global:
namespace: default
replicas: 1
services:
redis:
replicas: 3
imageTag: "7.0"
frontend:
replicas: 2
imageTag: "v5"
4. Running: Starting the Conductor
Build and run the conductor locally:
# Build
cd examples/guestbook-conductor
go build -o guestbook-conductor .
# Run
./guestbook-conductor
The conductor will:
- Load manifests from the embedded
manifests/directory - Start a web server on port 8081 (configurable via
PORTenv var) - Provide a web UI at
http://localhost:8081 - Manage Kubernetes resources based on the manifests
5. Deployment: Using API/UI to Deploy Services
Deploy services using the REST API:
# Deploy all services
curl -X POST http://localhost:8081/api/up
# Deploy specific services
curl -X POST http://localhost:8081/api/up \
-H "Content-Type: application/json" \
-d '{"services": ["frontend", "redis-master", "redis-slave"]}'
Or use the Web UI at http://localhost:8081 to deploy, update, or remove services interactively.
6. Monitoring: Viewing Events and Health Status
Monitor your deployments:
# Get service health
curl http://localhost:8081/api/services/health
# Get events
curl http://localhost:8081/api/events?limit=10
# Get errors only
curl http://localhost:8081/api/events/errors
Workflow
The complete workflow from configuration to deployment:
- Values: Parameters are defined in DeploymentParameters CRD or use framework defaults
- Templating: Go templates render manifests with parameter values and Sprig functions
- Manifests: Rendered Kubernetes YAML manifests are stored and indexed
- Reconciliation: Framework applies manifests to Kubernetes cluster via API
- Kubernetes Resources: Resources are created/updated in the cluster
Deploying to Kubernetes
You can also deploy the conductor itself to Kubernetes:
cd examples/guestbook-conductor/deploy
./up.sh
This will:
- Build the Docker image (if not already built)
- Deploy the conductor to the
guestbook-conductornamespace - Set up RBAC, PVC, and all necessary resources
To access the Web UI, port-forward the service:
kubectl port-forward -n guestbook-conductor svc/guestbook-conductor 8081:8081
Next Steps
- Explore the AI Agents page to see how to automate deployments
- Read the Implementation details to understand the framework internals
- Check out the Design Concepts to learn about the architecture
- View the full example source code on GitHub