# ACC Services CI/CD Migration Plan

**Date**: 2026-03-05
**Source**: Airtable `c60-Migration` base, table `CICD-Pipeline-Migration`
**Total Services**: 33 (32 pending + 1 completed)

## Quick Start

### Step 1: Clone All Service Repositories

```bash
# Run the clone script to get all service repositories
./scripts/clone-acc-services.sh
```

This will clone all 32 pending ACC service repositories to `/Users/iakpabio/Desktop/git-code/tbi-code/`

### Step 2: Analyze Service Repositories

```bash
# Run the analysis script to gather information about each service
./scripts/analyze-acc-services.sh
```

This will generate `ACC-SERVICES-ANALYSIS.md` with details about:
- Technology stack (Node.js, Python, Java)
- Framework (NestJS, Express, FastAPI, etc.)
- Existing CI/CD configurations
- Dependencies
- Entry points

### Step 3: Review Analysis and Prioritize

Review `ACC-SERVICES-ANALYSIS.md` and `AIRTABLE-MIGRATION-TRACKER.md` to determine migration order.

## Migration Workflow (Per Service)

For each service, follow this workflow:

### 1. Gather Service Information

**Required Information:**
- Service name (e.g., `tbi-acc-booking-service`)
- Namespace (e.g., `redtag`, `access`, `privatelabel`)
- Technology stack (Node.js version, Python version, etc.)
- Framework (NestJS, Express, FastAPI, etc.)
- Entry point (e.g., `dist/main.js` for NestJS)
- Environments to deploy (dev, qa, uat, prod)
- Environment variables/secrets needed

**How to Gather:**
```bash
# Check package.json for Node.js services
cat /Users/iakpabio/Desktop/git-code/tbi-code/[service-name]/package.json

# Check for existing Dockerfile
cat /Users/iakpabio/Desktop/git-code/tbi-code/[service-name]/Dockerfile

# Check for existing CircleCI config
cat /Users/iakpabio/Desktop/git-code/tbi-code/[service-name]/.circleci/config.yml
```

### 2. Create CI/CD Configuration in tbi-devops-environments

**Directory Structure:**
```
dev/[service-name]/
├── .circleci/
│   └── config.yml
├── docker/
│   └── Dockerfile
├── scripts/
│   ├── setup-kubectl.sh
│   └── deploy-services.sh
├── charts/
│   └── [service-name]/
│       ├── Chart.yaml
│       ├── values.yaml
│       └── templates/
│           ├── deployment.yaml
│           ├── service.yaml
│           ├── secrets.yaml
│           ├── ingress.yaml
│           ├── hpa.yaml
│           └── pdb.yaml
├── .github/
│   └── workflows/
│       └── manage-secrets.yml
├── README.md
└── SETUP-SUMMARY.md
```

**Use the CircleCI Pipeline Deployment Agent:**
```
Invoke the agent with service details to generate all files automatically
```

### 3. Create Values and Secrets in tbi-environments

**Files to Create:**
```
/Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments/
├── dev/
│   ├── values/[service-name].yaml
│   ├── secrets/secrets.[service-name].yaml
│   └── requirements.yaml (update)
├── qa/
│   ├── values/[service-name].yaml
│   ├── secrets/secrets.[service-name].yaml
│   └── requirements.yaml (update)
├── uat/
│   ├── values/[service-name].yaml
│   ├── secrets/secrets.[service-name].yaml
│   └── requirements.yaml (update)
└── prod/
    ├── values/[service-name].yaml
    ├── secrets/secrets.[service-name].yaml
    └── requirements.yaml (update)
```

**Encrypt Secrets:**
```bash
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments
sops -e -i dev/secrets/secrets.[service-name].yaml
```

### 4. Create Files in Service Repository

**Files to Create:**
```
/Users/iakpabio/Desktop/git-code/tbi-code/[service-name]/
├── VERSION
└── .github/
    └── workflows/
        └── manage-secrets.yml
```

### 5. Commit and Push Changes

