apiVersion: apps/v1
kind: Deployment
metadata:
  name: transit-planner-api
  namespace: mobility
  labels:
    app: transit-planner
    component: api
spec:
  replicas: 4
  selector:
    matchLabels:
      app: transit-planner
      component: api
  template:
    metadata:
      labels:
        app: transit-planner
        component: api
    spec:
      containers:
        - name: api
          image: registry.city.example/mobility/transit-planner:2.8.3
          ports:
            - containerPort: 8080
          env:
            - name: CITY_TIMEZONE
              value: America/Toronto
            - name: GTFS_STATIC_URL
              value: https://data.city.example/gtfs/current.zip
            - name: GTFS_REALTIME_VEHICLE_POSITIONS
              value: https://realtime.city.example/gtfs/vehicle-positions
            - name: GTFS_REALTIME_TRIP_UPDATES
              value: https://realtime.city.example/gtfs/trip-updates
            - name: GTFS_REALTIME_SERVICE_ALERTS
              value: https://realtime.city.example/gtfs/service-alerts
            - name: ROUTING_PROFILE
              value: urban_multimodal
            - name: MAX_WALKING_DISTANCE_METERS
              value: "1200"
            - name: CACHE_TTL_SECONDS
              value: "45"
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: transit-planner-secrets
                  key: database-url
            - name: REDIS_URL
              valueFrom:
                secretKeyRef:
                  name: transit-planner-secrets
                  key: redis-url
          readinessProbe:
            httpGet:
              path: /health/ready
              port: 8080
            initialDelaySeconds: 15
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /health/live
              port: 8080
            initialDelaySeconds: 30
            periodSeconds: 20
          resources:
            requests:
              cpu: 500m
              memory: 768Mi
            limits:
              cpu: "2"
              memory: 2Gi
---
apiVersion: v1
kind: Service
metadata:
  name: transit-planner-api
  namespace: mobility
spec:
  type: ClusterIP
  selector:
    app: transit-planner
    component: api
  ports:
    - name: http
      port: 80
      targetPort: 8080