Documentation
¶
Overview ¶
Package forward manages port-forwards into the cluster.
The daily loop ends with "now let me hit the service", so a tool that stops short of that sends the developer back to a terminal for the last step. This closes it.
Two rules shape the implementation. Every listener binds loopback only: forwarding a production database onto the office network would be a hole kubeside opened. And nothing survives the process: a tunnel into production left behind by a crashed UI is exactly what this tool must not leave running.
Index ¶
Constants ¶
const ( StateReady = "ready" StateStopped = "stopped" StateFailed = "failed" )
Forward states.
const DefaultStartTimeout = 15 * time.Second
DefaultStartTimeout bounds how long a caller waits for a tunnel to come up.
const LocalAddress = "127.0.0.1"
LocalAddress is where forwards bind. It is a constant rather than an option, for the same reason the web server's bind address is.
Variables ¶
This section is empty.
Functions ¶
func ValidTarget ¶
ValidTarget rejects a namespace or pod that cannot be safely encoded as one path segment.
Every other cluster call in this product goes through client-go's typed builders, which run this same check before a request is built. The tunnel is the one path assembled by hand, because SPDY needs the URL rather than a request object, so the check has to be made explicitly here rather than inherited.
Types ¶
type Forward ¶
type Forward struct {
ID string `json:"id"`
Context string `json:"context"`
Namespace string `json:"namespace"`
Workload string `json:"workload"`
Pod string `json:"pod"`
RemotePort int `json:"remotePort"`
LocalPort int `json:"localPort"`
Address string `json:"address"`
State string `json:"state"`
Environment string `json:"environment,omitempty"`
Risk string `json:"risk,omitempty"`
StartedAt string `json:"startedAt"`
Error string `json:"error,omitempty"`
}
Forward is one running tunnel.
type KubeTunnel ¶
type KubeTunnel struct {
// RESTConfig returns the config for one context. Credential plugins run
// here, the same as everywhere else.
RESTConfig func(contextName string) (*rest.Config, error)
}
KubeTunnel is the production tunnel: SPDY to the apiserver, exactly the mechanism kubectl port-forward uses.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns every live forward.
type Target ¶
type Target struct {
Context string
Namespace string
Workload string
Pod string
// RemotePort is the container port. LocalPort is a request, and zero means
// the operating system picks a free one.
RemotePort int
LocalPort int
// Environment and Risk travel with the forward so the UI can colour it. A
// tunnel into production is a different thing from one into qa.
Environment string
Risk string
}
Target is what to forward to.