Skip to content
Opod

Endpoints

Gateways in front

Put LiteLLM or another gateway in front of an endpoint for per-user keys and budgets, join a Gateway API InferencePool, or serve Vertex AI's routes.

opod serves tokens on GPUs you own. The jobs of a gateway are not opod's: keys per user, team and app; requests and tokens per minute; quotas and budgets; spend in money; which team may use which model; prompt and answer logs; PII and injection checks. Run a gateway in front of each endpoint for them. opod never reads the gateway, and the gateway reads nothing from opod but its endpoints.

apps ──► gateway (yours) ──► opod endpoint (leader) ──► workers
         keys, budgets,        endpoint key check,
         spend, guardrails     request classes

In short

A gateway such as LiteLLM sits between your apps and an opod endpoint. It owns users, budgets, rate limits and guardrails. opod owns the GPUs and checks one key: the gateway's. You give the gateway one endpoint key, register the endpoint as an OpenAI model in the gateway, and then close every other way in.

When you need it

  • You need a key per user, team or app, with its own limits or budget.
  • You must log prompts, filter PII or block prompt injection. opod does none of these.
  • You want spend in money per team. opod reports GPU-hours, and the gateway reports tokens.
  • Your cluster runs a Gateway API inference gateway, and you want it to choose the leader (InferencePool, below).
  • Vertex AI serves the model from a custom container (Vertex routes, below).

Do it

The full step-by-step LiteLLM guide has every command, including the LiteLLM install. The short form:

  1. Mint the gateway's key

    opodcp key create --endpoint chat-small --no-expiry litellm > litellm.key

    stdout holds only the key (sk-orc-…). stderr shows its id (k_…) and its expiry. Store the key in the gateway's Secret, for example as OPOD_CHAT_SMALL_KEY.

  2. Find the URL the gateway calls

    curl -s -H "$H" https://cp.example.com/api/v1/endpoints | jq -r '.[] | select(.name=="chat-small") | .url'
    # http://opodcp-ep-chat-small.opod.svc:8080           without front doors
    # http://opodcp-ep-chat-small-front.opod.svc:8080     with front doors (plan.gateways.enabled)

    Use this url with /v1 added as the gateway's api_base.

  3. Register the endpoint in the gateway

    Add the model_list entry from LiteLLM below, then restart the gateway.

  4. Require keys on the endpoint

    curl -s -H "$H" -H 'Content-Type: application/json' -X PUT \
      https://cp.example.com/api/v1/endpoints/<id>/auth -d '{"requireKeys": true}'

    From now on a caller without an opod key gets 401 from the leader.

  5. Admit only the gateway on the network

    Apply the NetworkPolicy in LiteLLM step 3, with the gateway's namespace and labels.

Check it worked

# through the gateway, with a gateway key: 200 and an answer
curl -s https://litellm.example.com/v1/chat/completions -H "Authorization: Bearer sk-<gateway key>" \
  -H 'Content-Type: application/json' -d '{"model":"chat-small","messages":[{"role":"user","content":"hi"}]}' | jq .usage
 
# straight to the endpoint with no key, from a pod in the cluster: 401
curl -s -o /dev/null -w '%{http_code}\n' http://opodcp-ep-chat-small.opod.svc:8080/v1/models

A good answer: the first call returns a usage object with non-zero completion_tokens. The second call prints 401, or it times out when your NetworkPolicy also blocks that pod. In the console, the endpoint's Connect card shows Require keys on, and the API keys page lists the litellm key as active.

If it fails

SymptomCauseFix
The gateway gets 401 from opodthe gateway's key is wrong, expired, revoked or for another endpointmint a new key for this endpoint (step 1) and update the gateway's Secret
PUT …/auth answers 400the endpoint has no active key yetmint the key first, then require keys
PUT …/auth refused E-VERTEX-KEYSthe plan serves the keyless Vertex AI routesturn exposure.vertex off, or leave keys off
Streamed answers count zero tokens at the gatewaystream_options.include_usage is not setadd it to the model's litellm_params
Every rollout fails its probe step after you applied your NetworkPolicythe policy does not admit the API server, which carries the control plane's calls to a leaderadd the API server's source address as an ipBlock
The gateway times out after networkPolicy.leaderIsolation.enabled=truethe gateway dials the leader's own Service opodcp-ep-<name>, whose port isolation closedpoint the gateway at the endpoint's url (…-front), or list the gateway's pods in networkPolicy.leaderIsolation.from
E-POOL-MODEL-MISMATCHtwo endpoints in one InferencePool serve different modelsone pool per model
E-INFERENCEPOOL-CRDthe cluster has no InferencePool v1 CRDsinstall your gateway's CRDs first

