Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
5.3 KB
Raw Blame
apiVersion: v1
kind: ServiceAccount
metadata:
  name: codex-llm-proxy
  namespace: control-plane
  labels:
    app: codex-llm-proxy
automountServiceAccountToken: false
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: codex-llm-proxy-config
  namespace: control-plane
  labels:
    app: codex-llm-proxy
data:
  CODEX_LLM_PROXY_RUNTIME_PORT: "8080"
  CODEX_LLM_PROXY_ADMIN_PORT: "8081"
  CODEX_LLM_PROXY_PROBE_PORT: "9090"
  # CODEX_LLM_PROXY_MAX_BODY_BYTES is deliberately unset: the proxy derives it
  # from LIMITS.maxRequestBodyBytes plus the envelope allowance (#731), and it
  # governs ordinary and anonymous requests.
  # V2 visual envelope. Keep this equal to LIMITS.maxVisualRequestBodyBytes.
  CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES: "25165824"
  CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS: "1800000"
  CODEX_LLM_PROXY_MAX_DEADLINE_MS: "1800000"
  CODEX_LLM_PROXY_JWT_ISSUER: control-api
  CODEX_LLM_PROXY_EXECUTION_ENABLED: "false"
  CODEX_LLM_PROXY_CONTROL_API_URL: http://control-api-rpc-gateway.control-plane.svc.cluster.local:8090/api/v1
  CODEX_LLM_PROXY_CONTROL_API_SERVICE: codex-llm-proxy
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: codex-llm-proxy
  namespace: control-plane
  labels:
    app: codex-llm-proxy
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: codex-llm-proxy
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: codex-llm-proxy
    spec:
      serviceAccountName: codex-llm-proxy
      automountServiceAccountToken: false
      # On SIGTERM the proxy stops accepting connections and finishes every
      # request it already admitted (#739 D6, R18): queue wait 60 s + body read
      # 10 s + redeem 15 s + stream cap (CODEX_LLM_PROXY_MAX_STREAM_DURATION_MS /
      # 1000) + finalize 30 s (one call plus its one retry, 15 s each) + 20 s
      # margin. test/deployManifest.test.ts derives this value from the proxy's
      # own constants.
      terminationGracePeriodSeconds: 1935
      securityContext:
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: codex-llm-proxy
          image: clerum/codex-llm-proxy:0.1.0
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: codex-llm-proxy-config
          env:
            - name: CODEX_LLM_PROXY_JWT_PUBLIC_KEY
              valueFrom:
                configMapKeyRef:
                  name: control-api-public-key
                  key: CONTROL_API_PUBLIC_KEY_PEM
            - name: CODEX_LLM_PROXY_CONTROL_API_TOKEN
              valueFrom:
                secretKeyRef:
                  name: codex-llm-proxy-secrets
                  key: CODEX_LLM_PROXY_CONTROL_API_TOKEN
            # Caps V8's old space under the 2048Mi limit so the heap is
            # collected before the kernel kills the pod. Measured peak with
            # eight 8 MiB streams, two 24 MiB visual streams and three queued
            # 8 MiB bodies (#739 D5): 790 MiB of RSS at a 384 MiB cap, 886-1009
            # MiB without one. The byte-based BodyBudget also admits about
            # eight compact bodies of the worst structure the contract admits
            # (#806 Q1), each a ~44 MiB tree once parsed. With 8 held streams,
            # 8 queued bodies and two visual streams, 640 MiB aborted 3 of 3
            # and 768 MiB passed 3 of 3; that load peaked at 1327-1460 MiB of
            # RSS on macOS, which is not cgroup memory. 768 MiB is the smallest
            # cap tested that passes, not a proven minimum.
            - name: NODE_OPTIONS
              value: "--max-old-space-size=768"
          ports:
            - name: runtime
              containerPort: 8080
              protocol: TCP
            - name: admin
              containerPort: 8081
              protocol: TCP
            - name: metrics
              containerPort: 9090
              protocol: TCP
          readinessProbe:
            httpGet: { path: /readyz, port: metrics }
            initialDelaySeconds: 4
            periodSeconds: 8
            timeoutSeconds: 2
          livenessProbe:
            httpGet: { path: /healthz, port: metrics }
            initialDelaySeconds: 8
            periodSeconds: 12
            timeoutSeconds: 2
          resources:
            requests:
              cpu: 50m
              memory: 768Mi
            limits:
              cpu: 250m
              memory: 2048Mi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 1001
            runAsGroup: 1001
            seccompProfile:
              type: RuntimeDefault
            capabilities:
              drop: [ALL]
          volumeMounts:
            - name: tmp
              mountPath: /tmp
      volumes:
        - name: tmp
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: codex-llm-proxy
  namespace: control-plane
  labels:
    app: codex-llm-proxy
spec:
  type: ClusterIP
  selector:
    app: codex-llm-proxy
  ports:
    - name: runtime
      port: 8080
      protocol: TCP
      targetPort: runtime
    - name: admin
      port: 8081
      protocol: TCP
      targetPort: admin
    - name: metrics
      port: 9090
      protocol: TCP
      targetPort: metrics