Skip to content

Commit 6f54948

Browse files
NETOBSERV-2438: enforce validation on subnet names (#2172)
Also standardize using EXT: for external subnet names in sample metrics Co-authored-by: Joel Takvorian <jtakvori@redhat.com>
1 parent e1c7730 commit 6f54948

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
lines changed

api/flowcollector/v1beta2/flowcollector_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,9 @@ type SubnetLabel struct {
14171417
// List of CIDRs, such as `["1.2.3.4/32"]`.
14181418
//+required
14191419
CIDRs []string `json:"cidrs,omitempty"` // Note, starting with k8s 1.31 / ocp 4.16 there's a new way to validate CIDR such as `+kubebuilder:validation:XValidation:rule="isCIDR(self)",message="field should be in CIDR notation format"`. But older versions would reject the CRD so we cannot implement it now to maintain compatibility.
1420+
14201421
// Label name, used to flag matching flows.
1422+
// +kubebuilder:validation:Pattern:="^[a-zA-Z_:-][a-zA-Z0-9_:-]*$"
14211423
//+required
14221424
Name string `json:"name,omitempty"`
14231425
}

bundle/manifests/flows.netobserv.io_flowcollectors.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6112,6 +6112,7 @@ spec:
61126112
type: array
61136113
name:
61146114
description: Label name, used to flag matching flows.
6115+
pattern: ^[a-zA-Z_:-][a-zA-Z0-9_:-]*$
61156116
type: string
61166117
required:
61176118
- cidrs

config/crd/bases/flows.netobserv.io_flowcollectors.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5647,6 +5647,7 @@ spec:
56475647
type: array
56485648
name:
56495649
description: Label name, used to flag matching flows.
5650+
pattern: ^[a-zA-Z_:-][a-zA-Z0-9_:-]*$
56505651
type: string
56515652
required:
56525653
- cidrs

config/samples/flowmetrics/cluster_external_egress_traffic.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ spec:
99
type: Counter
1010
valueField: Bytes
1111
direction: Egress
12-
labels: [SrcK8S_HostName,SrcK8S_Namespace,SrcK8S_OwnerName,SrcK8S_OwnerType]
12+
labels: [SrcK8S_HostName,SrcK8S_Namespace,SrcK8S_OwnerName,SrcK8S_OwnerType,DstSubnetLabel]
1313
filters:
1414
- field: DstSubnetLabel
1515
matchType: Absence
16+
- field: DstSubnetLabel
17+
matchType: MatchRegex
18+
value: "^EXT:.*"
1619
charts:
1720
- dashboardName: Main
1821
title: External egress traffic

config/samples/flowmetrics/cluster_external_ingress_traffic.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ spec:
99
type: Counter
1010
valueField: Bytes
1111
direction: Ingress
12-
labels: [DstK8S_HostName,DstK8S_Namespace,DstK8S_OwnerName,DstK8S_OwnerType]
12+
labels: [DstK8S_HostName,DstK8S_Namespace,DstK8S_OwnerName,DstK8S_OwnerType,SrcSubnetLabel]
1313
filters:
1414
- field: SrcSubnetLabel
1515
matchType: Absence
16+
- field: SrcSubnetLabel
17+
matchType: MatchRegex
18+
value: "^EXT:.*"
1619
charts:
1720
- dashboardName: Main
1821
title: External ingress traffic

helm/crds/flows.netobserv.io_flowcollectors.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5651,6 +5651,7 @@ spec:
56515651
type: array
56525652
name:
56535653
description: Label name, used to flag matching flows.
5654+
pattern: ^[a-zA-Z_:-][a-zA-Z0-9_:-]*$
56545655
type: string
56555656
required:
56565657
- cidrs

0 commit comments

Comments
 (0)