Documentation
¶
Overview ¶
Package privnet models VPC-like private networks and security-group style allow rules between apps, and answers which app pairs can talk.
Index ¶
- Constants
- func AppOwners(prefix string, apps []store.App, containers []docker.ContainerState) map[string]string
- func Load(ctx context.Context, src Source) ([]Network, []Rule, []store.App, error)
- func MeshHidden(nets []Network, rules []Rule) map[string]bool
- func NetworkDockerName(prefix, id string) string
- func PairKey(a, b string) [2]string
- func RuleDockerName(prefix, id string) string
- func SharedNetworks(prefix string, apps []store.App, containers []docker.ContainerState) map[[2]string]bool
- type App
- type Controller
- type Edge
- type Link
- type Network
- type Rule
- type Runtime
- type Source
Constants ¶
const ( ViaNetwork = "network" ViaRule = "rule" ViaNone = "" )
Edge reasons.
const MaxBlockedEdges = 200
MaxBlockedEdges caps how many blocked pairs Evaluate returns.
Variables ¶
This section is empty.
Functions ¶
func AppOwners ¶
func AppOwners(prefix string, apps []store.App, containers []docker.ContainerState) map[string]string
AppOwners maps container ID to app ID using the per-app network each container is attached to.
func MeshHidden ¶
MeshHidden returns app IDs that must not be published to mesh DNS: members of a default-deny network with no allow rule that names them.
func NetworkDockerName ¶
NetworkDockerName is the Docker network backing a private network.
func RuleDockerName ¶
RuleDockerName is the Docker network backing an allow rule.
func SharedNetworks ¶
func SharedNetworks(prefix string, apps []store.App, containers []docker.ContainerState) map[[2]string]bool
SharedNetworks returns, per unordered app pair, whether some container of each app is attached to one common Docker network besides per-app ones.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller keeps Docker networks in line with private networks and rules.
func NewController ¶
func NewController(src Source, rt Runtime, prefix, instanceID string) *Controller
NewController builds the enforcer. prefix must match the application controller's network prefix so per-app networks resolve to app IDs.
func (*Controller) ForNode ¶
func (c *Controller) ForNode(nodeID string) *Controller
ForNode names the controller for one remote node's runtime.
type Edge ¶
type Edge struct {
A string
B string
Allowed bool
Via string
ViaName string
RuleID string
CrossNode bool
}
Edge is the verdict for one unordered app pair (A sorts before B).
type Runtime ¶
type Runtime interface {
EnsureNetwork(ctx context.Context, name string) (string, error)
RemoveNetwork(ctx context.Context, name string) error
ListNetworksByPrefix(ctx context.Context, prefix string) ([]docker.NetworkInfo, error)
ListByPrefix(ctx context.Context, prefix string) ([]docker.ContainerState, error)
NetworkConnect(ctx context.Context, network, containerID string) error
NetworkDisconnect(ctx context.Context, network, containerID string, force bool) error
}
Runtime is the Docker surface the controller needs.
type Source ¶
type Source interface {
ListApps(ctx context.Context) ([]store.App, error)
ListPrivateNetworks(ctx context.Context) ([]store.PrivateNetwork, error)
ListPrivateNetworkRules(ctx context.Context) ([]store.PrivateNetworkRule, error)
}
Source is the store surface the controller and the API both read.