Merge branch '1.8'
This commit is contained in:
commit
16fca913de
2 files changed
+51
No files matched your search
@@ -46,6 +46,7 @@ func gatherMetrics() {
|
||||
tcp, _ := tcpLayer.(*layers.TCP)
|
||||
if tcp.SYN && !tcp.ACK { // Only plain SYN constitutes a NEW TCP connection
|
||||
blockedConnections.With(prometheus.Labels{"protocol": "tcp", "dport": strconv.Itoa(int(tcp.DstPort))}).Inc()
|
||||
log.Warnf("TCP connection from %v:%d to %v:%d blocked by Weave NPC.", srcIP(packet), tcp.SrcPort, dstIP(packet), tcp.DstPort)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -53,11 +54,42 @@ func gatherMetrics() {
|
||||
if udpLayer := packet.Layer(layers.LayerTypeUDP); udpLayer != nil {
|
||||
udp, _ := udpLayer.(*layers.UDP)
|
||||
blockedConnections.With(prometheus.Labels{"protocol": "udp", "dport": strconv.Itoa(int(udp.DstPort))}).Inc()
|
||||
log.Warnf("UDP connection from %v:%d to %v:%d blocked by Weave NPC.", srcIP(packet), udp.SrcPort, dstIP(packet), udp.DstPort)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const unknownIP string = "<unknown IP>"
|
||||
|
||||
func srcIP(packet gopacket.Packet) string {
|
||||
if layer := packet.Layer(layers.LayerTypeIPv4); layer != nil {
|
||||
if ip, ok := layer.(*layers.IPv4); ok {
|
||||
return ip.SrcIP.String()
|
||||
}
|
||||
}
|
||||
if layer := packet.Layer(layers.LayerTypeIPv6); layer != nil {
|
||||
if ip, ok := layer.(*layers.IPv6); ok {
|
||||
return ip.SrcIP.String()
|
||||
}
|
||||
}
|
||||
return unknownIP
|
||||
}
|
||||
|
||||
func dstIP(packet gopacket.Packet) string {
|
||||
if layer := packet.Layer(layers.LayerTypeIPv4); layer != nil {
|
||||
if ip, ok := layer.(*layers.IPv4); ok {
|
||||
return ip.DstIP.String()
|
||||
}
|
||||
}
|
||||
if layer := packet.Layer(layers.LayerTypeIPv6); layer != nil {
|
||||
if ip, ok := layer.(*layers.IPv6); ok {
|
||||
return ip.DstIP.String()
|
||||
}
|
||||
}
|
||||
return unknownIP
|
||||
}
|
||||
|
||||
func Start(addr string) error {
|
||||
if err := prometheus.Register(blockedConnections); err != nil {
|
||||
return err
|
||||
|
||||
@@ -65,6 +65,25 @@ Kubernetes see the
|
||||
and the [NetworkPolicy API object
|
||||
definition](http://kubernetes.io/docs/api-reference/extensions/v1beta1/definitions/#_v1beta1_networkpolicy).
|
||||
|
||||
### Blocked connections
|
||||
|
||||
If you suspect that legitimate traffic is being blocked by the Weave Network Policy Controller, you may want to look at the `weave-npc` container's logs:
|
||||
```
|
||||
$ kubectl logs $(kubectl get pods --all-namespaces | grep weave-net | awk '{print $2}') -n kube-system weave-npc
|
||||
```
|
||||
|
||||
Any time the Weave Network Policy Controller blocks a connection, it will log details about it:
|
||||
|
||||
* protocol used,
|
||||
* source IP and port,
|
||||
* destination IP and port,
|
||||
|
||||
as per the below example:
|
||||
```
|
||||
time="yyyy-MM-ddTHH:mm:ssZ" level=warning msg="TCP connection from 10.32.0.7:56648 to 10.32.0.11:80 blocked by Weave NPC.
|
||||
time="yyyy-MM-ddTHH:mm:ssZ" level=warning msg="UDP connection from 10.32.0.7:56648 to 10.32.0.11:80 blocked by Weave NPC.
|
||||
```
|
||||
|
||||
## Changing Configuration Options
|
||||
|
||||
You can change the default configuration by saving and editing the
|
||||
|
||||
Reference in new issue
Block a user