|
| 1 | +# Component Extraction Plan: EKS to components-microstacks |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Plan to extract Kubernetes-agnostic components from EKS-hosted directory and move them to the shared `components-microstacks` directory for reuse across all cloud platforms (AWS EKS, Google GKE, Azure AKS). |
| 6 | + |
| 7 | +## Current State Analysis |
| 8 | + |
| 9 | +### components-microstacks Directory |
| 10 | +- `api.ts` - Empty placeholder |
| 11 | +- `console.ts` - Empty placeholder |
| 12 | +- `cert-manager.ts` - Empty placeholder |
| 13 | +- `openSearch.ts` - Functional OpenSearch Helm chart deployment |
| 14 | +- `index.ts` - Basic structure |
| 15 | + |
| 16 | +### Key Findings from EKS Analysis |
| 17 | + |
| 18 | +The EKS `90-pulumi-service/` stage contains the primary Kubernetes deployments that are cloud-agnostic: |
| 19 | + |
| 20 | +1. **API Deployment** - Complete Kubernetes deployment with database migration init container |
| 21 | +2. **Console Deployment** - Frontend service deployment |
| 22 | +3. **Kubernetes Services** - Service definitions for API and Console |
| 23 | +4. **Secrets Management** - Multiple Kubernetes secrets for various integrations |
| 24 | +5. **Encryption Service** - Local key storage with optional cloud KMS integration |
| 25 | + |
| 26 | +## Implementation Plan |
| 27 | + |
| 28 | +### Phase 1: Core Service Components (High Priority) |
| 29 | + |
| 30 | +#### 1. API Component (`api.ts`) |
| 31 | +- **Source**: `eks-hosted/90-pulumi-service/index.ts:133-225` |
| 32 | +- **Kubernetes Resources**: |
| 33 | + - Deployment with init container for database migrations |
| 34 | + - Service (port 80 → 8080) |
| 35 | + - PodDisruptionBudget for high availability |
| 36 | +- **Key Features**: |
| 37 | + - Database migration init container |
| 38 | + - Comprehensive environment variable configuration |
| 39 | + - Resource specifications and volume mounts |
| 40 | +- **Parameterization Needed**: |
| 41 | + - Image names (API and migrations) |
| 42 | + - Resource requirements (CPU, memory) |
| 43 | + - Environment variables (domain names, database connections) |
| 44 | + - Namespace configuration |
| 45 | + - Replica count |
| 46 | + - Storage configuration (abstract S3/GCS/Azure Blob) |
| 47 | + |
| 48 | +#### 2. Console Component (`console.ts`) |
| 49 | +- **Source**: `eks-hosted/90-pulumi-service/index.ts:240-305` |
| 50 | +- **Kubernetes Resources**: |
| 51 | + - Deployment for frontend service |
| 52 | + - Service (port 80 → 3000) |
| 53 | + - PodDisruptionBudget |
| 54 | +- **Key Features**: |
| 55 | + - Console container configuration |
| 56 | + - UI feature flag management |
| 57 | + - OAuth provider integration |
| 58 | +- **Parameterization Needed**: |
| 59 | + - Console image name |
| 60 | + - Domain configuration |
| 61 | + - Feature flags (email login/signup, SAML SSO) |
| 62 | + - OAuth provider settings |
| 63 | + - Internal API endpoint configuration |
| 64 | + |
| 65 | +### Phase 2: Supporting Infrastructure (Medium Priority) |
| 66 | + |
| 67 | +#### 3. Modular Secrets Management Components |
| 68 | +- **Source**: `eks-hosted/90-pulumi-service/secrets.ts` |
| 69 | +- **Current Issues**: Very EKS-specific, monolithic structure |
| 70 | +- **Proposed Split**: |
| 71 | + - `databaseSecrets.ts` - Database connection credentials |
| 72 | + - `smtpSecrets.ts` - Email server configuration |
| 73 | + - `oauthSecrets.ts` - OAuth provider settings (GitHub, Google, etc.) |
| 74 | + - `samlSecrets.ts` - SAML SSO certificate management with auto-generation |
| 75 | +- **Benefits**: Modular approach, flexible secret key naming, support for external secret references |
| 76 | + |
| 77 | +#### 4. Encryption Service Component (`encryptionService.ts`) |
| 78 | +- **Source**: `eks-hosted/90-pulumi-service/encryptionService.ts` |
| 79 | +- **Kubernetes Resources**: |
| 80 | + - Secret for local encryption keys |
| 81 | + - Volume and VolumeMount specifications |
| 82 | +- **Cloud Dependencies**: AWS KMS integration (conditional) |
| 83 | +- **Abstraction Goals**: |
| 84 | + - Support multiple cloud key management services (AWS KMS, Azure Key Vault, GCP KMS) |
| 85 | + - Maintain local key fallback option |
| 86 | + - Configurable encryption backends |
| 87 | + |
| 88 | +### Phase 3: Enhanced Infrastructure (Lower Priority) |
| 89 | + |
| 90 | +#### 5. OpenSearch Component Improvements |
| 91 | +- **Current**: Already exists in `components-microstacks/openSearch.ts` |
| 92 | +- **Issues**: |
| 93 | + - Contains GCP-specific service annotations (`cloud.google.com/neg`) |
| 94 | + - Hardcoded namespace logic |
| 95 | +- **Improvements**: |
| 96 | + - Remove cloud-specific annotations |
| 97 | + - Make service type configurable |
| 98 | + - Support different ingress patterns per cloud provider |
| 99 | + |
| 100 | +#### 6. Ingress Component (`ingress.ts`) |
| 101 | +- **Purpose**: Abstract ingress patterns across cloud providers |
| 102 | +- **Support**: |
| 103 | + - ALB (AWS) with AWS-specific annotations |
| 104 | + - NGINX (GKE/AKS) with standard annotations |
| 105 | + - Cloud-specific TLS certificate management |
| 106 | +- **Features**: |
| 107 | + - Parameterized annotations per cloud provider |
| 108 | + - Domain routing configuration |
| 109 | + - TLS certificate management patterns |
| 110 | + |
| 111 | +## Cross-Platform Comparison |
| 112 | + |
| 113 | +### Common Patterns Identified |
| 114 | +1. **API + Console deployment pattern** - Consistent across all platforms |
| 115 | +2. **Database migration init containers** - Same pattern everywhere |
| 116 | +3. **Secret management for credentials** - Similar structures |
| 117 | +4. **Environment variable injection** - Standard Kubernetes patterns |
| 118 | +5. **Service-to-service communication** - Consistent networking patterns |
| 119 | + |
| 120 | +### Platform-Specific Differences |
| 121 | +- **AWS EKS**: Uses ALB Ingress, Route53 DNS, ACM certificates |
| 122 | +- **Google GKE**: Uses NGINX Ingress, Cloud DNS, Let's Encrypt certificates |
| 123 | +- **Azure AKS**: Uses NGINX Ingress, Azure DNS, cert-manager certificates |
| 124 | + |
| 125 | +## Proposed Configuration Interface |
| 126 | + |
| 127 | +```typescript |
| 128 | +export interface PulumiServiceArgs { |
| 129 | + namespace: pulumi.Input<string>; |
| 130 | + imageTag: pulumi.Input<string>; |
| 131 | + |
| 132 | + // Domain configuration |
| 133 | + apiDomain: pulumi.Input<string>; |
| 134 | + consoleDomain: pulumi.Input<string>; |
| 135 | + |
| 136 | + // Resource configuration |
| 137 | + apiReplicas?: pulumi.Input<number>; |
| 138 | + consoleReplicas?: pulumi.Input<number>; |
| 139 | + |
| 140 | + // Storage configuration (cloud-agnostic) |
| 141 | + storageConfig: { |
| 142 | + checkpointsEndpoint: pulumi.Input<string>; |
| 143 | + policyPacksEndpoint: pulumi.Input<string>; |
| 144 | + escEndpoint: pulumi.Input<string>; |
| 145 | + eventsEndpoint: pulumi.Input<string>; |
| 146 | + }; |
| 147 | + |
| 148 | + // Database configuration |
| 149 | + database: DatabaseConfig; |
| 150 | + |
| 151 | + // Optional integrations |
| 152 | + smtp?: SMTPConfig; |
| 153 | + oauth?: OAuthConfig; |
| 154 | + openSearch?: OpenSearchConfig; |
| 155 | + |
| 156 | + // Ingress configuration (varies by cloud) |
| 157 | + ingress: IngressConfig; |
| 158 | +} |
| 159 | +``` |
| 160 | + |
| 161 | +## Migration Strategy |
| 162 | + |
| 163 | +### Step-by-Step Approach |
| 164 | +1. **Extract one component at a time** to minimize disruption |
| 165 | +2. **Create comprehensive TypeScript interfaces** for configuration |
| 166 | +3. **Update EKS implementation** to use new shared components |
| 167 | +4. **Validate functionality** with existing EKS deployments |
| 168 | +5. **Migrate GKE and AKS** to use shared components |
| 169 | +6. **Remove duplicate code** from platform-specific directories |
| 170 | +7. **Update documentation** and examples |
| 171 | + |
| 172 | +### Backward Compatibility |
| 173 | +- Maintain existing EKS functionality during transition |
| 174 | +- Provide migration guides for users |
| 175 | +- Support both old and new component structures temporarily |
| 176 | + |
| 177 | +## Benefits |
| 178 | + |
| 179 | +### Code Reuse |
| 180 | +- Same core components work across EKS, GKE, AKS |
| 181 | +- Reduced duplication of Kubernetes resource definitions |
| 182 | +- Consistent deployment patterns |
| 183 | + |
| 184 | +### Maintenance |
| 185 | +- Single source of truth for core Pulumi Service components |
| 186 | +- Easier to implement new features across all platforms |
| 187 | +- Simplified testing and validation |
| 188 | + |
| 189 | +### Consistency |
| 190 | +- Standardized configuration interfaces |
| 191 | +- Uniform behavior across cloud providers |
| 192 | +- Easier troubleshooting and support |
| 193 | + |
| 194 | +## Success Metrics |
| 195 | + |
| 196 | +1. **Reduction in duplicate code** - Measure lines of code eliminated |
| 197 | +2. **Cross-platform consistency** - Verify identical Kubernetes resources |
| 198 | +3. **Configuration simplicity** - Reduced platform-specific parameters |
| 199 | +4. **Maintenance efficiency** - Time to implement features across platforms |
| 200 | + |
| 201 | +## Next Steps |
| 202 | + |
| 203 | +1. **Begin with API component extraction** - Highest impact, well-defined scope |
| 204 | +2. **Create comprehensive test suite** - Validate components work across platforms |
| 205 | +3. **Update documentation** - Reflect new shared component architecture |
| 206 | +4. **Engage stakeholders** - Get feedback on proposed interfaces and migration approach |
0 commit comments