NAME
IO::K8s::Role::MiddlewareTCPBuilder - Role for building Traefik TCP middleware configuration
VERSION
version 1.108
SYNOPSIS
package My::TraefikMiddlewareTCP;
use IO::K8s::APIObject
api_version => 'traefik.io/v1alpha1',
resource_plural => 'middlewaretcps';
with 'IO::K8s::Role::MiddlewareTCPBuilder';
package main;
my $k8s = IO::K8s->new(with => ['IO::K8s::Traefik']);
my $mw = $k8s->new_object('MiddlewareTCP',
metadata => { name => 'db-guard', namespace => 'default' },
);
$mw->in_flight_conn(10)
->ip_allow_list('10.0.0.0/8');
DESCRIPTION
This role provides the fluent builders for Traefik's TCP middleware. Each method writes the corresponding block under the spec key Traefik's MiddlewareTCP CRD expects, so the chain mirrors what a user would compose in YAML.
A TCP middleware is a much smaller surface than an HTTP one: Traefik's MiddlewareTCPSpec carries only inFlightConn, ipAllowList and the deprecated ipWhiteList, and none of the HTTP middlewares (rate limiting, basic auth, prefix stripping, scheme redirection, header injection) are honoured on a TCP router. That is why this role is separate from IO::K8s::Role::MiddlewareBuilder instead of extending it -- calling an HTTP builder on a MiddlewareTCP fails as an unknown method rather than silently producing a manifest Traefik ignores.
Each setter replaces its target block each time it is called; there is no accumulating setter in this role.
Apply this role to any class whose spec field is the Traefik MiddlewareTCP wire schema. The bundled Traefik CRD IO::K8s::Traefik::V1alpha1::MiddlewareTCP is the obvious target, but the role composes on custom CRD classes too.
in_flight_conn
$mw->in_flight_conn($amount);
Configures the Traefik inFlightConn middleware, which caps how many simultaneous TCP connections the middleware lets through -- once $amount connections are open the next one is closed rather than queued. Writes the spec.inFlightConn = { amount => $amount } block, replacing any prior one. Passing no amount writes an empty {} rather than a populated block. Returns $self for chaining.
$mw->in_flight_conn(10);
ip_allow_list
$mw->ip_allow_list(@ranges);
Configures the Traefik ipAllowList middleware to accept connections only from the given client IPs, each written either as a plain address or in CIDR notation. The ranges are written as a single { sourceRange => [...] } block, replacing any prior ipAllowList block. Pass an empty list to emit an empty ipAllowList.sourceRange array. Returns $self for chaining.
$mw->ip_allow_list('10.0.0.0/8', '192.168.1.7');
ip_white_list
$mw->ip_white_list(@ranges);
Same shape as ip_allow_list, but writing the ipWhiteList block. Upstream Traefik deprecated ipWhiteList in favour of ipAllowList; this method exists so a manifest that still carries the old field can be built and round-tripped, not as the way to express new configuration -- use ip_allow_list for that. Returns $self for chaining.
SEE ALSO
IO::K8s::Traefik, IO::K8s::Role::MiddlewareBuilder, IO::K8s::Role::SpecBuilder, IO::K8s::APIObject
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/pplu/io-k8s-p5/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHORS
Torsten Raudssus <getty@cpan.org>
Jose Luis Martinez Torres <jlmartin@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018-2026 by Jose Luis Martinez Torres <jlmartin@cpan.org>.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004