Skip to content

feat: Allow restricting callers to the API via NetworkPolicy - #393

Open
Rylon wants to merge 1 commit into
LibreChat-AI:mainfrom
Rylon:feat/api-ingress-from
Open

Rylon wants to merge 1 commit into
LibreChat-AI:mainfrom
Rylon:feat/api-ingress-from

Conversation

@Rylon

@Rylon Rylon commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

The API's NetworkPolicy allows ingress to the API port from any source, so any pod in the cluster can reach it. Callers still need valid credentials, but there's no way to narrow access only to the application that uses it, as the chart already does for every other component.

This adds an optional networkPolicy.api.ingressFrom, following the existing metrics.sandboxRunner.ingressFrom.

If empty (the default) we preserve the current behaviour, allowing access from any source. When set, we add the entries to the from section of the API's ingress rule, for example:

networkPolicy:
  api:
    ingressFrom:
      - namespaceSelector:
          matchLabels:
            kubernetes.io/metadata.name: librechat
        podSelector:
          matchLabels:
            app.kubernetes.io/name: librechat

One thing to watch out for when using this: the ingress controller (with ingress.enabled) and Prometheus (with metrics.enabled) will both need to be added to ingressFrom when they are enabled, because they reach the API on the same port.

Testing

  • helm template with values-local.yaml renders identically before and after this change.
  • With the values above, the API policy's ingress rule gets the expected from block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant