|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/openshift_network_security/AdminNetworkPolicy/logging-anp-policy.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: CONCEPT |
| 6 | +[id="nw-anp-audit-logging_{context}"] |
| 7 | += AdminNetworkPolicy audit logging |
| 8 | + |
| 9 | +Audit logging is enabled per `AdminNetworkPolicy` CR by annotating an ANP policy with the `k8s.ovn.org/acl-logging` key such as in the following example: |
| 10 | + |
| 11 | +.Example of annotation for `AdminNetworkPolicy` CR |
| 12 | +[%collapsible] |
| 13 | +==== |
| 14 | +[source,yaml] |
| 15 | +---- |
| 16 | +apiVersion: policy.networking.k8s.io/v1alpha1 |
| 17 | +kind: AdminNetworkPolicy |
| 18 | +metadata: |
| 19 | + annotations: |
| 20 | + k8s.ovn.org/acl-logging: '{ "deny": "alert", "allow": "alert", "pass" : "warning" }' |
| 21 | + name: anp-tenant-log |
| 22 | +spec: |
| 23 | + priority: 5 |
| 24 | + subject: |
| 25 | + namespaces: |
| 26 | + matchLabels: |
| 27 | + tenant: backend-storage # Selects all pods owned by storage tenant. |
| 28 | + ingress: |
| 29 | + - name: "allow-all-ingress-product-development-and-customer" # Product development and customer tenant ingress to backend storage. |
| 30 | + action: "Allow" |
| 31 | + from: |
| 32 | + - pods: |
| 33 | + namespaceSelector: |
| 34 | + matchExpressions: |
| 35 | + - key: tenant |
| 36 | + operator: In |
| 37 | + values: |
| 38 | + - product-development |
| 39 | + - customer |
| 40 | + podSelector: {} |
| 41 | + - name: "pass-all-ingress-product-security" |
| 42 | + action: "Pass" |
| 43 | + from: |
| 44 | + - namespaces: |
| 45 | + matchLabels: |
| 46 | + tenant: product-security |
| 47 | + - name: "deny-all-ingress" # Ingress to backend from all other pods in the cluster. |
| 48 | + action: "Deny" |
| 49 | + from: |
| 50 | + - namespaces: {} |
| 51 | + egress: |
| 52 | + - name: "allow-all-egress-product-development" |
| 53 | + action: "Allow" |
| 54 | + to: |
| 55 | + - pods: |
| 56 | + namespaceSelector: |
| 57 | + matchLabels: |
| 58 | + tenant: product-development |
| 59 | + podSelector: {} |
| 60 | + - name: "pass-egress-product-security" |
| 61 | + action: "Pass" |
| 62 | + to: |
| 63 | + - namespaces: |
| 64 | + matchLabels: |
| 65 | + tenant: product-security |
| 66 | + - name: "deny-all-egress" # Egress from backend denied to all other pods. |
| 67 | + action: "Deny" |
| 68 | + to: |
| 69 | + - namespaces: {} |
| 70 | +---- |
| 71 | +==== |
| 72 | +
|
| 73 | +Logs are generated whenever a specific OVN ACL is hit and meets the action criteria set in your logging annotation. For example, an event in which any of the namespaces with the label `tenant: product-development` accesses the namespaces with the label `tenant: backend-storage`, a log is generated. |
| 74 | +
|
| 75 | +
|
| 76 | +[NOTE] |
| 77 | +==== |
| 78 | +ACL logging is limited to 60 characters. If your ANP `name` field is long, the rest of the log will be truncated. |
| 79 | +==== |
| 80 | + |
| 81 | +The following is a direction index for the examples log entries that follow: |
| 82 | + |
| 83 | +[cols=".^4,.^6a",options="header"] |
| 84 | +|==== |
| 85 | +|Direction|Rule |
| 86 | + |
| 87 | +|Ingress |
| 88 | +| |
| 89 | +Rule0:: Allow from tenant `product-development` and `customer` to tenant `backend-storage`; Ingress0: `Allow` |
| 90 | +Rule1:: Pass from `product-security`to tenant `backend-storage`; Ingress1: `Pass` |
| 91 | +Rule2:: Deny ingress from all pods; Ingress2: `Deny` |
| 92 | + |
| 93 | +|Egress |
| 94 | +| |
| 95 | +Rule0:: Allow to `product-development`; Egress0: `Allow` |
| 96 | +Rule1:: Pass to `product-security`; Egress1: `Pass` |
| 97 | +Rule2:: Deny egress to all other pods; Egress2: `Deny` |
| 98 | + |
| 99 | +|==== |
| 100 | + |
| 101 | +.Example ACL log entry for `Allow` action of the `AdminNetworkPolicy` named `anp-tenant-log` with `Ingress:0` and `Egress:0` |
| 102 | + |
| 103 | +[%collapsible] |
| 104 | +==== |
| 105 | +[source,text] |
| 106 | +---- |
| 107 | +2024-06-10T16:27:45.194Z|00052|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Ingress:0", verdict=allow, severity=alert, direction=to-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:1a,dl_dst=0a:58:0a:80:02:19,nw_src=10.128.2.26,nw_dst=10.128.2.25,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=57814,tp_dst=8080,tcp_flags=syn |
| 108 | +2024-06-10T16:28:23.130Z|00059|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Ingress:0", verdict=allow, severity=alert, direction=to-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:18,dl_dst=0a:58:0a:80:02:19,nw_src=10.128.2.24,nw_dst=10.128.2.25,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=38620,tp_dst=8080,tcp_flags=ack |
| 109 | +2024-06-10T16:28:38.293Z|00069|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Egress:0", verdict=allow, severity=alert, direction=from-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:19,dl_dst=0a:58:0a:80:02:1a,nw_src=10.128.2.25,nw_dst=10.128.2.26,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=47566,tp_dst=8080,tcp_flags=fin|ack=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=55704,tp_dst=8080,tcp_flags=ack |
| 110 | +---- |
| 111 | +==== |
| 112 | +
|
| 113 | +.Example ACL log entry for `Pass` action of the `AdminNetworkPolicy` named `anp-tenant-log` with `Ingress:1` and `Egress:1` |
| 114 | +
|
| 115 | +[%collapsible] |
| 116 | +==== |
| 117 | +[source,text] |
| 118 | +---- |
| 119 | +2024-06-10T16:33:12.019Z|00075|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Ingress:1", verdict=pass, severity=warning, direction=to-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:1b,dl_dst=0a:58:0a:80:02:19,nw_src=10.128.2.27,nw_dst=10.128.2.25,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=37394,tp_dst=8080,tcp_flags=ack |
| 120 | +2024-06-10T16:35:04.209Z|00081|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Egress:1", verdict=pass, severity=warning, direction=from-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:19,dl_dst=0a:58:0a:80:02:1b,nw_src=10.128.2.25,nw_dst=10.128.2.27,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=34018,tp_dst=8080,tcp_flags=ack |
| 121 | +---- |
| 122 | +==== |
| 123 | +
|
| 124 | +.Example ACL log entry for `Deny` action of the `AdminNetworkPolicy` named `anp-tenant-log` with `Egress:2` and `Ingress2` |
| 125 | +
|
| 126 | +[%collapsible] |
| 127 | +==== |
| 128 | +[source,text] |
| 129 | +---- |
| 130 | +2024-06-10T16:43:05.287Z|00087|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Egress:2", verdict=drop, severity=alert, direction=from-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:19,dl_dst=0a:58:0a:80:02:18,nw_src=10.128.2.25,nw_dst=10.128.2.24,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=51598,tp_dst=8080,tcp_flags=syn |
| 131 | +2024-06-10T16:44:43.591Z|00090|acl_log(ovn_pinctrl0)|INFO|name="ANP:anp-tenant-log:Ingress:2", verdict=drop, severity=alert, direction=to-lport: tcp,vlan_tci=0x0000,dl_src=0a:58:0a:80:02:1c,dl_dst=0a:58:0a:80:02:19,nw_src=10.128.2.28,nw_dst=10.128.2.25,nw_tos=0,nw_ecn=0,nw_ttl=64,nw_frag=no,tp_src=33774,tp_dst=8080,tcp_flags=syn |
| 132 | +---- |
| 133 | +==== |
| 134 | +
|
| 135 | +The following table describes ANP annotation: |
| 136 | +
|
| 137 | +.Audit logging AdminNetworkPolicy annotation |
| 138 | +[cols=".^4,.^6a",options="header"] |
| 139 | +|==== |
| 140 | +|Annotation|Value |
| 141 | +
|
| 142 | +|`k8s.ovn.org/acl-logging` |
| 143 | +| |
| 144 | +You must specify at least one of `Allow`, `Deny`, or `Pass` to enable audit logging for a namespace. |
| 145 | +
|
| 146 | +`Deny`:: Optional: Specify `alert`, `warning`, `notice`, `info`, or `debug`. |
| 147 | +`Allow`:: Optional: Specify `alert`, `warning`, `notice`, `info`, or `debug`. |
| 148 | +`Pass`:: Optional: Specify `alert`, `warning`, `notice`, `info`, or `debug`. |
| 149 | +|==== |
| 150 | +
|
0 commit comments