Examples
Real-world examples demonstrating how to use Konductor synchronization primitives to solve common coordination problems in Kubernetes.
Example Categories
ETL and Data Processing
- ETL Pipeline - Multi-stage extract, transform, load coordination
- Batch Processing - Controlled concurrent batch job execution
- MapReduce Workflows - Coordinate map and reduce phases
Database Operations
- Database Migrations - Singleton migration execution
- Backup Coordination - Prevent overlapping backups
- Connection Pooling - Limit database connections
CI/CD and Deployments
- Deployment Gates - Wait for validation before deploy
- Test Coordination - Coordinate distributed testing
- Release Orchestration - Multi-service deployment coordination
Microservices Patterns
- Leader Election - Service leader election
- Circuit Breaker - Coordinate service degradation
- Rate Limiting - Distributed rate limiting
Quick Reference
Common Patterns
InitContainer Gating
initContainers:
- name: wait-dependencies
image: logiciq/koncli:latest
command:
- koncli
- barrier
- wait
- dependencies-ready
Semaphore in Script
if koncli semaphore acquire resource-limit --ttl=10m; then
# Do work
koncli semaphore release resource-limit
fi
Singleton CronJob
HOLDER_ID="$HOSTNAME-$$"
if koncli lease acquire singleton-job --holder $HOLDER_ID --timeout=0; then
# Run job
koncli lease release singleton-job --holder $HOLDER_ID
fi
Pipeline Stage Coordination
# Stage 1: Signal completion
koncli barrier arrive stage-1-complete
# Stage 2: Wait for stage 1
koncli barrier wait stage-1-complete --timeout=30m
Integration Examples
Argo Workflows
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: coordinated-workflow
spec:
templates:
- name: wait-barrier
container:
image: logiciq/koncli:latest
command: [koncli, barrier, wait, "{{inputs.parameters.barrier-name}}"]
Tekton Pipelines
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: acquire-semaphore
spec:
steps:
- name: acquire
image: logiciq/koncli:latest
script: |
koncli semaphore acquire "$(params.semaphore-name)" --ttl="$(params.ttl)"
Flux/GitOps
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: app-deployment
spec:
dependsOn:
- name: database-migration
postBuild:
substitute:
BARRIER_NAME: "deployment-ready"
Performance Examples
High-Throughput Processing
# Process 1000 items with max 50 concurrent workers
apiVersion: konductor.io/v1
kind: Semaphore
metadata:
name: worker-pool
spec:
permits: 50
ttl: 5m
Large-Scale Coordination
# Coordinate 100 parallel jobs
apiVersion: konductor.io/v1
kind: Barrier
metadata:
name: massive-parallel
spec:
expected: 100
timeout: 2h
quorum: 95 # Allow 5% failure rate
Troubleshooting Examples
Debug Stuck Barriers
# Check barrier status
kubectl describe barrier my-barrier
# List arrivals
kubectl get barrier my-barrier -o jsonpath='{.status.arrivals}'
# Check for missing jobs
kubectl get jobs -l barrier=my-barrier
Monitor Semaphore Usage
# Watch semaphore status
watch kubectl get semaphore my-semaphore
# Check permit holders
kubectl get semaphore my-semaphore -o jsonpath='{.status.holders}'
Lease Debugging
# Check lease holder
kubectl get lease my-lease -o jsonpath='{.status.holder}'
# Verify holder is alive
kubectl get pods | grep "$(kubectl get lease my-lease -o jsonpath='{.status.holder}')"
Best Practices from Examples
- Use meaningful names - Choose descriptive resource names
- Set appropriate timeouts - Balance safety with responsiveness
- Handle failures gracefully - Always clean up resources
- Monitor coordination state - Use status fields for observability
- Test coordination logic - Verify behavior under failure conditions
Contributing Examples
Have a useful Konductor pattern? We'd love to include it!
- Fork the repository
- Add your example to the appropriate category
- Include complete YAML manifests and explanations
- Submit a pull request
Next Steps
- Choose an example that matches your use case
- Adapt the patterns to your specific requirements
- Check the API Reference for detailed configuration options
- Use the CLI Reference for command-line integration