|
| 1 | +# Service Connections Configuration |
| 2 | + |
| 3 | +## Overview |
| 4 | +This document outlines the configuration for connecting to external services in our Kubernetes deployment. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | +- Kubernetes cluster configured |
| 8 | +- kubectl installed and configured |
| 9 | +- Helm installed |
| 10 | +- Access to create and modify Kubernetes resources |
| 11 | + |
| 12 | +## Service Connections |
| 13 | + |
| 14 | +### 1. Database Connections |
| 15 | + |
| 16 | +#### 1.1 CockroachDB Serverless |
| 17 | +```yaml |
| 18 | +# cockroachdb-secret.yaml |
| 19 | +apiVersion: v1 |
| 20 | +kind: Secret |
| 21 | +metadata: |
| 22 | + name: cockroachdb-connection |
| 23 | + namespace: production |
| 24 | +type: Opaque |
| 25 | +stringData: |
| 26 | + connection-string: "postgresql://user:[email protected]:26257/ai_database?sslmode=verify-full&options=--cluster%3Dyour-cluster" |
| 27 | +``` |
| 28 | +
|
| 29 | +#### 1.2 Upstash Redis |
| 30 | +```yaml |
| 31 | +# redis-secret.yaml |
| 32 | +apiVersion: v1 |
| 33 | +kind: Secret |
| 34 | +metadata: |
| 35 | + name: redis-connection |
| 36 | + namespace: production |
| 37 | +type: Opaque |
| 38 | +stringData: |
| 39 | + connection-string: "redis://default:[email protected]:6379" |
| 40 | +``` |
| 41 | +
|
| 42 | +### 2. Message Queue Connections |
| 43 | +
|
| 44 | +#### 2.1 CloudAMQP RabbitMQ |
| 45 | +```yaml |
| 46 | +# rabbitmq-secret.yaml |
| 47 | +apiVersion: v1 |
| 48 | +kind: Secret |
| 49 | +metadata: |
| 50 | + name: rabbitmq-connection |
| 51 | + namespace: production |
| 52 | +type: Opaque |
| 53 | +stringData: |
| 54 | + connection-string: "amqps://user:[email protected]/vhost" |
| 55 | +``` |
| 56 | +
|
| 57 | +### 3. LLM API Connections |
| 58 | +
|
| 59 | +#### 3.1 Google Gemini |
| 60 | +```yaml |
| 61 | +# gemini-secret.yaml |
| 62 | +apiVersion: v1 |
| 63 | +kind: Secret |
| 64 | +metadata: |
| 65 | + name: gemini-connection |
| 66 | + namespace: production |
| 67 | +type: Opaque |
| 68 | +stringData: |
| 69 | + api-key: "your-gemini-api-key" |
| 70 | +``` |
| 71 | +
|
| 72 | +### 4. Application Configuration |
| 73 | +
|
| 74 | +#### 4.1 Environment Variables |
| 75 | +```yaml |
| 76 | +# env-config.yaml |
| 77 | +apiVersion: v1 |
| 78 | +kind: ConfigMap |
| 79 | +metadata: |
| 80 | + name: app-environment |
| 81 | + namespace: production |
| 82 | +data: |
| 83 | + COCKROACHDB_URL: "postgresql://user:[email protected]:26257/ai_database?sslmode=verify-full&options=--cluster%3Dyour-cluster" |
| 84 | + REDIS_URL: "redis://default:[email protected]:6379" |
| 85 | + RABBITMQ_URL: "amqps://user:[email protected]/vhost" |
| 86 | + GEMINI_API_KEY: "your-gemini-api-key" |
| 87 | +``` |
| 88 | +
|
| 89 | +#### 4.2 Deployment Configuration |
| 90 | +```yaml |
| 91 | +# app-deployment.yaml |
| 92 | +apiVersion: apps/v1 |
| 93 | +kind: Deployment |
| 94 | +metadata: |
| 95 | + name: app-deployment |
| 96 | + namespace: production |
| 97 | +spec: |
| 98 | + replicas: 3 |
| 99 | + selector: |
| 100 | + matchLabels: |
| 101 | + app: app |
| 102 | + template: |
| 103 | + metadata: |
| 104 | + labels: |
| 105 | + app: app |
| 106 | + spec: |
| 107 | + containers: |
| 108 | + - name: app |
| 109 | + image: app:latest |
| 110 | + envFrom: |
| 111 | + - configMapRef: |
| 112 | + name: app-environment |
| 113 | + env: |
| 114 | + - name: COCKROACHDB_URL |
| 115 | + valueFrom: |
| 116 | + secretKeyRef: |
| 117 | + name: cockroachdb-connection |
| 118 | + key: connection-string |
| 119 | + - name: REDIS_URL |
| 120 | + valueFrom: |
| 121 | + secretKeyRef: |
| 122 | + name: redis-connection |
| 123 | + key: connection-string |
| 124 | + - name: RABBITMQ_URL |
| 125 | + valueFrom: |
| 126 | + secretKeyRef: |
| 127 | + name: rabbitmq-connection |
| 128 | + key: connection-string |
| 129 | + - name: GEMINI_API_KEY |
| 130 | + valueFrom: |
| 131 | + secretKeyRef: |
| 132 | + name: gemini-connection |
| 133 | + key: api-key |
| 134 | +``` |
| 135 | +
|
| 136 | +## Validation |
| 137 | +
|
| 138 | +### 1. Verify Secrets |
| 139 | +```bash |
| 140 | +# Check CockroachDB secret |
| 141 | +kubectl get secret cockroachdb-connection -n production |
| 142 | + |
| 143 | +# Check Redis secret |
| 144 | +kubectl get secret redis-connection -n production |
| 145 | + |
| 146 | +# Check RabbitMQ secret |
| 147 | +kubectl get secret rabbitmq-connection -n production |
| 148 | + |
| 149 | +# Check Gemini secret |
| 150 | +kubectl get secret gemini-connection -n production |
| 151 | +``` |
| 152 | + |
| 153 | +### 2. Test Connections |
| 154 | +```bash |
| 155 | +# Test CockroachDB connection |
| 156 | +kubectl exec -it <pod-name> -n production -- cockroach sql --url "$COCKROACHDB_URL" --execute "SHOW DATABASES;" |
| 157 | + |
| 158 | +# Test Redis connection |
| 159 | +kubectl exec -it <pod-name> -n production -- redis-cli -u "$REDIS_URL" ping |
| 160 | + |
| 161 | +# Test RabbitMQ connection |
| 162 | +kubectl exec -it <pod-name> -n production -- curl -u user:password "https://your-instance.cloudamqp.com/api/overview" |
| 163 | + |
| 164 | +# Test Gemini API |
| 165 | +kubectl exec -it <pod-name> -n production -- curl -H "Authorization: Bearer $GEMINI_API_KEY" https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent |
| 166 | +``` |
| 167 | + |
| 168 | +## Common Issues and Solutions |
| 169 | + |
| 170 | +### Issue 1: Connection Timeouts |
| 171 | +- **Solution**: Check network policies and firewall rules |
| 172 | +- **Prevention**: Implement proper timeout handling |
| 173 | + |
| 174 | +### Issue 2: Authentication Failures |
| 175 | +- **Solution**: Verify credentials and permissions |
| 176 | +- **Prevention**: Use proper error handling |
| 177 | + |
| 178 | +### Issue 3: Resource Limits |
| 179 | +- **Solution**: Adjust resource quotas |
| 180 | +- **Prevention**: Monitor resource usage |
| 181 | + |
| 182 | +## Best Practices |
| 183 | + |
| 184 | +### 1. Security |
| 185 | +- Use secrets for sensitive data |
| 186 | +- Implement proper RBAC |
| 187 | +- Monitor access patterns |
| 188 | +- Regular credential rotation |
| 189 | + |
| 190 | +### 2. Configuration |
| 191 | +- Use ConfigMaps for non-sensitive data |
| 192 | +- Implement proper validation |
| 193 | +- Document configurations |
| 194 | +- Version control |
| 195 | + |
| 196 | +### 3. Monitoring |
| 197 | +- Set up proper logging |
| 198 | +- Configure alerts |
| 199 | +- Monitor performance |
| 200 | +- Regular reviews |
| 201 | + |
| 202 | +## Next Steps |
| 203 | +- Set up monitoring |
| 204 | +- Configure backup |
| 205 | +- Implement disaster recovery |
| 206 | +- Regular testing |
0 commit comments