Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETOBSERV-1203 Add field to enable zone #537

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apis/flowcollector/v1alpha1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
if restored.Spec.Processor.ClusterName != "" {
dst.Spec.Processor.ClusterName = restored.Spec.Processor.ClusterName
}
dst.Spec.Processor.AddZone = restored.Spec.Processor.AddZone
if restored.Spec.Processor.MultiClusterDeployment != nil {
dst.Spec.Processor.MultiClusterDeployment = restored.Spec.Processor.MultiClusterDeployment
}
Expand Down
1 change: 1 addition & 0 deletions apis/flowcollector/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/flowcollector/v1beta1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Loki.Monolithic = restored.Spec.Loki.Monolithic
dst.Spec.Loki.Microservices = restored.Spec.Loki.Microservices
dst.Spec.Loki.Manual = restored.Spec.Loki.Manual
dst.Spec.Processor.AddZone = restored.Spec.Processor.AddZone

return nil
}
Expand Down
1 change: 1 addition & 0 deletions apis/flowcollector/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apis/flowcollector/v1beta2/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ type FlowCollectorFLP struct {
// Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data
MultiClusterDeployment *bool `json:"multiClusterDeployment,omitempty"`

//+kubebuilder:default:=false
//+optional
// `addZone` when set to `true`, the source and destination of flow will their zone added to the flow
AddZone *bool `json:"addZone,omitempty"`

// `advanced` allows setting some aspects of the internal configuration of the flow processor.
// This section is aimed mostly for debugging and fine-grained performance optimizations,
// such as `GOGC` and `GOMAXPROCS` env vars. Users setting its values do it at their own risk.
Expand Down
5 changes: 5 additions & 0 deletions apis/flowcollector/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions bundle/manifests/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7102,6 +7102,11 @@ spec:
and forwards them to the Loki persistence layer and/or any available
exporter.'
properties:
addZone:
default: false
description: '`addZone` when set to `true`, the source and destination
of flow will their zone added to the flow'
type: boolean
advanced:
description: '`advanced` allows setting some aspects of the internal
configuration of the flow processor. This section is aimed mostly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,12 @@ spec:
path: loki.monolithic.tenantID
- displayName: Url
path: loki.monolithic.url
- displayName: Read timeout
path: loki.readTimeout
- displayName: Namespace
path: namespace
- displayName: Add zone
path: processor.addZone
- displayName: Log types
path: processor.logTypes
- displayName: Disable alerts
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7088,6 +7088,11 @@ spec:
and forwards them to the Loki persistence layer and/or any available
exporter.'
properties:
addZone:
default: false
description: '`addZone` when set to `true`, the source and destination
of flow will their zone added to the flow'
type: boolean
advanced:
description: '`advanced` allows setting some aspects of the internal
configuration of the flow processor. This section is aimed mostly
Expand Down
1 change: 1 addition & 0 deletions config/samples/flows_v1beta2_flowcollector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ spec:
logTypes: Flows
# Append a unique cluster name to each record
# clusterName: <CLUSTER NAME>
# addZone: true
metrics:
server:
port: 9102
Expand Down
24 changes: 24 additions & 0 deletions controllers/consoleplugin/config/static-frontend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ columns:
calculated: getConcatenatedValue(SrcAddr,SrcPort)
default: false
width: 15
- id: SrcZone
group: Source
name: Zone
field: SrcK8S_Zone
filter: src_zone
default: false
width: 15
- id: DstK8S_Name
group: Destination
name: Name
Expand Down Expand Up @@ -253,6 +260,13 @@ columns:
calculated: getConcatenatedValue(DstAddr,DstPort)
default: false
width: 15
- id: DstZone
group: Destination
name: Zone
field: DstK8S_Zone
filter: dst_zone
default: false
width: 15
- id: K8S_Name
name: Names
calculated: getSrcOrDstValue(SrcK8S_Name,DstK8S_Name)
Expand Down Expand Up @@ -556,6 +570,16 @@ filters:
- Starting text like cluster, "cluster-*"
- Ending text like "*-registry"
- Pattern like "cluster-*-registry", "c*-*-r*y", -i*e-
- id: src_zone
name: Zone Name
component: text
category: source
hint: Specify a single zone.
- id: dst_zone
name: Zone Name
component: text
category: destination
hint: Specify a single zone.
- id: src_resource
name: Resource
component: autocomplete
Expand Down
1 change: 1 addition & 0 deletions controllers/flowcollector_controller_iso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func flowCollectorIsoSpecs() {
KafkaConsumerBatchSize: int(zero),
MultiClusterDeployment: ptr.To(true),
ClusterName: "testCluster",
AddZone: ptr.To(false),
Advanced: &flowslatest.AdvancedProcessorConfig{
Port: ptr.To(int32(12345)),
HealthPort: ptr.To(int32(12346)),
Expand Down
11 changes: 11 additions & 0 deletions controllers/flp/flp_pipeline_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,27 @@ func (b *PipelineBuilder) AddProcessorStages() error {
lastStage = b.addTransformFilter(lastStage)
lastStage = b.addConnectionTracking(lastStage)

addZone := false
if b.desired.Processor.AddZone != nil {
addZone = *b.desired.Processor.AddZone
}

// enrich stage (transform) configuration
enrichedStage := lastStage.TransformNetwork("enrich", api.TransformNetwork{
Rules: api.NetworkTransformRules{{
Input: "SrcAddr",
Output: "SrcK8S",
Type: api.AddKubernetesRuleType,
Kubernetes: &api.K8sRule{
AddZone: addZone,
},
}, {
Input: "DstAddr",
Output: "DstK8S",
Type: api.AddKubernetesRuleType,
Kubernetes: &api.K8sRule{
AddZone: addZone,
},
}, {
Type: api.ReinterpretDirectionRuleType,
}, {
Expand Down
9 changes: 9 additions & 0 deletions docs/FlowCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -12657,6 +12657,15 @@ TLS client configuration for Loki URL.
</tr>
</thead>
<tbody><tr>
<td><b>addZone</b></td>
<td>boolean</td>
<td>
`addZone` when set to `true`, the source and destination of flow will their zone added to the flow<br/>
<br/>
<i>Default</i>: false<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#flowcollectorspecprocessoradvanced">advanced</a></b></td>
<td>object</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/go-logr/logr v1.4.1
github.com/mitchellh/mapstructure v1.5.0
github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240123101451-40b694850494
github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240125165124-4289f5a17934
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.30.0
github.com/openshift/api v0.0.0-20220112145620-704957ce4980
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240123101451-40b694850494 h1:r0yWwNs/r0J6kRO4nnbGxUwITVdHAkWSXFr1+6gzIqs=
github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240123101451-40b694850494/go.mod h1:Hfcqa5PFrELNp1B4M9e2+rG3226uOiKMi8KEOYBY0ow=
github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240125165124-4289f5a17934 h1:vMJ6tEETHl81Lbzmvs7z7I7PgvyC6WEzlJym2zSWMpQ=
github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240125165124-4289f5a17934/go.mod h1:Hfcqa5PFrELNp1B4M9e2+rG3226uOiKMi8KEOYBY0ow=
github.com/netobserv/prometheus-common v0.46.0-netobserv h1:gpnbXZtSWBauwlSm0aC//mAwAUIvblW6xqNV4mnY2mE=
github.com/netobserv/prometheus-common v0.46.0-netobserv/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down
4 changes: 4 additions & 0 deletions hack/cloned.flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4933,6 +4933,10 @@ spec:
processor:
description: '`processor` defines the settings of the component that receives the flows from the agent, enriches them, generates metrics, and forwards them to the Loki persistence layer and/or any available exporter.'
properties:
addZone:
default: false
description: '`addZone` when set to `true`, the source and destination of flow will their zone added to the flow'
type: boolean
advanced:
description: '`advanced` allows setting some aspects of the internal configuration of the flow processor. This section is aimed mostly for debugging and fine-grained performance optimizations, such as `GOGC` and `GOMAXPROCS` env vars. Users setting its values do it at their own risk.'
properties:
Expand Down
2 changes: 1 addition & 1 deletion hack/crd2csvSpecDesc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

version="$1"

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ github.com/munnerz/goautoneg
# github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
## explicit
github.com/mwitkow/go-conntrack
# github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240123101451-40b694850494
# github.com/netobserv/flowlogs-pipeline v0.1.11-0.20240125165124-4289f5a17934
## explicit; go 1.20
github.com/netobserv/flowlogs-pipeline/pkg/api
github.com/netobserv/flowlogs-pipeline/pkg/config
Expand Down
Loading