Documentation
¶
Overview ¶
Package egressproxy is the egress proxy of the run-controller's kubernetes network mode (v4 D6, plan PR5): a CONNECT-only forward proxy that knows a client by its source pod IP and lets it reach only the host:port pairs of its pod's maku.ogenki.io/egress annotation, which the run-controller alone writes (the run-pod policy holds it).
Index ¶
Constants ¶
const ( DecisionAllow = "allow" DecisionRefuse = "refuse" DecisionError = "error" )
The decisions of Proxy.Count, the bounded label of maku_egress_proxy_connections_total.
const DefaultIdleTimeout = 5 * time.Minute
DefaultIdleTimeout closes a tunnel that moved no byte either way for this long.
const EgressAnnotation = runctl.EgressAnnotation
EgressAnnotation is the run pod's allow-list.
Variables ¶
var ErrRefused = errors.New("refused")
ErrRefused is a destination the proxy never dials: a name that resolves to a non-public or denied address.
Functions ¶
Types ¶
type Dialer ¶
type Dialer struct {
Resolver Resolver
Deny []*net.IPNet // beyond the non-public ranges: the chart's privateCIDRs
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
Timeout time.Duration
}
Dialer resolves a name itself and dials the address it vetted, so a second lookup cannot substitute another (DNS rebinding).
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index maps a pod IP to its run, from the pods a watch feeds it.
func (*Index) Lookup ¶
Lookup is ip's entry. It has one only when exactly one unfinished pod holds ip, and that pod is the run-controller's, not terminating, and annotated. Pending counts with Running: a pod with an IP is already running containers, and the watch can trail its phase change. A terminating pod still holds its IP, so it makes the IP ambiguous instead of freeing it.
type Proxy ¶
type Proxy struct {
Index Lookuper
Dial func(ctx context.Context, hostport string) (net.Conn, error)
IdleTimeout time.Duration
Log *slog.Logger
Count func(decision string) // optional
Bytes func(n int64) // optional
// MaxTunnels caps the open tunnels in all, MaxTunnelsPerClient those of one source IP; 0 is no
// cap. A CONNECT over either is refused 429 before anything is dialled.
MaxTunnels, MaxTunnelsPerClient int
// contains filtered or unexported fields
}
Proxy serves CONNECT only. A client gets a tunnel to host:port when its source IP maps to a run whose allow-list holds exactly that pair, and the host is a name, never an IP literal. Each decision logs `allow run=<id> <host:port>` or `refuse run=<id|-> <host:port>`, as the harness's test proxy does.