Skip to main content
The backend service (exchange-router) handles the main API routing and request processing for the exchange platform.

Deployment Configuration

The backend is deployed as a Kubernetes deployment with auto-scaling capabilities.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: exchange-router-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: exchange-router
  template:
    metadata:
      labels:
        app: exchange-router
    spec:
      containers:
        - name: exchange-router
          image: jogeshwar01/exchange-router:ed9f044dc79ee713da9518648524e0c68a70ddf7
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: "300m"
            limits:
              cpu: "2000m"
          env:
            - name: SERVER_ADDR
              valueFrom:
                secretKeyRef:
                  name: exchange-router-secret
                  key: server_addr
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: exchange-router-secret
                  key: database_url
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: exchange-router-secret
                  key: redis_url

Service Configuration

The service exposes the backend on port 80, routing traffic to container port 8080.
apiVersion: v1
kind: Service
metadata:
  name: exchange-router-service
spec:
  selector:
    app: exchange-router
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  type: ClusterIP

Horizontal Pod Autoscaler

The backend automatically scales based on CPU utilization.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: exchange-router-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: exchange-router-deployment
  minReplicas: 1
  maxReplicas: 2
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 95

Environment Variables

The backend service requires the following environment variables from secrets:
VariableDescriptionSource
SERVER_ADDRServer listen addressSecret: exchange-router-secret
DATABASE_URLPostgreSQL connection URLSecret: exchange-router-secret
REDIS_URLRedis connection URLSecret: exchange-router-secret

Resource Limits

ResourceRequestLimit
CPU300m2000m
Memory--

Scaling Configuration

  • Min Replicas: 1
  • Max Replicas: 2
  • Scaling Metric: CPU utilization at 95%
  • Target Port: 8080
  • Service Port: 80

Secrets

Secrets are managed using Sealed Secrets (Bitnami). The encrypted secret includes:
  • Database connection URL
  • Redis connection URL
  • Server address configuration
Refer to sealed-secret.yml in the source repository for the encrypted values.

Build docs developers (and LLMs) love