Infrastructure Deployment Guide
This guide documents the correct deployment sequence for raibid-ci infrastructure components.
Table of Contents
- Prerequisites
- Deployment Sequence
- Component Dependencies
- Deployment Methods
- Validation
- Troubleshooting
Prerequisites
System Requirements
- OS: Ubuntu 22.04 LTS (or compatible)
- CPU: 2+ cores recommended
- Memory: 4GB+ RAM
- Disk: 20GB+ available space
- Network: Internet connectivity for pulling images
Required Tools
# Install curl
sudo apt-get update
sudo apt-get install -y curl
# raibid-cli will auto-install:
# - kubectl
# - helm
# - k3sOptional Tools
# For manual operations
sudo apt-get install -y python3 python3-pip
# For validation
pip3 install yamllint
# For Helm operations
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bashDeployment Sequence
Infrastructure components must be deployed in the following order due to dependencies:
1. k3s (Foundation)
│
├─→ 2a. Redis (Job Queue)
│ │
│ └─→ 4. KEDA (Requires Redis)
│
└─→ 2b. Gitea (Git Server)
│
└─→ 5. Flux (Requires Gitea)
Detailed Steps
1. Deploy k3s (Foundation Layer)
k3s is the base Kubernetes cluster. All other components run on k3s.
# Deploy k3s
raibid-cli setup k3s
# Verify deployment
kubectl cluster-info
kubectl get nodesExpected Result: One node in “Ready” state.
Estimated Time: 2-3 minutes
2a. Deploy Redis (Job Queue)
Redis provides the job queue using Redis Streams.
# Deploy Redis
raibid-cli setup redis
# Verify deployment
kubectl get pods -n raibid-redis
kubectl exec -n raibid-redis raibid-redis-master-0 -- redis-cli pingExpected Result: Redis pod running, PING returns PONG.
Estimated Time: 2-3 minutes
2b. Deploy Gitea (Git Server)
Gitea provides Git hosting and OCI registry. Can be deployed in parallel with Redis.
# Deploy Gitea
raibid-cli setup gitea
# Verify deployment
kubectl get pods -n raibid-gitea
curl http://localhost:30080/api/v1/versionExpected Result: Gitea pods running, API responds with version.
Estimated Time: 5-7 minutes (includes database initialization)
3. Deploy KEDA (Autoscaling)
KEDA enables event-driven autoscaling based on Redis queue depth.
# Deploy KEDA
raibid-cli setup keda
# Verify deployment
kubectl get pods -n keda
kubectl get scaledobject -n raibid-ciExpected Result: KEDA operator running, ScaledObject created.
Estimated Time: 2-3 minutes
4. Deploy Flux (GitOps)
Flux provides GitOps continuous delivery from Gitea.
# Deploy Flux
raibid-cli setup flux
# Verify deployment
kubectl get pods -n flux-system
flux get sources gitExpected Result: Flux controllers running, GitRepository syncing.
Estimated Time: 3-4 minutes
Complete Deployment
Deploy all components in one command:
# Automated deployment in correct order
raibid-cli setup all
# Or using Task
cd infra
task deploy-allTotal Estimated Time: 15-20 minutes
Component Dependencies
Dependency Graph
graph TD K3S[k3s<br/>Base Cluster] REDIS[Redis<br/>Job Queue] GITEA[Gitea<br/>Git Server] KEDA[KEDA<br/>Autoscaler] FLUX[Flux<br/>GitOps] K3S --> REDIS K3S --> GITEA REDIS --> KEDA GITEA --> FLUX K3S --> KEDA K3S --> FLUX style K3S fill:#e1f5e1 style REDIS fill:#ffe1e1 style GITEA fill:#ffe1e1 style KEDA fill:#e1e5ff style FLUX fill:#e1e5ff
Dependency Matrix
| Component | Depends On | Optional Dependencies |
|---|---|---|
| k3s | None | - |
| Redis | k3s | - |
| Gitea | k3s | - |
| KEDA | k3s, Redis | - |
| Flux | k3s, Gitea | - |
Parallel Deployment
These components can be deployed in parallel:
- Redis and Gitea (both depend only on k3s)
These components must be deployed sequentially:
- k3s → Redis → KEDA
- k3s → Gitea → Flux
Deployment Methods
Method 1: raibid-cli (Recommended)
The raibid-cli tool handles all dependencies automatically:
# Deploy everything
raibid-cli setup all
# Deploy individual components
raibid-cli setup k3s
raibid-cli setup redis
raibid-cli setup gitea
raibid-cli setup keda
raibid-cli setup fluxAdvantages:
- Automatic dependency checking
- Credential management
- Rollback on failure
- Progress feedback
Method 2: Task Automation
Using the Taskfile for more control:
cd infra
# Validate before deployment
task validate-all
# Deploy all
task deploy-all
# Deploy individually
task deploy-k3s
task deploy-redis
task deploy-gitea
task deploy-keda
task deploy-flux
# Check status
task statusAdvantages:
- Validation before deployment
- Status checking
- Cleanup tasks included
Method 3: Manual Deployment
For advanced users who need full control:
k3s
curl -sfL https://get.k3s.io | sh -s - --config=infra/k3s/config.yamlRedis
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install raibid-redis bitnami/redis \
-n raibid-redis --create-namespace \
-f infra/redis/values.yamlGitea
helm repo add gitea-charts https://dl.gitea.io/charts/
helm install gitea gitea-charts/gitea \
-n raibid-gitea --create-namespace \
-f infra/gitea/values.yamlKEDA
helm repo add kedacore https://kedacore.github.io/charts
helm install raibid-keda kedacore/keda \
-n keda --create-namespace \
-f infra/keda/values.yaml
kubectl apply -f infra/keda/scaledobject.yaml
kubectl apply -f infra/keda/triggerauth.yamlFlux
flux bootstrap generic \
--url=http://gitea.raibid-gitea.svc.cluster.local:3000/raibid/infrastructure \
--username=raibid-admin \
--password=$GITEA_PASSWORD \
--namespace=flux-systemValidation
Pre-Deployment Validation
# Validate all manifests
cd infra
./scripts/validate-manifests.sh
# Lint manifests
./scripts/lint-manifests.sh
# Check dependencies
./scripts/check-dependencies.shPost-Deployment Validation
# Check all components
task status
# Or check individually
kubectl get pods -n raibid-redis
kubectl get pods -n raibid-gitea
kubectl get pods -n keda
kubectl get pods -n flux-system
# Test functionality
raibid-cli statusHealth Checks
k3s
kubectl cluster-info
kubectl get nodes
kubectl get pods -ARedis
kubectl exec -n raibid-redis raibid-redis-master-0 -- redis-cli PING
kubectl exec -n raibid-redis raibid-redis-master-0 -- redis-cli INFOGitea
curl http://localhost:30080/api/v1/version
curl http://localhost:30080/api/healthzKEDA
kubectl get scaledobject -n raibid-ci
kubectl describe scaledobject raibid-ci-agent-scaler -n raibid-ciFlux
flux get sources git
flux get kustomizations
kubectl logs -n flux-system -l app=source-controllerTroubleshooting
Component Won’t Deploy
-
Check dependencies:
./infra/scripts/check-dependencies.sh -
Check logs:
# For k3s sudo journalctl -u k3s -n 50 # For Kubernetes components kubectl logs -n <namespace> <pod-name> -
Check events:
kubectl get events -n <namespace> --sort-by='.lastTimestamp'
Deployment Hangs
-
Check pod status:
kubectl get pods -n <namespace> kubectl describe pod -n <namespace> <pod-name> -
Check resource availability:
kubectl top nodes df -h -
Restart component:
raibid-cli teardown <component> raibid-cli setup <component>
Networking Issues
-
Check DNS:
kubectl run test --rm -it --image=busybox -- nslookup kubernetes.default -
Check service:
kubectl get svc -n <namespace> kubectl describe svc -n <namespace> <service-name> -
Check connectivity:
kubectl run test --rm -it --image=curlimages/curl -- curl <service-url>
Complete Reset
If all else fails, reset and redeploy:
# Remove all components
task clean-all
# Or
raibid-cli teardown all
# Wait for cleanup to complete
sleep 30
# Redeploy
task deploy-allBest Practices
Development Environment
-
Use dev values files:
helm install component chart -f values.yaml -f values-dev.yaml -
Enable verbose logging:
raibid-cli -v setup <component> -
Keep backups:
kubectl get all -n <namespace> -o yaml > backup.yaml
Production Environment
- Use specific versions (not
latest) - Configure resource limits
- Enable monitoring
- Set up backup automation
- Use external secrets management
- Configure network policies
- Enable TLS/SSL
Upgrade Strategy
- Test in development first
- Back up data before upgrading
- Upgrade one component at a time
- Monitor for issues after each upgrade
- Have rollback plan ready