**tbi-devops-environments:**
```bash
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-devops-environments
git add dev/[service-name]
git commit -m "Add CI/CD pipeline for [service-name]"
git push origin master
```

**tbi-environments:**
```bash
cd /Users/iakpabio/Desktop/git-code/tbi-code/tbi-environments
git add dev/values/[service-name].yaml
git add dev/secrets/secrets.[service-name].yaml
git add dev/requirements.yaml
git commit -m "Add values and secrets for [service-name]"
git push origin master
```

**Service Repository:**
```bash
cd /Users/iakpabio/Desktop/git-code/tbi-code/[service-name]
git checkout develop  # or appropriate branch
git add VERSION .github/workflows/manage-secrets.yml
git commit -m "Add VERSION file and secrets management workflow"
git push origin develop
```

### 6. Test Deployment

**Trigger CircleCI Pipeline:**
- Push a commit to the `develop` branch
- Monitor CircleCI dashboard
- Check pod status: `kubectl get pods -n [namespace]`
- Check logs: `kubectl logs -n [namespace] [pod-name]`

### 7. Document and Update Tracking

- Update `AIRTABLE-MIGRATION-TRACKER.md`
- Create service-specific documentation
- Update Airtable record (optional)

## Batch Processing Strategy

### Batch 1: Core Multi-Environment Services (5 services)
Priority: HIGH | Complexity: HIGH

