Skip to content

Commit

Permalink
dot graphs with exposure edges dashed and with different colors
Browse files Browse the repository at this point in the history
  • Loading branch information
shireenf-ibm committed Jun 9, 2024
1 parent d22e48a commit 51f3239
Show file tree
Hide file tree
Showing 103 changed files with 310 additions and 304 deletions.
34 changes: 20 additions & 14 deletions pkg/netpol/connlist/conns_formatter_dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@ import (
)

const (
ipColor = "red2"
nonIPPeerColor = "blue"
representativeObjColor = "red2"
entireClusterShape = " shape=diamond"
peerLineClosing = "]"
allPeersLbl = "all pods"
allNamespacesLbl = "all namespaces"
edgeWeightLabel = " weight="
ingWeight = "1"
egWeight = "0.5"
ipColor = "red2"
nonIPPeerColor = "blue"
representativeObjColor = "red2"
entireClusterShape = " shape=diamond"
peerLineClosing = "]"
allPeersLbl = "all pods"
allNamespacesLbl = "all namespaces"
edgeWeightLabel = " weight="
ingWeight = "1"
egWeight = "0.5"
ingressExposureEdgeColor = "darkorange2"
egressExposureEdgeColor = "darkorange4"
connlistEdgeColor = "gold2"
exposureEdgeStyle = " style=dashed"
)

var edgeLineFormat = fmt.Sprintf("\t%%q -> %%q [label=%%q color=\"gold2\" fontcolor=\"darkgreen\"%%s]")
var edgeLineFormat = fmt.Sprintf("\t%%q -> %%q [label=%%q color=%%q fontcolor=\"darkgreen\"%%s]")
var peerLineFormatPrefix = fmt.Sprintf("\t%%q [label=%%q color=%%q fontcolor=%%q")

