Two bugs found during validation: 1. rclone defaults to HTTPS when endpoint has no scheme — MinIO serves plain HTTP. All RCLONE_S3_ENDPOINT values now include http:// prefix. 2. rclone copyto returns exit 0 for non-existent S3 keys (empty bucket). initContainers crashed on chmod of missing file instead of falling through to PVC cache. Added `&& [ -f /binaries/$SERVICE ]` guard. Also: deploy stage uses `kubectl apply -k` (not -f) for minio/ dir to properly handle kustomization.yaml. Deleted stale s3-credentials secret from cluster. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
167 lines
5.0 KiB
YAML
167 lines
5.0 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: backtesting-service
|
|
namespace: foxhunt
|
|
labels:
|
|
app.kubernetes.io/name: backtesting-service
|
|
app.kubernetes.io/part-of: foxhunt
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 0
|
|
maxUnavailable: 1
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: backtesting-service
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
gitlab.com/prometheus_scrape: "true"
|
|
gitlab.com/prometheus_port: "9093"
|
|
gitlab.com/prometheus_path: "/metrics"
|
|
labels:
|
|
app.kubernetes.io/name: backtesting-service
|
|
spec:
|
|
imagePullSecrets:
|
|
- name: scw-registry
|
|
nodeSelector:
|
|
k8s.scaleway.com/pool-name: services
|
|
initContainers:
|
|
- name: fetch-binary
|
|
securityContext:
|
|
runAsUser: 0
|
|
image: rg.fr-par.scw.cloud/foxhunt-ci/foxhunt-runtime:latest
|
|
command: ["/bin/sh", "-c"]
|
|
args:
|
|
- |
|
|
set -e
|
|
SERVICE=backtesting_service
|
|
if rclone copyto :s3:foxhunt-binaries/latest/services/$SERVICE /binaries/$SERVICE 2>/dev/null && [ -f /binaries/$SERVICE ]; then
|
|
chmod +x /binaries/$SERVICE
|
|
cp /binaries/$SERVICE /cache/$SERVICE
|
|
echo "Fetched $SERVICE from S3 ($(stat -c%s /binaries/$SERVICE) bytes)"
|
|
elif [ -f /cache/$SERVICE ]; then
|
|
cp /cache/$SERVICE /binaries/$SERVICE
|
|
chmod +x /binaries/$SERVICE
|
|
echo "WARNING: S3 unavailable, using cached $SERVICE"
|
|
else
|
|
echo "FATAL: No binary available for $SERVICE (S3 down + empty cache)"
|
|
exit 1
|
|
fi
|
|
env:
|
|
- name: RCLONE_S3_PROVIDER
|
|
value: Minio
|
|
- name: RCLONE_S3_ENDPOINT
|
|
value: "http://minio.foxhunt.svc.cluster.local:9000"
|
|
- name: RCLONE_S3_REGION
|
|
value: us-east-1
|
|
- name: RCLONE_S3_ACCESS_KEY_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: minio-credentials
|
|
key: access-key
|
|
- name: RCLONE_S3_SECRET_ACCESS_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: minio-credentials
|
|
key: secret-key
|
|
volumeMounts:
|
|
- name: binaries
|
|
mountPath: /binaries
|
|
- name: binary-cache
|
|
mountPath: /cache
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 64Mi
|
|
limits:
|
|
cpu: 500m
|
|
memory: 128Mi
|
|
containers:
|
|
- name: backtesting-service
|
|
image: rg.fr-par.scw.cloud/foxhunt-ci/foxhunt-runtime:latest
|
|
command: ["/binaries/backtesting_service"]
|
|
ports:
|
|
- containerPort: 50053
|
|
name: grpc
|
|
- containerPort: 9093
|
|
name: metrics
|
|
env:
|
|
- name: DATABASE_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: foxhunt-secrets
|
|
key: db-password
|
|
- name: DATABASE_URL
|
|
value: "postgresql://foxhunt:$(DATABASE_PASSWORD)@postgres:5432/foxhunt"
|
|
- name: REDIS_URL
|
|
value: "redis://redis:6379"
|
|
- name: JWT_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: foxhunt-secrets
|
|
key: jwt-secret
|
|
- name: JWT_ISSUER
|
|
value: foxhunt-api-gateway
|
|
- name: JWT_AUDIENCE
|
|
value: foxhunt-services
|
|
- name: BENZINGA_API_KEY
|
|
value: "placeholder"
|
|
- name: RUST_LOG
|
|
value: info
|
|
- name: OTEL_EXPORTER_OTLP_ENDPOINT
|
|
value: "http://tempo.foxhunt.svc.cluster.local:4317"
|
|
volumeMounts:
|
|
- name: binaries
|
|
mountPath: /binaries
|
|
readOnly: true
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8082
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 10
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8082
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 15
|
|
failureThreshold: 5
|
|
resources:
|
|
requests:
|
|
cpu: 200m
|
|
memory: 256Mi
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi
|
|
volumes:
|
|
- name: binaries
|
|
emptyDir:
|
|
sizeLimit: 200Mi
|
|
- name: binary-cache
|
|
persistentVolumeClaim:
|
|
claimName: binary-cache-backtesting-service
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: backtesting-service
|
|
namespace: foxhunt
|
|
labels:
|
|
app.kubernetes.io/name: backtesting-service
|
|
app.kubernetes.io/part-of: foxhunt
|
|
spec:
|
|
selector:
|
|
app.kubernetes.io/name: backtesting-service
|
|
ports:
|
|
- port: 50053
|
|
targetPort: 50053
|
|
name: grpc
|
|
- port: 9093
|
|
targetPort: 9093
|
|
name: metrics
|