LiteLLM

This is the reference form of the steps above. The full step-by-step LiteLLM guide covers the install, TLS, streaming and cost per team.

  1. Mint one endpoint key for the gateway

    opodcp key create --endpoint chat-small --no-expiry litellm

    It is the only opod key the gateway holds. Your users get gateway keys, never opod ones.

  2. Register the endpoint as a model

    # litellm-config.yaml
    model_list:
      - model_name: chat-small                        # what your users ask for
        litellm_params:
          model: openai/<the endpoint's model id>
          api_base: http://opodcp-ep-chat-small.opod.svc:8080/v1   # the endpoint's url + /v1
          api_key: os.environ/OPOD_CHAT_SMALL_KEY
          stream_options: { include_usage: true }       # count streamed tokens
    general_settings:
      master_key: os.environ/LITELLM_MASTER_KEY
      database_url: os.environ/DATABASE_URL

    api_base is the endpoint's url field plus /v1. With front doors on (plan.gateways.enabled), the url is opodcp-ep-<name>-front: that Service reaches the leader and every door. With endpoints.tls.embedded=true, use https:// and give the gateway the endpoint's certificate (item tls.crt of its auth Secret) as its trust store.

  3. Make the gateway the only way in

    Turn on Require keys for the endpoint so a caller without the key gets 401. As defence in depth, admit only the gateway to port 8080 with a NetworkPolicy. It must also admit:

    • the endpoint's own pods (workers join and heartbeat on 8080);
    • the pods labelled app.kubernetes.io/name: opodcp: the eval Job and the batch runner, which call /v1 on the leader;
    • the API server. Every call the control plane makes to a leader rides the API server's Service proxy, so it arrives from the API server, not from the control plane's pod. Without this rule every rollout's probe step fails.

    Leave the probe port 8081 open.

    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata: { name: only-the-gateway, namespace: opodcp }
    spec:
      podSelector: { matchLabels: { opod.io/front: chat-small } }
      policyTypes: [Ingress]
      ingress:
        - from: [{ namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: litellm } },
                   podSelector: { matchLabels: { app: litellm } } }]
          ports: [{ port: 8080 }]
        - from: [{ podSelector: { matchLabels: { opod.io/endpoint: chat-small } } }]
        - from: [{ podSelector: { matchLabels: { app.kubernetes.io/name: opodcp } } }]
        - from: [{ ipBlock: { cidr: 192.0.2.10/32 } }]     # the API server: a control-plane node's address, or on flannel the first two addresses of its pod range
        - ports: [{ port: 8081 }]

    Policies add up. With networkPolicy.enabled=true and leader isolation off, the chart's <release>-endpoints policy admits every source on 8080 to our pods, so this policy then closes nothing. Turn on leader isolation, or keep networkPolicy.enabled off and rely on this policy alone.

    The chart's networkPolicy.leaderIsolation is not a gateway-only policy. It closes the leader's port, not the doors, and only on an endpoint with front doors (plan.gateways.enabled); an endpoint without doors gets a policy that stays open. It admits the endpoint's own pods, the API server, KEDA when autoscaler.adapter=keda, the cell door's pods when the endpoint has a door alias, and the peers you list in networkPolicy.leaderIsolation.from. Nothing else. So:

    • a gateway that calls the endpoint's url (opodcp-ep-<name>-front) reaches the doors, which this policy does not close;
    • a gateway that calls the leader's own Service (opodcp-ep-<name>) must be listed in from, or it is cut off.

    See Network and TLS → Leader isolation. An endpoint on the cell door is reachable through the door with any of its keys: put the gateway in front of the door too, or keep a gated endpoint off it.

