# ACC Services Migration - Status Update

**Date**: 2026-03-05
**Migration Type**: Pipeline Migration from Existing CI/CD → CircleCI
**Critical Discovery**: Services are already running with existing pipelines!

## Key Findings

### ✅ What Already Exists (Currently Running)

1. **Services**: All 33 ACC services are already deployed and running in Kubernetes
2. **Values Files**: All services have values files in `/Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments/dev/values/`
3. **Secrets Files**: Encrypted secrets exist in `tbi-environments/dev/secrets/`
4. **Requirements.yaml**: Services are already listed in `dev/requirements.yaml`
5. **Namespace**: All ACC services use `redtag` namespace (confirmed via `group: "redtag"`)
6. **Ingress**: Most services use `internal-nginx` ingress class
7. **Existing Pipeline**: Services currently deploy via a separate (non-CircleCI) pipeline

### ❌ What's Missing (Need to Create for CircleCI)

For each service, we need to create in `tbi-devops-environments`:

1. **CircleCI Config**: `.circleci/config.yml` - NEW pipeline configuration
2. **Dockerfile**: `docker/Dockerfile` - May exist in service repo, need to centralize
3. **Deployment Scripts**: 
   - `scripts/setup-kubectl.sh`
   - `scripts/deploy-services.sh`
4. **Helm Charts**: Complete chart structure in `charts/[service-name]/` - May need to migrate from existing location
5. **GitHub Actions**: `.github/workflows/manage-secrets.yml` - For secrets management only
6. **Documentation**: README.md, SETUP-SUMMARY.md

### 🔍 What Needs Investigation

1. **Current Pipeline**: What system is currently deploying these services? (Jenkins, GitHub Actions, manual?)
2. **Existing Dockerfiles**: Where are the current Dockerfiles located?
3. **Existing Helm Charts**: Where are the current Helm charts? (tbi-devops-common? Service repos?)
4. **Migration Strategy**: Can we run both pipelines in parallel during migration?
5. **Cutover Plan**: How do we switch from old pipeline to CircleCI?

## Revised Migration Strategy

**This is a PIPELINE MIGRATION, not a greenfield deployment.**

The services are already running. We're migrating the CI/CD pipeline from the existing system to CircleCI.

### Migration Goals

1. ✅ Create CircleCI pipelines in tbi-devops-environments
2. ✅ Centralize Dockerfiles and Helm charts
3. ✅ Maintain zero downtime during migration
4. ✅ Run parallel pipelines during transition (if possible)
5. ✅ Validate CircleCI pipeline before decommissioning old pipeline
6. ✅ Document the new pipeline for team

### Migration Approach

**Phase 1: Preparation**
- Identify current pipeline system
- Locate existing Dockerfiles and Helm charts
- Document current deployment process
- Create CircleCI pipeline structure

**Phase 2: Parallel Running**
- Deploy via CircleCI to dev environment
- Keep existing pipeline active
- Validate CircleCI deployments
- Compare outputs

**Phase 3: Cutover**
- Switch to CircleCI for dev
- Gradually roll out to qa, uat
- Finally migrate prod
- Decommission old pipeline

**Phase 4: Cleanup**
- Remove old pipeline configurations
- Update documentation
- Train team on new pipeline

## Updated Workflow (Per Service)

### Phase 1: Discovery (10 min)
```bash
SERVICE_NAME="tbi-acc-booking-service"

# 1. Check if values file exists (ALREADY EXISTS)
cat /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments/dev/values/${SERVICE_NAME}.yaml

# 2. Check if secrets file exists
ls -la /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments/dev/secrets/secrets.${SERVICE_NAME}.yaml

# 3. Check if service repo exists
ls -la /Users/iakpabio/Desktop/git-code/tbi-code/${SERVICE_NAME}

# 4. Check current deployment
kubectl get deployment ${SERVICE_NAME} -n redtag
```

### Phase 2: Create CI/CD Pipeline (20-30 min)
```bash
# Create directory structure in tbi-devops-environments
mkdir -p dev/${SERVICE_NAME}/{.circleci,docker,scripts,charts,github/workflows}

# Copy and customize from reference service
cp -r dev/tbi-acc-hotel-mapping-service/* dev/${SERVICE_NAME}/

# Update all references to new service name
```

### Phase 3: Verify/Create Secrets (5-10 min)
```bash
# If secrets file doesn't exist, create it
# If it exists but not encrypted, encrypt it
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments
sops -e -i dev/secrets/secrets.${SERVICE_NAME}.yaml
```

### Phase 4: Service Repo Setup (5 min)
```bash
cd /Users/iakpabio/Desktop/git-code/tbi-code/${SERVICE_NAME}

# Create VERSION file if doesn't exist
echo "1.0.0" > VERSION

# Add GitHub Actions workflow
mkdir -p .github/workflows
cp /path/to/template/manage-secrets.yml .github/workflows/
```

