Page MenuHomePhabricator

Allow limiting exposed port access
Open, MediumPublicFeature

Description

Feature summary (what you would like to be able to do and where):

Currently if a port is exposed from a job, then the service/container is accessible to all tools (via <name>.tool-<tool name>.svc.tools.local).

While this can be useful to allow cross tool usage, when running 'backend' services scoped to a specific tool it potentially opens up unexpected usage.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

ClueBot NG runs a number of services, which the primary process uses, 2 examples of this are core (the scoring engine) and irc-relay (UDP -> Libera).

Both of these services are only intended to be consumed by bot, which is the production instance of ClueBot NG.

Applying a network policy to the namespace along the lines of

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: access-core
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: core
  ingress:
  - from:
    # Bot uses Core for scoring
    - podSelector:
        matchLabels:
          app.kubernetes.io/name: bot

Does appear to limit access, however this is once again going outside of the "supported" usage of toolforge.

Note: I do also use cross tool access, for example cluebotng-review using the IRC Relay; this could however be replaced with a local instance if a only allow from same namespace or everywhere policy was desired.

Benefits (why should this be implemented?):

  • Security; outside of webservice type tools I was not expecting services to be exposed 'publicly'
  • Limit complexity; having to implement authentication mechanisms in (especially existing) backend services would introduce more overhead for maintainers and bring in management of secrets
  • This is a well supported pattern in k8s, only the wrapper tooling needs to add support (as it does for Service/Deployment objects)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Note: I do also use cross tool access, for example cluebotng-review using the IRC Relay; this could however be replaced with a local instance if a only allow from same namespace or everywhere policy was desired.

Wikibugs uses cross-namespace access to the http://gitlab-webhooks.tool-gitlab-webhooks.svc.tools.local:8000/sse/ service endpoint in the gitlab-webhooks tool. It would be difficult to replace this in practice. The same service is exposed through the Toolforge front proxy, but past experience showed noisy neighbor problems for the connection between the tools when passing through the nginx ingress service. T364490: Wikibugs' gitlab connector stops working without a strong sign of why

fnegri triaged this task as Medium priority.Aug 20 2025, 2:21 PM

Currently handling this in my tools as part of the deployment (network policy / ingress being the only 'unsupported' objects managed (including cross-tool access), everything else is components/jobs-api driven), works just fine but is 'unsupported' so this is 'long term nice to have' for me.