Skip to content

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

TypeScript
9.8 KB
Raw Blame
apiVersion: v1
kind: ServiceAccount
metadata:
  name: host-context-controller
  namespace: control-plane
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: host-context-controller
  namespace: control-plane
  labels:
    app: host-context-controller
spec:
  replicas: 1
  # HCC's safety model assumes a single NetworkPolicy writer: replicas:1 with no
  # leader election (see statelessLifecycleExecutor.ts). RollingUpdate (the
  # default) starts the new pod before terminating the old one, so every rollout
  # would overlap two writers — during which the outgoing replica can win a
  # conflict-retry replace and land its wider spec back over a policy the new
  # replica just hardened and certified, with no NetworkPolicy resync to heal it
  # and /ready still 200. Recreate terminates the old pod first, honouring the
  # single-writer assumption through the rollout too.
  strategy:
    type: Recreate
  # CONTRACT: hcc-rollout-recovery=external-detection-only; owner=evenfire-infra
  # Recreate + replicas:1 means a botched rollout (new pod never Ready) leaves
  # /ready 503. Kubernetes will not self-heal that; the evenfire-infra deploy
  # workflows own automatic `rollout undo --to-revision` for this Deployment
  # only (evenfire#391). The deploy job still fails after a successful undo.
  # This deadline is DETECTION ONLY: it flips Progressing=False
  # (ProgressDeadlineExceeded) and fails `kubectl rollout status` for callers
  # without their own --timeout; it does not roll back.
  #
  # Value (origin/dev, 2026-08-05): HCC's /ready stays 503 until its initial fleet
  # reconciliation finishes, so time-to-Ready scales with the McpServer/Context
  # fleet — clerum-dev took 651s at 108 McpServers / 22 Contexts. The unset default
  # (600s) governed the deploy because `kubectl rollout status` aborts the instant
  # the deadline is exceeded. apply-inter-service-tokens.sh used to start that
  # clock on every token apply via `rollout restart`, even when
  # INTERNAL_CONTROL_JWT_HCC_HMAC_SECRET was unchanged; no-op token deploys no
  # longer Recreate this Deployment, so they no longer consume this budget.
  # A real HMAC change (or FORCE_CONSUMER_RESTART) still restarts HCC — then
  # 1200s covers the 900s wait plus a 300s head-start. Mitigation, not the
  # fix — #205 decouples readiness from fleet convergence, after which this should
  # come back down.
  progressDeadlineSeconds: 1200
  selector:
    matchLabels:
      app: host-context-controller
  template:
    metadata:
      labels:
        app: host-context-controller
    spec:
      serviceAccountName: host-context-controller
      securityContext:
        seccompProfile:
          type: RuntimeDefault
      containers:
      - name: host-context-controller
        image: clerum/host-context-controller:0.9.5
        imagePullPolicy: Always
        ports:
        - containerPort: 8081
          name: http
          protocol: TCP
        env:
        # HCC signs InternalControl JWTs with its issuer-specific HS256 secret.
        - name: INTERNAL_CONTROL_JWT_HCC_HMAC_SECRET
          valueFrom:
            secretKeyRef:
              name: internal-control-jwt-secrets
              key: INTERNAL_CONTROL_JWT_HCC_HMAC_SECRET
        - name: CONTEXT_MAPPER_PORT
          value: "8081"
        - name: CONTEXT_MAPPER_NAMESPACE
          value: mcp-server
        # Product baseline for stateless Hosts. HCC uses the effective idle window
        # max(idleMinutes, idleFloorMinutes), then drains active work before scale-to-zero.
        - name: CONTEXT_MAPPER_STATELESS_IDLE_MINUTES
          value: "30"
        - name: CONTEXT_MAPPER_STATELESS_IDLE_FLOOR_MINUTES
          value: "15"
        - name: CONTEXT_MAPPER_STATELESS_DRAIN_GRACE_MS
          value: "60000"
        - name: CONTEXT_MAPPER_HEARTBEAT_POLL_MS
          value: "10000"
        - name: CONTEXT_MAPPER_HOST_NAMESPACE
          value: mcp-host
        - name: CONTEXT_MAPPER_HOST_IMAGE
          value: clerum/mcp-host:0.9.5
        - name: CONTEXT_MAPPER_EGRESS_PROXY_IMAGE
          value: clerum/nginx-egress-proxy:0.1.0
        # Legacy JSON GFS mutation cap (bytes), passed through to generated gfsc
        # pods. Upload v2 uses raw indexed parts and is configured independently
        # through CONTEXT_MAPPER_GFSC_UPLOAD_* private-infra settings.
        - name: GFS_MAX_WRITE_BODY_BYTES
          value: "25165824"
        # gfsc memory limit for the legacy buffered path. v2 part streaming must be
        # validated against the configured part/global concurrency budgets instead.
        - name: CONTEXT_MAPPER_GFSC_LIMIT_MEMORY
          value: 512Mi
        - name: CONTEXT_MAPPER_RUNTIME_NAMESPACES
          value: mcp-server,sandbox-recipes,rpc-proxy,sandbox-ui
        # sandbox-ui pods are React HTTP servers — they don't talk to the K8s
        # API or the HCC discovery API, so they get only deny-all + DNS.
        - name: CONTEXT_MAPPER_MINIMAL_INFRA_NAMESPACES
          value: sandbox-ui
        # issue #299: the external-egress resync interval MUST stay <= half the
        # overlap window (HCC_EXTERNAL_EGRESS_OVERLAP_SEC, default 300s) so the
        # persisted sliding window of resolved /32s never lapses between
        # refreshes. The legacy 300 (== the overlap) let the accumulated set
        # expire before the next refresh, which is the #299 drift itself; HCC
        # now fails closed at startup on any interval > overlap/2.
        - name: HCC_EXTERNAL_EGRESS_RESYNC_SEC
          value: "60"
        - name: HCC_EXTERNAL_EGRESS_DNS_TIMEOUT_MS
          value: "5000"
        - name: HCC_HOST_K8S_REQUEST_TIMEOUT_MS
          value: "30000"
        # Bounded cross-Host concurrency for a full/lifecycle Host fleet pass.
        # Urgent per-Host events (ADDED/MODIFIED/DELETED/wake) are admitted
        # outside this budget, so the low default optimizes for Kubernetes API
        # stability rather than convergence speed (issue #791). Integer 1..8.
        - name: HCC_HOST_FULL_RECONCILE_CONCURRENCY
          value: "2"
        - name: CONTEXT_MAPPER_STDIO_BRIDGE_IMAGE
          value: clerum/stdio-bridge:0.9.5
        # workspace-files-controller (per-SharedFileSystem) — see config.ts wfc*
        - name: CONTEXT_MAPPER_WFC_IMAGE
          value: clerum/workspace-files-controller:0.9.5
        - name: CONTEXT_MAPPER_WFC_IMAGE_PULL_POLICY
          value: IfNotPresent
        - name: CONTEXT_MAPPER_WFC_PORT
          value: "8086"
        - name: CONTEXT_MAPPER_WFC_INIT_IMAGE
          value: busybox:1.36
        - name: CONTEXT_MAPPER_WFC_JWT_PUBLIC_KEY_CM
          value: mcp-host-config
        - name: CONTEXT_MAPPER_WFC_JWT_PUBLIC_KEY_CM_KEY
          value: CLERUM_AUTH_JWT_PUBLIC_KEY
        - name: HCC_TARGET_NAMESPACE
          value: mcp-host
        # Existing Control API RS256 public key used to verify the first-party
        # mcp-host access-token family on HCC v2 Host routes. The audience is a
        # fixed HCC code contract; the issuer is read from the same ConfigMap
        # key consumed by Control API so signer and verifier cannot drift.
        - name: HCC_MCP_HOST_JWT_PUBLIC_KEY
          valueFrom:
            configMapKeyRef:
              name: control-api-public-key
              key: CONTROL_API_PUBLIC_KEY_PEM
        - name: HCC_MCP_HOST_JWT_ISSUER
          valueFrom:
            configMapKeyRef:
              name: control-api-config
              key: CONTROL_API_ADMIN_JWT_ISSUER
        - name: HCC_MCP_HOST_JWT_MAX_TTL_SECONDS
          valueFrom:
            configMapKeyRef:
              name: control-api-config
              key: WORKFLOW_APPROVAL_ACCESS_TTL_SEC
        - name: CONTROL_API_BASE_URL
          value: http://control-api.control-plane.svc.cluster.local:8090
        # URL of the nginx gateway that mediates mcp-host → control-api
        # traffic. HCC injects this as MCP_HOST_GATEWAY_URL into every
        # 1st-party mcp-host pod it provisions; HCC itself does NOT use it
        # (HCC calls control-api directly via CONTROL_API_BASE_URL).
        - name: MCP_HOST_GATEWAY_URL
          value: http://nginx-workflow-approval-gateway.control-plane.svc.cluster.local:8092
        # Plugin image-host allowlist (Phase 2.3) — audit mode by default. Base
        # ships a vendor-neutral default; environment overlays override this env
        # with the image prefixes for their own registry.
        - name: CONTEXT_MAPPER_ALLOWED_IMAGE_PREFIXES
          value: "ghcr.io/evenfire-ai/,mongodb/,mcr.microsoft.com/,clerum/"
        - name: CONTEXT_MAPPER_ENFORCE_IMAGE_ALLOWLIST
          value: "false"
        livenessProbe:
          httpGet:
            path: /health
            port: http
            scheme: HTTP
          initialDelaySeconds: 20
          periodSeconds: 15
          failureThreshold: 4
          successThreshold: 1
          timeoutSeconds: 10
        readinessProbe:
          httpGet:
            path: /ready
            port: http
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 5
          failureThreshold: 6
          successThreshold: 1
          timeoutSeconds: 10
        startupProbe:
          httpGet:
            path: /health
            port: http
            scheme: HTTP
          periodSeconds: 3
          failureThreshold: 40
          successThreshold: 1
          timeoutSeconds: 10
        resources:
          limits:
            cpu: 500m
            memory: 256Mi
          requests:
            cpu: 100m
            memory: 128Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          seccompProfile:
            type: RuntimeDefault
---
apiVersion: v1
kind: Service
metadata:
  name: host-context-controller
  namespace: control-plane
  labels:
    app: host-context-controller
spec:
  type: ClusterIP
  selector:
    app: host-context-controller
  ports:
  - name: http
    port: 8081
    targetPort: http
    protocol: TCP