Rules that keep the numbers right:

  • Count streamed tokens with stream_options.include_usage, or a streamed answer counts as zero.
  • Pass the end user in OpenAI's user field; opod's usage row keeps only which endpoint key called.
  • A gateway retry is a new request to opod.
  • Reconcile the gateway's tokens per model per day with opod's GPU-hours export (GET /api/v1/usage/gpu-daily, JSON or CSV; it is new in 0.3.0). Fewer tokens at the gateway than opod served means traffic went around it.
  • Pin the gateway's image by digest.

For cost per team, join the gateway's tokens per team with opod's GPU-hours per endpoint. See Usage → Cost per team.

Guardrails, prompt logs, key pause and IdP groups are LiteLLM settings too; the LiteLLM guide has one example of each.

Traces. With LiteLLM's forward_traceparent_to_llm_provider: true, the caller's traceparent reaches the leader, which continues the trace into the engine: one trace from caller to engine.

Gateway API InferencePool

InferencePool membership is new in 0.3.0. If your cluster runs a Gateway API inference gateway, the control plane can make an endpoint's leader a member of an InferencePool. The gateway picks a leader; the leader still picks the worker.

helm upgrade opodcp … --reset-then-reuse-values --set inferencePool.enabled=true
exposure: { inferencePool: chat }   # in the plan

In 0.3.0, the create form has a Gateway API InferencePool field, and opodcp endpoint expose --inference-pool chat chat-small joins a running endpoint to the pool (- leaves it).

A pool name is lowercase letters, digits and -, at most 40 characters, starting and ending with a letter or digit; anything else is refused 400. Every endpoint that names one pool is a member. The control plane renders the pool, one endpoint picker (llm-d's, engineImages.epp) and one HTTPRoute on your Gateway. The leader keeps auth, admission and usage for its own requests. Members of one pool serve one model (E-POOL-MODEL-MISMATCH). A remote endpoint cannot join a pool: its leader is a proxy to another API. The InferencePool v1 CRDs come with your gateway; the chart never installs them (E-INFERENCEPOOL-CRD when absent). With inferencePool.enabled on, the control plane may create the picker's ServiceAccount and Role in its namespace.

PortSchemeCarries
8080the leader's own (HTTPS with embedded TLS)/v1/* for direct clients
8081always plain HTTP/healthz, /readyz, /loadz, /metrics, which the picker scrapes
8082always plain HTTP, only on a pool memberthe whole API, for the gateway's proxies

For example, a gateway whose proxies run in namespace gateways and carry the label app: my-gateway-proxy:

helm upgrade opodcp … --reset-then-reuse-values --set inferencePool.enabled=true \
  --set inferencePool.gatewayPods.namespace=gateways --set inferencePool.gatewayPods.podLabels.app=my-gateway-proxy

The 8082 hop is clear text inside the cluster, so the control plane renders a NetworkPolicy per pool (opodcp-pool-<name>) that admits only your Gateway's proxies to it. inferencePool.gatewayPods.namespace (default envoy-gateway-system) and .podLabels (default empty) name them. The defaults fit Envoy Gateway: with podLabels empty, the proxies are selected by the gateway.envoyproxy.io/owning-gateway-name and -namespace labels of the Gateway the routes attach to. For another gateway, set both to where its proxies run and the labels they carry; a namespace alone is never sent.

The leader publishes vLLM-named aliases the picker reads, beside its own metrics: vllm:num_requests_waiting (the summed queue), vllm:num_requests_running, vllm:kv_cache_usage_perc (mean KV use, 0–1).

Vertex AI custom-container routes

The Vertex AI routes are new in 0.3.0. plan.exposure.vertex: true makes the leader answer POST /v1/vertex:predict and GET /v1/vertex/health on the endpoint's own URL. predict takes Vertex's {instances, parameters} and answers {predictions}, serving each instance as a chat request; a chat body is passed through.

These routes take no key

They assume Vertex AI's IAM checked the caller. Anyone who reaches the leader can call the model through them. They are refused on an endpoint that requires keys (E-VERTEX-KEYS), and accepted with the advisory vertex-keyless on one that does not.

Also refused: E-VERTEX-PROTOCOL (not a chat endpoint), E-VERTEX-DOORS (front doors do not serve the routes), E-VERTEX-UNSUPPORTED (the running leader lacks them). This is partly proven: the control plane's render is proven, and Vertex AI's own front end has not yet called a leader.

Last updated · Source: content/docs/control-plane-endpoints/gateways.mdx · View as Markdown