22
33This directory contains Kubernetes manifests for deploying the Rewards Eligibility Oracle with persistent state management.
44
5- ## Prerequisites
6-
7- - Kubernetes cluster (version 1.19+)
8- - ` kubectl ` configured to access your cluster
9- - Docker image published to ` ghcr.io/graphprotocol/rewards-eligibility-oracle `
10- - ** Storage class configured** (see Storage Configuration below)
11-
12- ## Quick Start
13-
14- ### 1. Create Secrets (Required)
15-
16- ``` bash
17- # Copy the example secrets file
18- cp k8s/secrets.yaml.example k8s/secrets.yaml
19-
20- # Edit with your actual credentials
21- # IMPORTANT: Never commit secrets.yaml to version control
22- nano k8s/secrets.yaml
23- ```
24-
25- ** Required secrets:**
26-
27- - ** ` google-credentials ` ** : Service account JSON for BigQuery access
28- - ** ` blockchain-private-key ` ** : Private key for Arbitrum Sepolia transactions
29- - ** ` arbitrum-api-key ` ** : API key for Arbiscan contract verification
30- - ** ` slack-webhook-url ` ** : Webhook URL for operational notifications
31-
32- ### 2. Configure Storage (Required)
33-
34- ``` bash
35- # Check available storage classes
36- kubectl get storageclass
37-
38- # If you see a default storage class (marked with *), skip to step 3
39- # Otherwise, edit persistent-volume-claim.yaml and uncomment the appropriate storageClassName
40- ```
41-
42- ** Common storage classes by platform:**
43-
44- - ** AWS EKS** : ` gp2 ` , ` gp3 ` , ` ebs-csi `
45- - ** Google GKE** : ` standard ` , ` ssd `
46- - ** Azure AKS** : ` managed-premium ` , ` managed `
47- - ** Local/Development** : ` hostpath ` , ` local-path `
48-
49- ### 3. Deploy to Kubernetes
50-
51- ``` bash
52- # Apply all manifests
53- kubectl apply -f k8s/
54-
55- # Verify deployment
56- kubectl get pods -l app=rewards-eligibility-oracle
57- kubectl get pvc -l app=rewards-eligibility-oracle
58- ```
59-
60- ### 4. Monitor Deployment
61-
62- ``` bash
63- # Check pod status
64- kubectl describe pod -l app=rewards-eligibility-oracle
65-
66- # View logs
67- kubectl logs -l app=rewards-eligibility-oracle -f
68-
69- # Check persistent volumes
70- kubectl get pv
71- ```
72-
735## Architecture
746
757### Persistent Storage
768
779The service uses ** two persistent volumes** to maintain state across pod restarts:
7810
79- - ** ` rewards-eligibility-oracle-data ` (5GB) ** : Circuit breaker state, last run tracking, BigQuery cache, CSV outputs
80- - ** ` rewards-eligibility-oracle-logs ` (2GB) ** : Application logs
11+ - ** ` rewards-eligibility-oracle-data ` ** : Circuit breaker state, last run tracking, BigQuery cache, CSV outputs
12+ - ** ` rewards-eligibility-oracle-logs ` ** : Application logs
8113
8214** Mount points:**
8315
@@ -86,98 +18,17 @@ The service uses **two persistent volumes** to maintain state across pod restart
8618
8719### Configuration Management
8820
89- ** Non-sensitive configuration** → ` ConfigMap ` (` configmap.yaml ` )
90- ** Sensitive credentials** → ` Secret ` (` secrets.yaml ` )
91-
92- This separation provides:
93-
94- - ✅ Easy configuration updates without rebuilding images
95- - ✅ Secure credential management with base64 encoding
96- - ✅ Clear separation of concerns
97-
98- ### Resource Allocation
99-
100- ** Requests (guaranteed):**
101-
102- - CPU: 250m (0.25 cores)
103- - Memory: 512M
104-
105- ** Limits (maximum):**
106-
107- - CPU: 1000m (1.0 core)
108- - Memory: 1G
109-
110- ## State Persistence Benefits
111-
112- With persistent volumes, the service maintains:
113-
114- 1 . ** Circuit breaker state** → Prevents infinite restart loops
115- 2 . ** Last run tracking** → Enables proper catch-up logic
116- 3 . ** BigQuery cache** → Dramatic performance improvement (30s vs 5min restarts)
117- 4 . ** CSV audit artifacts** → Regulatory compliance and debugging
118-
119- ## Health Checks
120-
121- The deployment uses ** file-based health checks** (same as docker-compose):
122-
123- ** Liveness probe:** Checks ` /app/healthcheck ` file modification time
124- ** Readiness probe:** Verifies ` /app/healthcheck ` file exists
125-
126- ## Troubleshooting
127-
128- ### Pod Won't Start
129-
130- ``` bash
131- # Check events
132- kubectl describe pod -l app=rewards-eligibility-oracle
133-
134- # Common issues:
135- # - Missing secrets
136- # - PVC provisioning failures
137- # - Image pull errors
138- ```
139-
140- ### Check Persistent Storage
141-
142- ``` bash
143- # Verify PVCs are bound
144- kubectl get pvc
145-
146- # Check if volumes are mounted correctly
147- kubectl exec -it deployment/rewards-eligibility-oracle -- ls -la /app/data
148- ```
149-
150- ### Debug Configuration
151-
152- ``` bash
153- # Check environment variables
154- kubectl exec -it deployment/rewards-eligibility-oracle -- env | grep -E " (BIGQUERY|BLOCKCHAIN)"
155-
156- # Verify secrets are mounted
157- kubectl exec -it deployment/rewards-eligibility-oracle -- ls -la /etc/secrets
158- ```
159-
160- ## Security Best Practices
161-
162- ✅ ** Secrets never committed** to version control
163- ✅ ** Service account** with minimal BigQuery permissions
164- ✅ ** Private key** stored in Kubernetes secrets (base64 encoded)
165- ✅ ** Resource limits** prevent resource exhaustion
166- ✅ ** Read-only filesystem** where possible
21+ The application requires a ` config.toml ` file to run. Configuration is split across two Kubernetes resources:
16722
168- ## Production Considerations
23+ ** ConfigMap ( ` configmap.yaml ` ): **
16924
170- - ** Backup strategy** for persistent volumes
171- - ** Monitoring** and alerting setup
172- - ** Log aggregation** (ELK stack, etc.)
173- - ** Network policies** for additional security
174- - ** Pod disruption budgets** for maintenance
175- - ** Horizontal Pod Autoscaler** (if needed for scaling)
25+ - Contains the complete ` config.toml ` file structure
26+ - Includes non-sensitive settings (RPC URLs, contract addresses, batch sizes, etc.)
27+ - Uses ` $VARIABLE_NAME ` placeholders for sensitive values
28+ - ** Mounted as a file** at ` /app/config.toml `
17629
177- ## Next Steps
30+ ** Secret ( ` secrets.yaml ` ): **
17831
179- 1 . ** Test deployment** in staging environment
180- 2 . ** Verify state persistence** across pod restarts
181- 3 . ** Set up monitoring** and alerting
182- 4 . ** Configure backup** for persistent volumes
183- 5 . ** Enable quality checking** after successful validation
32+ - Contains sensitive credentials
33+ - ** Injected as environment variables** into the container
34+ - Values are substituted into ` config.toml ` placeholders at runtime
0 commit comments