From 5f17fd53910e57f0a757b09a6fb721bf1a2892a0 Mon Sep 17 00:00:00 2001 From: Julien Pinsonneau Date: Mon, 29 Jan 2024 14:06:37 +0100 Subject: [PATCH] Cluster name & zone features --- controllers/consoleplugin/config/config.go | 30 +++++++++++++++---- .../config/static-frontend-config.yaml | 19 +++++++++--- .../consoleplugin/consoleplugin_objects.go | 22 +++++++++++++- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/controllers/consoleplugin/config/config.go b/controllers/consoleplugin/config/config.go index 76a3c22da..6b22ccd71 100644 --- a/controllers/consoleplugin/config/config.go +++ b/controllers/consoleplugin/config/config.go @@ -1,6 +1,8 @@ package config import ( + "strings" + flowslatest "github.com/netobserv/network-observability-operator/apis/flowcollector/v1beta2" ) @@ -68,11 +70,11 @@ type Deduper struct { } type FrontendConfig struct { - RecordTypes []string `yaml:"recordTypes" json:"recordTypes"` - Columns []ColumnConfig `yaml:"columns" json:"columns"` - Sampling int `yaml:"sampling" json:"sampling"` - Features []string `yaml:"features" json:"features"` - Deduper Deduper `yaml:"deduper" json:"deduper"` + RecordTypes []string `yaml:"recordTypes" json:"recordTypes"` + Columns []*ColumnConfig `yaml:"columns" json:"columns"` + Sampling int `yaml:"sampling" json:"sampling"` + Features []string `yaml:"features" json:"features"` + Deduper Deduper `yaml:"deduper" json:"deduper"` PortNaming flowslatest.ConsolePluginPortConfig `yaml:"portNaming,omitempty" json:"portNaming,omitempty"` Filters []FilterConfig `yaml:"filters,omitempty" json:"filters,omitempty"` @@ -85,3 +87,21 @@ type PluginConfig struct { Loki LokiConfig `yaml:"loki" json:"loki"` Frontend FrontendConfig `yaml:"frontend" json:"frontend"` } + +func (fconf *FrontendConfig) FilterColumns(matchers []string) { + filtered := []*ColumnConfig{} + for _, c := range fconf.Columns { + match := false + for _, m := range matchers { + if strings.Contains(strings.ToLower(c.ID), m) { + match = true + break + } + } + + if !match { + filtered = append(filtered, c) + } + } + fconf.Columns = filtered +} diff --git a/controllers/consoleplugin/config/static-frontend-config.yaml b/controllers/consoleplugin/config/static-frontend-config.yaml index 9a35b5660..b3df1136f 100644 --- a/controllers/consoleplugin/config/static-frontend-config.yaml +++ b/controllers/consoleplugin/config/static-frontend-config.yaml @@ -29,6 +29,13 @@ columns: filter: id default: true width: 15 + - id: ClusterName + name: Cluster + tooltip: The cluster ID or Name. + field: K8S_ClusterName + filter: cluster_name + default: false + width: 15 - id: SrcK8S_Name group: Source name: Name @@ -466,6 +473,10 @@ columns: default: true width: 5 filters: + - id: cluster_name + name: Cluster + component: autocomplete + hint: Specify a cluster ID or name. - id: src_namespace name: Namespace component: autocomplete @@ -571,13 +582,13 @@ filters: - Ending text like "*-registry" - Pattern like "cluster-*-registry", "c*-*-r*y", -i*e- - id: src_zone - name: Zone Name - component: text + name: Zone + component: autocomplete category: source hint: Specify a single zone. - id: dst_zone - name: Zone Name - component: text + name: Zone + component: autocomplete category: destination hint: Specify a single zone. - id: src_resource diff --git a/controllers/consoleplugin/consoleplugin_objects.go b/controllers/consoleplugin/consoleplugin_objects.go index 9107ab84c..7549cfc54 100644 --- a/controllers/consoleplugin/consoleplugin_objects.go +++ b/controllers/consoleplugin/consoleplugin_objects.go @@ -351,6 +351,7 @@ func (b *builder) setLokiConfig(lconf *config.LokiConfig) { func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) error { var err error + skipColumns := []string{} dedupJustMark, err := strconv.ParseBool(ebpf.DedupeJustMarkDefault) if err != nil { return err @@ -362,14 +363,18 @@ func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) error { if helper.UseEBPF(b.desired) { if helper.IsPktDropEnabled(&b.desired.Agent.EBPF) { fconf.Features = append(fconf.Features, "pktDrop") - } + } // no specific drop column if helper.IsDNSTrackingEnabled(&b.desired.Agent.EBPF) { fconf.Features = append(fconf.Features, "dnsTracking") + } else { + skipColumns = append(skipColumns, "dns") } if helper.IsFlowRTTEnabled(&b.desired.Agent.EBPF) { fconf.Features = append(fconf.Features, "flowRTT") + } else { + skipColumns = append(skipColumns, "flowrtt") } if b.desired.Agent.EBPF.Advanced != nil { @@ -387,6 +392,8 @@ func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) error { } } } + } else { + skipColumns = append(skipColumns, "dns", "flowrtt") } fconf.RecordTypes = helper.GetRecordTypes(&b.desired.Processor) fconf.PortNaming = b.desired.ConsolePlugin.PortNaming @@ -397,6 +404,19 @@ func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) error { Mark: dedupJustMark, Merge: dedupMerge, } + if b.desired.Processor.MultiClusterDeployment != nil && *b.desired.Processor.MultiClusterDeployment { + fconf.Features = append(fconf.Features, "multiCluster") + } else { + skipColumns = append(skipColumns, "cluster") + } + if b.desired.Processor.AddZone != nil && *b.desired.Processor.AddZone { + fconf.Features = append(fconf.Features, "zones") + } else { + skipColumns = append(skipColumns, "zone") + } + if len(skipColumns) > 0 { + fconf.FilterColumns(skipColumns) + } return nil }