Documentation
¶
Overview ¶
Package published chooses the Published ports (ADR 0012) a Containerized Instance serves host clients on: the ports its own container publishes to the host. GKE LoadBalancer Services (on a VM runtime) and forwarding rules (on any runtime) share them, and whoever binds a port first wins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenShared ¶
ListenShared listens on addr like net.Listen, but lets a listener on the wildcard address and one on a specific address share a port (Linux refuses that otherwise), when both are opened with it. A forwarding rule's loopback listener and a Published port listener on the rule's own port need that in a Containerized Instance. Sharing also lets two wildcard listeners share a port, so callers must keep track of the ports they hold themselves; a plain listener (another process, or a GKE LoadBalancer Service) still refuses it.
Types ¶
type Binding ¶ added in v0.8.0
type Binding struct {
Listener net.Listener
// Port is the container port, and Host its host address.
Port int
Host string
}
Binding is a listener on a Published port.
type OwnPortPolicy ¶ added in v0.8.0
type OwnPortPolicy int
OwnPortPolicy says when an Own port comes first among its candidates.
const ( // SameHostPort: when the container publishes it at the same host // port (GKE LoadBalancer Services). SameHostPort OwnPortPolicy = iota // AnyHostPort: when the container publishes it at any host port // (forwarding rules). AnyHostPort )
type Ports ¶ added in v0.8.0
type Ports struct {
// contains filtered or unexported fields
}
Ports is what a Containerized Instance knows of its container's Published ports: the ports it publishes, and --port-range.
func NewPorts ¶ added in v0.8.0
NewPorts returns the Ports of a container that publishes published (runtime.Client.SelfPorts) under the Instance's config c.
func (*Ports) Bind ¶ added in v0.8.0
func (p *Ports) Bind(cands []int, listen func(port int) (net.Listener, error), skip func(port int) bool) *Binding
Bind listens on the first of cands that skip (when set) does not report and listen binds, and returns that binding; nil when none binds.
func (*Ports) Candidates ¶ added in v0.8.0
func (p *Ports) Candidates(name string, own int, policy OwnPortPolicy) []int
Candidates lists the container ports to try serving port own on, in order: own itself when the container publishes it as policy says, then the published ports of --port-range, from a hash of name onwards, so that name keeps its port across syncs and restarts where it can.