1. **tbi-acc-hotel-service** (6 envs: dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
2. **tbi-acc-package-service** (6 envs: dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
3. **tbi-acc-hotel-service-connector** (6 envs: dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
4. **tbi-acc-travelbrandsagent** (6 envs: dev, prod, qa, tbi-acc-gx, tbi-acc-his, uat)
5. **tbi-acc-profile-service** (6 envs: dev, prod, qa, tbi-acc-his, tbi-retail, uat)

**Approach**: Start with dev environment, validate, then roll out to other environments

### Batch 2: Standard Services (10 services)
Priority: MEDIUM | Complexity: MEDIUM

6. **tbi-acc-booking-service** (4 envs: dev, prod, qa, uat)
7. **tbi-acc-quotes-service** (4 envs: dev, prod, qa, uat)
8. **tbi-acc-notification-service** (4 envs: dev, prod, qa, uat)
9. **tbi-acc-mybooking-service** (3 envs: dev, prod, uat)
10. **tbi-acc-mybooking-frontend** (3 envs: dev, prod, uat)
11. **tbi-acc-mybff** (3 envs: dev, prod, uat)
12. **tbi-acc-ceetiz-connector** (3 envs: dev, prod, uat)
13. **tbi-acc-exotiktours-connector** (3 envs: dev, prod, uat)
14. **tbi-acc-sabreapi** (3 envs: dev, prod, uat)
15. **tbi-acc-profile-sync-service** (5 envs: dev, prod, qa, tbi-retail, uat)

### Batch 3: Gimmonix Automation Services (7 services)
Priority: LOW | Complexity: LOW (similar pattern)

16. **tbi-acc-gimmonix-automation** (1 env: dev)
17. **tbi-acc-gimmonix-automation-cron** (1 env: dev)
18. **tbi-acc-gimmonix-automation-cron-2** (1 env: dev)
19. **tbi-acc-gimmonix-automation-cron-3** (1 env: dev)
20. **tbi-acc-gimmonix-automation-cron-4** (1 env: dev)
21. **tbi-acc-gimmonix-automation-cron-5** (1 env: dev)
22. **tbi-acc-gimmonix-automation-cron-6** (1 env: dev)

**Approach**: These likely share similar configuration, can be batch processed

### Batch 4: Miscellaneous Services (7 services)
Priority: LOW | Complexity: LOW

23. **tbi-acc-travelbrands** (2 envs: dev, prod)
24. **tbi-acc-package-cron** (2 envs: dev, prod)
25. **tbi-acc-cron-service** (2 envs: dev, uat)
26. **tbi-acc-clone-mybff** (1 env: dev)
27. **tbi-acc-corporate-booking** (1 env: dev)
28. **tbi-acc-booking-notification** (1 env: dev)
29. **tbi-acc-cronjobs** (1 env: qa)

### Batch 5: Legacy Services (3 services)
Priority: VERIFY FIRST | Complexity: UNKNOWN

30. **tbi-acc-hotel-service-old** (1 env: prod)
31. **tbi-acc-package-service-old** (2 envs: prod, tbi-charts/prod)
32. **tbi-acc-hotel-service-connector-old** (1 env: prod)

**Approach**: Verify if these are still in use before migrating

## Namespace Mapping Guide

Based on service patterns:

- **redtag**: Mobile hotel services, mapping services
- **access**: Package and booking services
- **privatelabel**: Private label services
- **copolo**: Copolo-specific services
- **tbi-retail**: Retail-specific services

**To Determine Namespace:**
1. Check existing Kubernetes deployments
2. Check service naming patterns
3. Ask team/check documentation
4. Use `redtag` as default for ACC services if unclear

## Common Patterns by Service Type

### Standard API Service (NestJS/Express)
- Entry point: `dist/main.js` or `dist/index.js`
- Port: 3000 (typically)
- Ingress: nginx with cert-manager
- Autoscaling: 1-3 replicas

### Cron Service
- Entry point: Same as API service
- Port: 3000 (for health checks)
- Ingress: Usually disabled
- Autoscaling: Fixed 1 replica
- CronJob: May need separate CronJob manifest

### Frontend Service
- Entry point: Nginx serving static files
- Port: 80
- Ingress: nginx with cert-manager
- Autoscaling: 2-5 replicas

### Connector Service
- Entry point: `dist/main.js`
- Port: 3000
- Ingress: nginx with cert-manager
- Autoscaling: 1-3 replicas
- External API dependencies

## Troubleshooting Guide

### Issue: Repository doesn't exist
**Solution**: Check if repository name is correct, may need to create new repository

### Issue: Can't determine entry point
**Solution**: Check package.json `start:prod` script or existing Dockerfile

### Issue: Missing environment variables
**Solution**: Check existing deployment or ask team for required variables

### Issue: Namespace unclear
**Solution**: Check existing Kubernetes deployments or use `redtag` as default

### Issue: Service has multiple components
**Solution**: Follow multi-service pattern like `tbi-redtag-mobile-hotel-service`

## Reference Documentation

- **Template Service**: `dev/tbi-acc-hotel-mapping-service/`
- **Patterns Guide**: `.kiro/steering/circleci-pipeline-patterns.md`
- **Agent Config**: `.kiro/agents/circleci-pipeline-deployment-agent.json`
- **Completed Setup**: `docs/SETUP-COMPLETE-tbi-acc-hotel-mapping-service.md`

## Progress Tracking

Track progress in:
1. `AIRTABLE-MIGRATION-TRACKER.md` (this repository)
2. `ACC-SERVICES-ANALYSIS.md` (generated by analysis script)
3. Airtable `CICD-Pipeline-Migration` table (optional)

## Next Actions

1. ✅ Run `./scripts/clone-acc-services.sh` to clone all repositories
2. ✅ Run `./scripts/analyze-acc-services.sh` to analyze services
3. ⏳ Review analysis report
4. ⏳ Select first service to migrate (recommend starting with Batch 3 - Gimmonix services for quick wins)
5. ⏳ Gather service information
6. ⏳ Create CI/CD configuration
7. ⏳ Test deployment
8. ⏳ Document and move to next service

## Estimated Timeline

- **Batch 1** (5 services × 6 envs): ~10-15 hours (2-3 hours per service)
- **Batch 2** (10 services × 3-4 envs): ~15-20 hours (1.5-2 hours per service)
- **Batch 3** (7 services × 1 env): ~3-5 hours (30-45 min per service)
- **Batch 4** (7 services × 1-2 envs): ~5-7 hours (45-60 min per service)
- **Batch 5** (3 services): ~2-3 hours (verify + migrate)

**Total Estimated Time**: 35-50 hours

**With Automation**: Can reduce by 40-50% using the CircleCI Pipeline Deployment Agent