### Phase 5: Test & Deploy (15-20 min)
```bash
# Commit changes
# Push to trigger CircleCI
# Monitor deployment
# Verify pod status
```

## Priority Services Analysis

### Tier 1: Production Services (20 services)
These are already in production and need CI/CD pipelines:

1. tbi-acc-booking-service (dev, prod, qa, uat)
2. tbi-acc-ceetiz-connector (dev, prod, uat)
3. tbi-acc-exotiktours-connector (dev, prod, uat)
4. tbi-acc-hotel-service (dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
5. tbi-acc-hotel-service-connector (dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
6. tbi-acc-mybff (dev, prod, uat)
7. tbi-acc-mybooking-frontend (dev, prod, uat)
8. tbi-acc-mybooking-service (dev, prod, uat)
9. tbi-acc-notification-service (dev, prod, qa, uat)
10. tbi-acc-package-cron (dev, prod)
11. tbi-acc-package-service (dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
12. tbi-acc-profile-service (dev, prod, qa, tbi-acc-his, tbi-retail, uat)
13. tbi-acc-profile-sync-service (dev, prod, qa, tbi-retail, uat)
14. tbi-acc-quotes-service (dev, prod, qa, uat)
15. tbi-acc-sabreapi (dev, prod, uat)
16. tbi-acc-travelbrands (dev, prod)
17. tbi-acc-travelbrandsagent (dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
18. tbi-acc-hotel-service-connector-old (prod) - VERIFY IF NEEDED
19. tbi-acc-hotel-service-old (prod) - VERIFY IF NEEDED
20. tbi-acc-package-service-old (prod, tbi-charts/prod) - VERIFY IF NEEDED

### Tier 2: Development Only Services (12 services)
These are dev-only and lower risk:

21. tbi-acc-booking-notification (dev)
22. tbi-acc-clone-mybff (dev)
23. tbi-acc-corporate-booking (dev)
24. tbi-acc-cron-service (dev, uat)
25. tbi-acc-cronjobs (qa)
26. tbi-acc-gimmonix-automation (dev)
27. tbi-acc-gimmonix-automation-cron (dev)
28. tbi-acc-gimmonix-automation-cron-2 (dev)
29. tbi-acc-gimmonix-automation-cron-3 (dev)
30. tbi-acc-gimmonix-automation-cron-4 (dev)
31. tbi-acc-gimmonix-automation-cron-5 (dev)
32. tbi-acc-gimmonix-automation-cron-6 (dev)

### Tier 3: Already Completed (1 service)
33. tbi-acc-hotel-mapping-service (dev) ✅

## Recommended Approach

### Option 1: Start with Dev-Only Services (Recommended)
**Rationale**: Lower risk, faster to complete, build confidence

**Start with Gimmonix services** (7 services, all dev-only):
- Similar configuration
- Low risk
- Quick wins
- ~30-45 min each = 3-5 hours total

### Option 2: Start with Critical Production Services
**Rationale**: High business value, but higher risk

**Start with core services**:
- tbi-acc-booking-service
- tbi-acc-hotel-service
- tbi-acc-package-service

## Next Immediate Actions

1. ✅ Run `./scripts/clone-acc-services.sh` to clone repositories
2. ✅ Run `./scripts/analyze-acc-services.sh` to analyze tech stacks
3. ⏳ Check which secrets files exist:
   ```bash
   ls -la /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments/dev/secrets/ | grep tbi-acc
   ```
4. ⏳ Check current Kubernetes deployments:
   ```bash
   kubectl get deployments -n redtag | grep tbi-acc
   ```
5. ⏳ Select first batch of services to migrate
6. ⏳ Start creating CI/CD pipelines

## Time Estimate Revision

**Original Estimate**: 35-50 hours
**Revised Estimate**: 20-30 hours

**Reason**: Values files and requirements.yaml already exist, reducing configuration time by ~40%

**Per Service Time**:
- Discovery: 10 min
- Create CI/CD pipeline: 20-30 min
- Verify/create secrets: 5-10 min
- Service repo setup: 5 min
- Test & deploy: 15-20 min
**Total per service**: 55-75 min (vs original 2-3 hours)

## Success Metrics

For each service:
- ✅ CI/CD pipeline created in tbi-devops-environments
- ✅ Secrets verified/created and encrypted in tbi-environments
- ✅ VERSION file in service repository
- ✅ GitHub Actions workflow in service repository
- ✅ Successful CircleCI pipeline run
- ✅ Pod deployed and running in Kubernetes
- ✅ Documentation updated

---

**Key Insight**: The infrastructure is already partially in place. We're primarily adding the CI/CD automation layer, not building from scratch!
