Documentation
¶
Index ¶
- Constants
- Variables
- func Complement(f func(report.Node) bool) func(report.Node) bool
- func ImageNameWithoutVersion(name string) string
- func IsRunning(n report.Node) bool
- func IsSystem(n report.Node) bool
- func LocalNetworks(r report.Report) report.Networks
- func MakePseudoNodeID(parts ...string) string
- func MapContainer2ContainerImage(n report.Node, _ report.Networks) report.Nodes
- func MapContainer2Hostname(n report.Node, _ report.Networks) report.Nodes
- func MapContainer2IP(m report.Node, _ report.Networks) report.Nodes
- func MapContainer2Pod(n report.Node, _ report.Networks) report.Nodes
- func MapEndpoint2Host(n report.Node, local report.Networks) report.Nodes
- func MapEndpoint2IP(m report.Node, local report.Networks) report.Nodes
- func MapEndpoint2Process(n report.Node, local report.Networks) report.Nodes
- func MapEndpoint2Pseudo(n report.Node, local report.Networks) report.Nodes
- func MapIP2Container(n report.Node, _ report.Networks) report.Nodes
- func MapPod2Service(pod report.Node, _ report.Networks) report.Nodes
- func MapProcess2Container(n report.Node, _ report.Networks) report.Nodes
- func MapProcess2Name(n report.Node, _ report.Networks) report.Nodes
- func MapX2Host(n report.Node, _ report.Networks) report.Nodes
- func NewDerivedNode(id string, node report.Node) report.Node
- func NewDerivedPseudoNode(id string, node report.Node) report.Node
- func ResetCache()
- type CustomRenderer
- type Filter
- type Map
- type MapFunc
- type Reduce
- type Renderer
- func ColorConnected(r Renderer) Renderer
- func FilterApplication(r Renderer) Renderer
- func FilterNonProcspied(r Renderer) Renderer
- func FilterNoop(in Renderer) Renderer
- func FilterPseudo(r Renderer) Renderer
- func FilterRunning(r Renderer) Renderer
- func FilterStopped(r Renderer) Renderer
- func FilterSystem(r Renderer) Renderer
- func FilterUnconnected(r Renderer) Renderer
- func MakeFilter(f func(report.Node) bool, r Renderer) Renderer
- func MakeMap(f MapFunc, r Renderer) Renderer
- func MakeReduce(renderers ...Renderer) Renderer
- func MakeSilentFilter(f func(report.Node) bool, r Renderer) Renderer
- func Memoise(r Renderer) Renderer
- func SilentFilterUnconnected(r Renderer) Renderer
- type Stats
- type TopologySelector
Constants ¶
const ( UncontainedID = "uncontained" UncontainedMajor = "Uncontained" TheInternetID = "theinternet" IncomingInternetID = "in-" + TheInternetID OutgoingInternetID = "out-" + TheInternetID InboundMajor = "The Internet" OutboundMajor = "The Internet" InboundMinor = "Inbound connections" OutboundMinor = "Outbound connections" // Topology for pseudo-nodes and IPs so we can differentiate them at the end Pseudo = "pseudo" IP = "IP" )
Constants are used in the tests.
const IsConnected = "is_connected"
IsConnected is the key added to Node.Metadata by ColorConnected to indicate a node has an edge pointing to it or from it
Variables ¶
var ( SelectEndpoint = TopologySelector(report.Endpoint) SelectProcess = TopologySelector(report.Process) SelectContainer = TopologySelector(report.Container) SelectContainerImage = TopologySelector(report.ContainerImage) SelectHost = TopologySelector(report.Host) SelectPod = TopologySelector(report.Pod) SelectService = TopologySelector(report.Service) )
The topology selectors implement a Renderer which fetch the nodes from the various report topologies.
var ContainerHostnameRenderer = MakeMap( MapContainer2Hostname, ContainerRenderer, )
ContainerHostnameRenderer is a Renderer which produces a renderable container by hostname graph..
var ContainerImageRenderer = MakeReduce( MakeMap( MapContainer2ContainerImage, ContainerRenderer, ), SelectContainerImage, )
ContainerImageRenderer is a Renderer which produces a renderable container image graph by merging the container graph and the container image topology.
var ContainerRenderer = MakeReduce( MakeSilentFilter( func(n report.Node) bool { _, isConnected := n.Latest.Lookup(IsConnected) return n.Topology != Pseudo || isConnected }, MakeMap( MapProcess2Container, ColorConnected(ProcessRenderer), ), ), SilentFilterUnconnected(MakeMap( MapIP2Container, MakeReduce( MakeMap( MapContainer2IP, SelectContainer, ), MakeMap( MapEndpoint2IP, SelectEndpoint, ), ), )), SelectContainer, )
ContainerRenderer is a Renderer which produces a renderable container graph by merging the process graph and the container topology. NB We only want processes in container _or_ processes with network connections but we need to be careful to ensure we only include each edge once, by only including the ProcessRenderer once.
var ContainerWithHostIPsRenderer = containerWithHostIPsRenderer{ContainerRenderer}
ContainerWithHostIPsRenderer is a Renderer which produces a container graph enriched with host IPs on containers where NetworkMode is Host
var ContainerWithImageNameRenderer = containerWithImageNameRenderer{ContainerWithHostIPsRenderer}
ContainerWithImageNameRenderer is a Renderer which produces a container graph where the ranks are the image names, not their IDs
var EndpointRenderer = FilterNonProcspied(SelectEndpoint)
EndpointRenderer is a Renderer which produces a renderable endpoint graph.
var HostRenderer = MakeReduce( MakeMap( MapEndpoint2Host, EndpointRenderer, ), MakeMap( MapX2Host, ColorConnected(ProcessRenderer), ), MakeMap( MapX2Host, ContainerRenderer, ), MakeMap( MapX2Host, ContainerImageRenderer, ), SelectHost, )
HostRenderer is a Renderer which produces a renderable host graph from the host topology.
var PodRenderer = MakeReduce( MakeSilentFilter( func(n report.Node) bool { _, isConnected := n.Latest.Lookup(IsConnected) return n.Topology != Pseudo || isConnected }, ColorConnected(MakeMap( MapContainer2Pod, ContainerRenderer, )), ), SelectPod, )
PodRenderer is a Renderer which produces a renderable kubernetes graph by merging the container graph and the pods topology.
var PodServiceRenderer = MakeReduce( MakeMap( MapPod2Service, PodRenderer, ), SelectService, )
PodServiceRenderer is a Renderer which produces a renderable kubernetes services graph by merging the pods graph and the services topology.
var ProcessNameRenderer = MakeMap( MapProcess2Name, ProcessRenderer, )
ProcessNameRenderer is a Renderer which produces a renderable process name graph by munging the progess graph.
var ProcessRenderer = MakeReduce( MakeMap( MapEndpoint2Process, EndpointRenderer, ), SelectProcess, )
ProcessRenderer is a Renderer which produces a renderable process graph by merging the endpoint graph and the process topology.
var ProcessWithContainerNameRenderer = processWithContainerNameRenderer{ProcessRenderer}
ProcessWithContainerNameRenderer is a Renderer which produces a process graph enriched with container names where appropriate
Functions ¶
func Complement ¶ added in v0.14.0
Complement takes a FilterFunc f and returns a FilterFunc that has the same effects, if any, and returns the opposite truth value.
func ImageNameWithoutVersion ¶ added in v0.12.0
ImageNameWithoutVersion splits the image name apart, returning the name without the version, if possible
func IsRunning ¶ added in v0.14.0
IsRunning checks if the node is a running docker container
func IsSystem ¶ added in v0.14.0
IsSystem checks if the node is a "system" node
func LocalNetworks ¶
LocalNetworks returns a superset of the networks (think: CIDRs) that are "local" from the perspective of each host represented in the report. It's used to determine which nodes in the report are "remote", i.e. outside of our infrastructure.
func MakePseudoNodeID ¶
MakePseudoNodeID joins the parts of an id into the id of a pseudonode
func MapContainer2ContainerImage ¶
MapContainer2ContainerImage maps container Nodes to container image Nodes.
If this function is given a node without a docker_image_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func MapContainer2Hostname ¶
MapContainer2Hostname maps container Nodes to 'hostname' renderabled nodes..
func MapContainer2IP ¶
MapContainer2IP maps container nodes to their IP addresses (outputs multiple nodes). This allows container to be joined directly with the endpoint topology.
func MapContainer2Pod ¶
MapContainer2Pod maps container Nodes to pod Nodes.
If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Unmanaged" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func MapEndpoint2Host ¶ added in v0.14.0
MapEndpoint2Host takes nodes from the endpoint topology and produces host nodes or pseudo nodes.
func MapEndpoint2IP ¶
MapEndpoint2IP maps endpoint nodes to their IP address, for joining with container nodes. We drop endpoint nodes with pids, as they will be joined to containers through the process topology, and we don't want to double count edges.
func MapEndpoint2Process ¶
MapEndpoint2Process maps endpoint Nodes to process Nodes.
If this function is given a pseudo node, then it will just return it; Pseudo nodes will never have pids in them, and therefore will never be able to be turned into a Process node.
Otherwise, this function will produce a node with the correct ID format for a process, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a process graph to get that info.
func MapEndpoint2Pseudo ¶ added in v0.14.0
MapEndpoint2Pseudo makes internet of host pesudo nodes from a endpoint node.
func MapIP2Container ¶
MapIP2Container maps IP nodes produced from MapContainer2IP back to container nodes. If there is more than one container with a given IP, it is dropped.
func MapPod2Service ¶
MapPod2Service maps pod Nodes to service Nodes.
If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a pod graph to get that info.
func MapProcess2Container ¶
MapProcess2Container maps process Nodes to container Nodes.
If this function is given a node without a docker_container_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func MapProcess2Name ¶
MapProcess2Name maps process Nodes to Nodes for each process name.
This mapper is unlike the other foo2bar mappers as the intention is not to join the information with another topology.
func MapX2Host ¶ added in v0.12.0
MapX2Host maps any Nodes to host Nodes.
If this function is given a node without a hostname (including other pseudo nodes), it will drop the node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func NewDerivedNode ¶
NewDerivedNode makes a node based on node, but with a new ID
func NewDerivedPseudoNode ¶ added in v0.14.0
NewDerivedPseudoNode makes a new pseudo node with the node as a child
Types ¶
type CustomRenderer ¶
CustomRenderer allow for mapping functions that received the entire topology in one call - useful for functions that need to consider the entire graph. We should minimise the use of this renderer type, as it is very inflexible.
type Filter ¶
type Filter struct { Renderer FilterFunc func(report.Node) bool Silent bool // true means we don't report stats for how many are filtered }
Filter removes nodes from a view based on a predicate.
func (*Filter) Render ¶
Render implements Renderer
type Map ¶
Map is a Renderer which produces a set of Nodes from the set of Nodes produced by another Renderer.
func (*Map) Render ¶
Render transforms a set of Nodes produces by another Renderer. using a map function
type MapFunc ¶
MapFunc is anything which can take an arbitrary Node and return a set of other Nodes.
If the output is empty, the node shall be omitted from the rendered topology.
type Reduce ¶
type Reduce []Renderer
Reduce renderer is a Renderer which merges together the output of several other renderers.
func (*Reduce) Render ¶
Render produces a set of Nodes given a Report.
type Renderer ¶
Renderer is something that can render a report to a set of Nodes.
func ColorConnected ¶
ColorConnected colors nodes with the IsConnected key if they have edges to or from them. Edges to/from yourself are not counted here (see #656).
func FilterApplication ¶ added in v0.14.0
FilterApplication is a Renderer which filters out system nodes.
func FilterNonProcspied ¶ added in v0.14.0
FilterNonProcspied removes endpoints which were not found in procspy.
func FilterPseudo ¶ added in v0.12.0
FilterPseudo produces a renderer that removes pseudo nodes from the given renderer
func FilterRunning ¶ added in v0.14.0
FilterRunning filters out running containers.
func FilterStopped ¶ added in v0.10.0
FilterStopped filters out stopped containers.
func FilterSystem ¶
FilterSystem is a Renderer which filters out system nodes.
func FilterUnconnected ¶
FilterUnconnected produces a renderer that filters unconnected nodes from the given renderer
func MakeFilter ¶ added in v0.12.0
MakeFilter makes a new Filter.
func MakeMap ¶ added in v0.12.0
MakeMap makes a new Map
func MakeReduce ¶
MakeReduce is the only sane way to produce a Reduce Renderer.
func MakeSilentFilter ¶ added in v0.14.0
MakeSilentFilter makes a new Filter which does not report how many nodes it filters in Stats.
func Memoise ¶ added in v0.12.0
Memoise wraps the renderer in a loving embrace of caching
type TopologySelector ¶
type TopologySelector string
TopologySelector selects a single topology from a report. NB it is also a Renderer!
func (TopologySelector) Render ¶
func (t TopologySelector) Render(r report.Report) report.Nodes
Render implements Renderer
func (TopologySelector) Stats ¶
func (t TopologySelector) Stats(r report.Report) Stats
Stats implements Renderer
Source Files
¶
- filters.go
- id.go
- mapping.go
- memoise.go
- render.go
- selectors.go
- theinternet.go
- topologies.go