Skip to content

Commit

Permalink
Cluster name & zone features
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Jan 29, 2024
1 parent a01f2d9 commit 5f17fd5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
30 changes: 25 additions & 5 deletions controllers/consoleplugin/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"strings"

flowslatest "github.com/netobserv/network-observability-operator/apis/flowcollector/v1beta2"
)

Expand Down Expand Up @@ -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"`
Expand All @@ -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
}
19 changes: 15 additions & 4 deletions controllers/consoleplugin/config/static-frontend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion controllers/consoleplugin/consoleplugin_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 5f17fd5

Please sign in to comment.