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

WIP Add network flows export support to OpenShift #982

Closed
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
11 changes: 11 additions & 0 deletions bindata/network/ovn-kubernetes/006-ovs-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ spec:
trap quit SIGTERM
# Don't need to worry about restoring flows; this can only change if we've rebooted
tail --pid=$BASHPID -F /host/var/log/openvswitch/ovs-vswitchd.log /host/var/log/openvswitch/ovsdb-server.log &
{{ if .EnableExportNetworkFlows }}
{{ if .EnableNetFlow }}
ovs-vsctl -- --id=@netflow create netflow targets={{ .NetFlowCollectors }} -- set bridge br-int netflow=@netflow
{{ end }}
{{ if .EnableSFlow }}
ovs-vsctl -- --id=@sflow create sflow agent=ovn-k8s-mp0 targets={{ .SFlowCollectors }} header=128 sampling=64 polling=10 -- set bridge br-int sflow=@sflow
{{ end }}
{{ if .EnableIPFIX }}
ovs-vsctl -- --id=@ipfix create ipfix targets={{ .IPFIXCollectors }} obs_domain_id=123 obs_point=456 sampling=1 -- set bridge br-int ipfix=@ipfix
{{ end }}
{{ end }}
wait
env:
- name: OVS_LOG_LEVEL
Expand Down
39 changes: 39 additions & 0 deletions pkg/network/ovn_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,45 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
data.Data["EnableIPsec"] = false
}

if conf.ExportNetworkFlows != nil {
data.Data["EnableExportNetworkFlows"] = true
if conf.ExportNetworkFlows.NetFlow != nil {
data.Data["EnableNetFlow"] = true
collectors := "\\["
for _, v := range conf.ExportNetworkFlows.NetFlow {
collectors += "\\\"" + v + "\\\"" + ","
}
collectors = strings.TrimSuffix(collectors, ",") + "\\]"
data.Data["NetFlowCollectors"] = collectors
} else {
data.Data["EnableNetFlow"] = false
}
if conf.ExportNetworkFlows.SFlow != nil {
data.Data["EnableSFlow"] = true
collectors := "\\["
for _, v := range conf.ExportNetworkFlows.SFlow {
collectors += "\\\"" + v + "\\\"" + ","
}
collectors = strings.TrimSuffix(collectors, ",") + "\\]"
data.Data["SFlowCollectors"] = collectors
} else {
data.Data["EnableSFlow"] = false
}
if conf.ExportNetworkFlows.IPFIX != nil {
data.Data["EnableIPFIX"] = true
collectors := "\\["
for _, v := range conf.ExportNetworkFlows.IPFIX {
collectors += "\\\"" + v + "\\\"" + ","
}
collectors = strings.TrimSuffix(collectors, ",") + "\\]"
data.Data["IPFIXCollectors"] = collectors
} else {
data.Data["EnableIPFIX"] = false
}
} else {
data.Data["EnableExportNetworkFlows"] = false
}

manifests, err := render.RenderDir(filepath.Join(manifestDir, "network/ovn-kubernetes"), &data)
if err != nil {
return nil, errors.Wrap(err, "failed to render manifests")
Expand Down

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

20 changes: 20 additions & 0 deletions vendor/github.com/openshift/api/operator/v1/types_network.go

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