Skip to content

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

TypeScript
5.5 KB
Raw Blame
apiVersion: v1
kind: ServiceAccount
metadata:
  name: grok-llm-proxy
  namespace: control-plane
  labels:
    app: grok-llm-proxy
automountServiceAccountToken: false
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: grok-llm-proxy-config
  namespace: control-plane
  labels:
    app: grok-llm-proxy
data:
  GROK_LLM_PROXY_RUNTIME_PORT: "8080"
  GROK_LLM_PROXY_ADMIN_PORT: "8081"
  GROK_LLM_PROXY_PROBE_PORT: "9090"
  # GROK_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 (#784). Keep this equal to LIMITS.maxVisualRequestBodyBytes.
  GROK_LLM_PROXY_MAX_VISUAL_BODY_BYTES: "36700160"
  GROK_LLM_PROXY_MAX_STREAM_DURATION_MS: "1800000"
  GROK_LLM_PROXY_MAX_DEADLINE_MS: "1800000"
  GROK_LLM_PROXY_JWT_ISSUER: control-api
  GROK_LLM_PROXY_EXECUTION_ENABLED: "false"
  GROK_LLM_PROXY_CONTROL_API_URL: http://control-api-rpc-gateway.control-plane.svc.cluster.local:8090/api/v1
  GROK_LLM_PROXY_CONTROL_API_SERVICE: grok-llm-proxy
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: grok-llm-proxy
  namespace: control-plane
  labels:
    app: grok-llm-proxy
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: grok-llm-proxy
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: grok-llm-proxy
    spec:
      serviceAccountName: grok-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 (GROK_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: grok-llm-proxy
          image: clerum/grok-llm-proxy:0.1.0
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: grok-llm-proxy-config
          env:
            - name: GROK_LLM_PROXY_JWT_PUBLIC_KEY
              valueFrom:
                configMapKeyRef:
                  name: control-api-public-key
                  key: CONTROL_API_PUBLIC_KEY_PEM
            - name: GROK_LLM_PROXY_CONTROL_API_TOKEN
              valueFrom:
                secretKeyRef:
                  name: grok-llm-proxy-secrets
                  key: GROK_LLM_PROXY_CONTROL_API_TOKEN
            # Caps V8's old space under the 2048Mi limit, so heap growth is
            # bounded and collected before the kernel kills the pod. The cap
            # does not lower the peak: with eight 8 MiB streams and three
            # queued 8 MiB bodies (#739 D5), RSS measured 511 MiB at a 384 MiB
            # cap and 480-511 MiB without it. One ~36 MB V2 stream in the
            # visual slot on top of that load (#784) raised it to 775 MiB. 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 one
            # V2 stream (two on the Codex proxy), 640 MiB passed 3 of 3 for
            # Grok (it aborts the Codex proxy) and 768 MiB passed both; that load peaked at 1212-1482 MiB
            # of RSS on macOS, which is not cgroup memory. 768 MiB is the
            # smallest cap tested that passes both, 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: grok-llm-proxy
  namespace: control-plane
  labels:
    app: grok-llm-proxy
spec:
  type: ClusterIP
  selector:
    app: grok-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