// formatDOT: implements the connsFormatter interface for dot output format
Expand All @@ -38,7 +42,7 @@ type formatDOT struct {
// getEdgeLine formats an edge line from a Peer2PeerConnection struct , to be used for dot graph
func getEdgeLine(c Peer2PeerConnection) string {
connStr := common.ConnStrFromConnProperties(c.AllProtocolsAndPorts(), c.ProtocolsAndPorts())
return fmt.Sprintf(edgeLineFormat, c.Src().String(), c.Dst().String(), connStr, "")
return fmt.Sprintf(edgeLineFormat, c.Src().String(), c.Dst().String(), connStr, connlistEdgeColor, "")
}

// peerNameAndColorByType returns the peer label and color to be represented in the graph, and whether the peer is
Expand Down Expand Up @@ -182,9 +186,11 @@ func getEntireClusterLine() string {
// getExposureEdgeLine formats an exposure connection edge line for dot graph
func getExposureEdgeLine(realPeerStr, repPeerStr string, isIngress bool, conn *common.ConnectionSet) string {
if isIngress {
return fmt.Sprintf(edgeLineFormat, repPeerStr, realPeerStr, conn.String(), edgeWeightLabel+ingWeight)
return fmt.Sprintf(edgeLineFormat, repPeerStr, realPeerStr, conn.String(), ingressExposureEdgeColor,
edgeWeightLabel+ingWeight+exposureEdgeStyle)
}
return fmt.Sprintf(edgeLineFormat, realPeerStr, repPeerStr, conn.String(), edgeWeightLabel+egWeight)
return fmt.Sprintf(edgeLineFormat, realPeerStr, repPeerStr, conn.String(), egressExposureEdgeColor,
edgeWeightLabel+egWeight+exposureEdgeStyle)
}

// getRepPeerLine formats a representative peer line for dot graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ digraph {
"{ingress-controller}" [label="{ingress-controller}" color="blue" fontcolor="blue"]
"backend/checkout[Deployment]" -> "backend/notification[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"backend/checkout[Deployment]" -> "backend/recommendation[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"backend/checkout[Deployment]" -> "entire-cluster" [label="UDP 5353" color="gold2" fontcolor="darkgreen" weight=0.5]
"backend/checkout[Deployment]" -> "entire-cluster" [label="UDP 5353" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"backend/checkout[Deployment]" -> "payments/gateway[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"backend/recommendation[Deployment]" -> "backend/catalog[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"backend/recommendation[Deployment]" -> "entire-cluster" [label="UDP 5353" color="gold2" fontcolor="darkgreen" weight=0.5]
"backend/recommendation[Deployment]" -> "entire-cluster" [label="UDP 5353" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"backend/reports[Deployment]" -> "backend/catalog[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"backend/reports[Deployment]" -> "backend/recommendation[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"backend/reports[Deployment]" -> "entire-cluster" [label="UDP 5353" color="gold2" fontcolor="darkgreen" weight=0.5]
"entire-cluster" -> "frontend/asset-cache[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen" weight=1]
"entire-cluster" -> "frontend/webapp[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen" weight=1]
"backend/reports[Deployment]" -> "entire-cluster" [label="UDP 5353" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"entire-cluster" -> "frontend/asset-cache[Deployment]" [label="TCP 8080" color="darkorange2" fontcolor="darkgreen" weight=1 style=dashed]
"entire-cluster" -> "frontend/webapp[Deployment]" [label="TCP 8080" color="darkorange2" fontcolor="darkgreen" weight=1 style=dashed]
"frontend/webapp[Deployment]" -> "backend/checkout[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "backend/recommendation[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "backend/reports[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "backend/shipping[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "entire-cluster" [label="UDP 5353" color="gold2" fontcolor="darkgreen" weight=0.5]
"payments/gateway[Deployment]" -> "entire-cluster" [label="UDP 5353" color="gold2" fontcolor="darkgreen" weight=0.5]
"frontend/webapp[Deployment]" -> "entire-cluster" [label="UDP 5353" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"payments/gateway[Deployment]" -> "entire-cluster" [label="UDP 5353" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"payments/gateway[Deployment]" -> "payments/mastercard-processor[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"payments/gateway[Deployment]" -> "payments/visa-processor[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"{ingress-controller}" -> "frontend/asset-cache[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ digraph {
}
"entire-cluster" [label="entire-cluster" color="red2" fontcolor="red2" shape=diamond]
"{ingress-controller}" [label="{ingress-controller}" color="blue" fontcolor="blue"]
"entire-cluster" -> "frontend/webapp[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen" weight=1]
"entire-cluster" -> "frontend/webapp[Deployment]" [label="TCP 8080" color="darkorange2" fontcolor="darkgreen" weight=1 style=dashed]
"frontend/webapp[Deployment]" -> "backend/checkout[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "backend/recommendation[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "backend/reports[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "backend/shipping[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
"frontend/webapp[Deployment]" -> "entire-cluster" [label="UDP 5353" color="gold2" fontcolor="darkgreen" weight=0.5]
"frontend/webapp[Deployment]" -> "entire-cluster" [label="UDP 5353" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"{ingress-controller}" -> "frontend/webapp[Deployment]" [label="TCP 8080" color="gold2" fontcolor="darkgreen"]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ digraph {
"default/ratings-v1-b6994bb9[ReplicaSet]" -> "default/reviews-v1-545db77b95[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen"]
"default/ratings-v1-b6994bb9[ReplicaSet]" -> "default/reviews-v2-7bf8c9648f[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen"]
"default/ratings-v1-b6994bb9[ReplicaSet]" -> "default/reviews-v3-84779c7bbc[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen"]
"default/ratings-v1-b6994bb9[ReplicaSet]" -> "entire-cluster" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=0.5]
"default/ratings-v1-b6994bb9[ReplicaSet]" -> "entire-cluster" [label="All Connections" color="darkorange4" fontcolor="darkgreen" weight=0.5 style=dashed]
"default/reviews-v1-545db77b95[ReplicaSet]" -> "default/ratings-v1-b6994bb9[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen"]
"default/reviews-v2-7bf8c9648f[ReplicaSet]" -> "default/ratings-v1-b6994bb9[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen"]
"default/reviews-v3-84779c7bbc[ReplicaSet]" -> "default/ratings-v1-b6994bb9[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen"]
"entire-cluster" -> "default/ratings-v1-b6994bb9[ReplicaSet]" [label="All Connections" color="gold2" fontcolor="darkgreen" weight=1]
"entire-cluster" -> "default/ratings-v1-b6994bb9[ReplicaSet]" [label="All Connections" color="darkorange2" fontcolor="darkgreen" weight=1 style=dashed]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 51f3239

Please sign in to comment.