Skip to content

Commit

Permalink
Added flag to enable multiCluster configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierCazade committed Nov 20, 2023
1 parent fc1c80c commit ef51fe2
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 13 deletions.
7 changes: 7 additions & 0 deletions api/v1alpha1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
if restored.Spec.Processor.Metrics.DisableAlerts != nil {
dst.Spec.Processor.Metrics.DisableAlerts = restored.Spec.Processor.Metrics.DisableAlerts
}
if restored.Spec.Processor.ClusterName != "" {
dst.Spec.Processor.ClusterName = restored.Spec.Processor.ClusterName
}
if restored.Spec.Processor.MultiClusterDeployment != nil {
dst.Spec.Processor.MultiClusterDeployment = restored.Spec.Processor.MultiClusterDeployment
}

dst.Spec.Processor.Metrics.Server.TLS.InsecureSkipVerify = restored.Spec.Processor.Metrics.Server.TLS.InsecureSkipVerify
dst.Spec.Processor.Metrics.Server.TLS.ProvidedCaFile = restored.Spec.Processor.Metrics.Server.TLS.ProvidedCaFile

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.conversion.go

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

4 changes: 4 additions & 0 deletions api/v1beta1/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ type FlowCollectorFLP struct {
// `clusterName` is the name of the cluster to appear in the flows data. This is useful in a multi-cluster context. When using OpenShift, leave empty to make it automatically determined.
ClusterName string `json:"clusterName,omitempty"`

//+kubebuilder:default:=false
// Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data
MultiClusterDeployment *bool `json:"multiClusterDeployment,omitempty"`

// `debug` allows setting some aspects of the internal configuration of the flow processor.
// This section is aimed exclusively 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
2 changes: 2 additions & 0 deletions api/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 api/v1beta1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions api/v1beta2/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ type FlowCollectorFLP struct {
// `clusterName` is the name of the cluster to appear in the flows data. This is useful in a multi-cluster context. When using OpenShift, leave empty to make it automatically determined.
ClusterName string `json:"clusterName,omitempty"`

//+kubebuilder:default:=false
// Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data
MultiClusterDeployment *bool `json:"multiClusterDeployment,omitempty"`

// `debug` allows setting some aspects of the internal configuration of the flow processor.
// This section is aimed exclusively 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 api/v1beta2/zz_generated.deepcopy.go

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

12 changes: 12 additions & 0 deletions bundle/manifests/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4925,6 +4925,12 @@ spec:
type: object
type: object
type: object
multiClusterDeployment:
default: false
description: Set `multiClusterDeployment` to `true` to enable
multi clusters feature. This will add clusterName label to flows
data
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention,
Expand Down Expand Up @@ -7807,6 +7813,12 @@ spec:
type: object
type: object
type: object
multiClusterDeployment:
default: false
description: Set `multiClusterDeployment` to `true` to enable
multi clusters feature. This will add clusterName label to flows
data
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention,
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4911,6 +4911,12 @@ spec:
type: object
type: object
type: object
multiClusterDeployment:
default: false
description: Set `multiClusterDeployment` to `true` to enable
multi clusters feature. This will add clusterName label to flows
data
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention,
Expand Down Expand Up @@ -7793,6 +7799,12 @@ spec:
type: object
type: object
type: object
multiClusterDeployment:
default: false
description: Set `multiClusterDeployment` to `true` to enable
multi clusters feature. This will add clusterName label to flows
data
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention,
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 @@ -70,6 +70,7 @@ func flowCollectorIsoSpecs() {
ConversationHeartbeatInterval: &metav1.Duration{Duration: time.Second},
ConversationEndTimeout: &metav1.Duration{Duration: time.Second},
ConversationTerminatingTimeout: &metav1.Duration{Duration: time.Second},
MultiClusterDeployment: ptr.To(true),
ClusterName: "testCluster",
Debug: flowslatest.DebugConfig{},
LogTypes: &outputRecordTypes,
Expand Down
34 changes: 21 additions & 13 deletions controllers/flowlogspipeline/flp_common_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
conntrackTerminatingTimeout = 5 * time.Second
conntrackEndTimeout = 10 * time.Second
conntrackHeartbeatInterval = 30 * time.Second
clusterNameLabelName = "K8S_ClusterName"
)

type ConfKind string
Expand Down Expand Up @@ -289,6 +290,10 @@ func (b *builder) addTransformStages(stage *config.PipelineBuilderStage) error {

indexFields, lastStage = b.addConnectionTracking(indexFields, lastStage)

if b.desired.Processor.MultiClusterDeployment != nil && *b.desired.Processor.MultiClusterDeployment {
indexFields = append(indexFields, clusterNameLabelName)
}

// enrich stage (transform) configuration
enrichedStage := lastStage.TransformNetwork("enrich", api.TransformNetwork{
Rules: api.NetworkTransformRules{{
Expand Down Expand Up @@ -554,20 +559,23 @@ func (b *builder) addTransformFilter(lastStage config.PipelineBuilderStage) conf
var clusterName string
transformFilterRules := []api.TransformFilterRule{}

if b.desired.Processor.ClusterName != "" {
clusterName = b.desired.Processor.ClusterName
} else {
//take clustername from openshift
clusterName = string(globals.DefaultClusterID)
}
if clusterName != "" {
transformFilterRules = []api.TransformFilterRule{
{
Input: "K8S_ClusterName",
Type: "add_field_if_doesnt_exist",
Value: clusterName,
},
if b.desired.Processor.MultiClusterDeployment != nil && *b.desired.Processor.MultiClusterDeployment {
if b.desired.Processor.ClusterName != "" {
clusterName = b.desired.Processor.ClusterName
} else {
//take clustername from openshift
clusterName = string(globals.DefaultClusterID)
}
if clusterName != "" {
transformFilterRules = []api.TransformFilterRule{
{
Input: clusterNameLabelName,
Type: "add_field_if_doesnt_exist",
Value: clusterName,
},
}
}

}

// Filter-out unused fields?
Expand Down
18 changes: 18 additions & 0 deletions docs/FlowCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -7537,6 +7537,15 @@ TLS client configuration for Loki URL.
`Metrics` define the processor configuration regarding metrics<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>multiClusterDeployment</b></td>
<td>boolean</td>
<td>
Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data<br/>
<br/>
<i>Default</i>: false<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>port</b></td>
<td>integer</td>
Expand Down Expand Up @@ -12698,6 +12707,15 @@ TLS client configuration for Loki URL.
`Metrics` define the processor configuration regarding metrics<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>multiClusterDeployment</b></td>
<td>boolean</td>
<td>
Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data<br/>
<br/>
<i>Default</i>: false<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>port</b></td>
<td>integer</td>
Expand Down
8 changes: 8 additions & 0 deletions hack/cloned.flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3409,6 +3409,10 @@ spec:
type: object
type: object
type: object
multiClusterDeployment:
default: false
description: Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention, some values are forbidden. It must be greater than 1024 and different from 4500, 4789 and 6081.
Expand Down Expand Up @@ -5396,6 +5400,10 @@ spec:
type: object
type: object
type: object
multiClusterDeployment:
default: false
description: Set `multiClusterDeployment` to `true` to enable multi clusters feature. This will add clusterName label to flows data
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention, some values are forbidden. It must be greater than 1024 and different from 4500, 4789 and 6081.
Expand Down

0 comments on commit ef51fe2

Please sign in to comment.