netobserv / flowlogs-pipeline

Transform flow logs into metrics
Apache License 2.0
75 stars 23 forks source link

NETOBSERV-1790: Manage enrichment via "k8s.v1.cni.cncf.io/network-status" #674

Closed jotak closed 4 weeks ago

jotak commented 3 months ago

Description

Manage enrichment by extracting pod IPs from the annotation "k8s.v1.cni.cncf.io/network-status", which is used (at least) by multus

This allows to correlate Pods with their Mac / IPs on secondary interfaces

Breaking change

The API for add_kubernetes_infra transform stage has been modified to directly use enriched name & namespace to figure out the layer, instead of doing an informer lookup by IP. The reason is informers can now index by MAC.

To migrate, if add_kubernetes_infra rule was used such as:

    kubernetes_infra:
      inputs:
      - SrcAddr
      - DstAddr
      output: K8S_FlowLayer

it must be changed such as:

    kubernetes_infra:
      namespaceNameFields:
      - namespace: SrcK8S_Namespace
        name: SrcK8S_Name
      - namespace: DstK8S_Namespace
        name: DstK8S_Name
      output: K8S_FlowLayer

where SrcK8S_Namespace, SrcK8S_Name, DstK8S_Namespace and DstK8S_Name match the names of the corresponding enriched fields.

Dependencies

https://github.com/netobserv/network-observability-operator/pull/732 for Mac enrichment

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

github-actions[bot] commented 3 months ago

New image: quay.io/netobserv/flowlogs-pipeline:dfe4fdf

It will expire after two weeks.

To deploy this build, run from the operator repo, assuming the operator is running:

USER=netobserv VERSION=dfe4fdf make set-flp-image
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 64.33566% with 51 lines in your changes missing coverage. Please review.

Project coverage is 65.34%. Comparing base (5034e92) to head (ff6e56a). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...peline/transform/kubernetes/informers/informers.go 32.07% 35 Missing and 1 partial :warning:
pkg/pipeline/transform/kubernetes/cni/multus.go 63.63% 8 Missing :warning:
...ipeline/transform/kubernetes/cni/ovn_kubernetes.go 28.57% 5 Missing :warning:
...e/transform/kubernetes/informers/informers-mock.go 96.29% 1 Missing :warning:
pkg/pipeline/transform/transform_network.go 87.50% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #674 +/- ## ========================================== - Coverage 65.42% 65.34% -0.08% ========================================== Files 107 108 +1 Lines 6874 6951 +77 ========================================== + Hits 4497 4542 +45 - Misses 2067 2099 +32 Partials 310 310 ``` | [Flag](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv) | `65.34% <64.33%> (-0.08%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv) | Coverage Δ | | |---|---|---| | [pkg/api/transform\_network.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fapi%2Ftransform_network.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL2FwaS90cmFuc2Zvcm1fbmV0d29yay5nbw==) | `100.00% <ø> (ø)` | | | [pkg/config/generic\_map.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fconfig%2Fgeneric_map.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL2NvbmZpZy9nZW5lcmljX21hcC5nbw==) | `100.00% <100.00%> (ø)` | | | [pkg/pipeline/transform/kubernetes/enrich.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fpipeline%2Ftransform%2Fkubernetes%2Fenrich.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL3BpcGVsaW5lL3RyYW5zZm9ybS9rdWJlcm5ldGVzL2VucmljaC5nbw==) | `79.56% <100.00%> (+2.39%)` | :arrow_up: | | [...e/transform/kubernetes/informers/informers-mock.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fpipeline%2Ftransform%2Fkubernetes%2Finformers%2Finformers-mock.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL3BpcGVsaW5lL3RyYW5zZm9ybS9rdWJlcm5ldGVzL2luZm9ybWVycy9pbmZvcm1lcnMtbW9jay5nbw==) | `97.05% <96.29%> (+0.54%)` | :arrow_up: | | [pkg/pipeline/transform/transform\_network.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fpipeline%2Ftransform%2Ftransform_network.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL3BpcGVsaW5lL3RyYW5zZm9ybS90cmFuc2Zvcm1fbmV0d29yay5nbw==) | `68.02% <87.50%> (+0.21%)` | :arrow_up: | | [...ipeline/transform/kubernetes/cni/ovn\_kubernetes.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fpipeline%2Ftransform%2Fkubernetes%2Fcni%2Fovn_kubernetes.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL3BpcGVsaW5lL3RyYW5zZm9ybS9rdWJlcm5ldGVzL2NuaS9vdm5fa3ViZXJuZXRlcy5nbw==) | `64.86% <28.57%> (-3.71%)` | :arrow_down: | | [pkg/pipeline/transform/kubernetes/cni/multus.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fpipeline%2Ftransform%2Fkubernetes%2Fcni%2Fmultus.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL3BpcGVsaW5lL3RyYW5zZm9ybS9rdWJlcm5ldGVzL2NuaS9tdWx0dXMuZ28=) | `63.63% <63.63%> (ø)` | | | [...peline/transform/kubernetes/informers/informers.go](https://app.codecov.io/gh/netobserv/flowlogs-pipeline/pull/674?src=pr&el=tree&filepath=pkg%2Fpipeline%2Ftransform%2Fkubernetes%2Finformers%2Finformers.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=netobserv#diff-cGtnL3BpcGVsaW5lL3RyYW5zZm9ybS9rdWJlcm5ldGVzL2luZm9ybWVycy9pbmZvcm1lcnMuZ28=) | `18.29% <32.07%> (+0.24%)` | :arrow_up: |
jpinsonneau commented 1 month ago

https://github.com/netobserv/flowlogs-pipeline/pull/674/commits/f39388d718f3a6714b8103160e2e3d0f7d6cf7de ^ checking on mac addresses when possible

image

jotak commented 1 month ago

thanks @jpinsonneau ! /lgtm

openshift-ci[bot] commented 1 month ago

@jotak: you cannot LGTM your own PR.

In response to [this](https://github.com/netobserv/flowlogs-pipeline/pull/674#issuecomment-2286427033): >thanks @jpinsonneau ! >/lgtm > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
openshift-ci-robot commented 1 month ago

@jotak: This pull request references NETOBSERV-1790 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to [this](https://github.com/netobserv/flowlogs-pipeline/pull/674): >## Description > >Manage enrichment by extracting pod IPs from the annotation "k8s.v1.cni.cncf.io/network-status", which is used (at least) by multus > >This allows to correlate Pods with their IPs on secondary interfaces > > >## Dependencies > >https://github.com/netobserv/network-observability-operator/pull/732 for Mac enrichment > >## Checklist > >If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that. > >* [x] Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist. >* [x] Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix _(in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes)._ >* [ ] Does this PR require product documentation? > * [ ] If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs. >* [ ] Does this PR require a product release notes entry? > * [ ] If so, fill in "Release Note Text" in the JIRA. >* [ ] Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc. > * [ ] If so, make sure it is described in the JIRA ticket. >* QE requirements (check 1 from the list): > * [x] Standard QE validation, with pre-merge tests unless stated otherwise. > * [ ] Regression tests only (e.g. refactoring with no user-facing change). > * [ ] No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team). > Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=netobserv%2Fflowlogs-pipeline). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
openshift-ci-robot commented 1 month ago

@jotak: This pull request references NETOBSERV-1790 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to [this](https://github.com/netobserv/flowlogs-pipeline/pull/674): >## Description > >Manage enrichment by extracting pod IPs from the annotation "k8s.v1.cni.cncf.io/network-status", which is used (at least) by multus > >This allows to correlate Pods with their IPs on secondary interfaces > >### Breaking change > >The API for `add_kubernetes_infra` transform stage has been modified to directly use enriched name & namespace to figure out the layer, instead of doing an informer lookup by IP. The reason is informers can now index by MAC. > >To migrate, if `add_kubernetes_infra` rule was used such as: > >```yaml > kubernetes_infra: > inputs: > - SrcAddr > - DstAddr > output: K8S_FlowLayer >``` > >it must be changed such as: > >```yaml > kubernetes_infra: > namespaceNameFields: > - namespace: SrcK8S_Namespace > name: SrcK8S_Name > - namespace: DstK8S_Namespace > name: DstK8S_Name > output: K8S_FlowLayer >``` > >where SrcK8S_Namespace, SrcK8S_Name, DstK8S_Namespace and DstK8S_Name match the names of the corresponding enriched fields. > >## Dependencies > >https://github.com/netobserv/network-observability-operator/pull/732 for Mac enrichment > >## Checklist > >If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that. > >* [x] Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist. >* [x] Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix _(in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes)._ >* [ ] Does this PR require product documentation? > * [ ] If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs. >* [ ] Does this PR require a product release notes entry? > * [ ] If so, fill in "Release Note Text" in the JIRA. >* [ ] Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc. > * [ ] If so, make sure it is described in the JIRA ticket. >* QE requirements (check 1 from the list): > * [x] Standard QE validation, with pre-merge tests unless stated otherwise. > * [ ] Regression tests only (e.g. refactoring with no user-facing change). > * [ ] No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team). > Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=netobserv%2Fflowlogs-pipeline). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
msherif1234 commented 1 month ago

/ok-to-test

github-actions[bot] commented 1 month ago

New image: quay.io/netobserv/flowlogs-pipeline:f457772

It will expire after two weeks.

To deploy this build, run from the operator repo, assuming the operator is running:

USER=netobserv VERSION=f457772 make set-flp-image
memodi commented 1 month ago

/ok-to-test

github-actions[bot] commented 1 month ago

New image: quay.io/netobserv/flowlogs-pipeline:6e9178a

It will expire after two weeks.

To deploy this build, run from the operator repo, assuming the operator is running:

USER=netobserv VERSION=6e9178a make set-flp-image
memodi commented 1 month ago

it's working well to enrich traffic for secondary interfaces.

/label qe-approved

openshift-ci-robot commented 1 month ago

@jotak: This pull request references NETOBSERV-1790 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to [this](https://github.com/netobserv/flowlogs-pipeline/pull/674): >## Description > >Manage enrichment by extracting pod IPs from the annotation "k8s.v1.cni.cncf.io/network-status", which is used (at least) by multus > >This allows to correlate Pods with their IPs on secondary interfaces > >### Breaking change > >The API for `add_kubernetes_infra` transform stage has been modified to directly use enriched name & namespace to figure out the layer, instead of doing an informer lookup by IP. The reason is informers can now index by MAC. > >To migrate, if `add_kubernetes_infra` rule was used such as: > >```yaml > kubernetes_infra: > inputs: > - SrcAddr > - DstAddr > output: K8S_FlowLayer >``` > >it must be changed such as: > >```yaml > kubernetes_infra: > namespaceNameFields: > - namespace: SrcK8S_Namespace > name: SrcK8S_Name > - namespace: DstK8S_Namespace > name: DstK8S_Name > output: K8S_FlowLayer >``` > >where SrcK8S_Namespace, SrcK8S_Name, DstK8S_Namespace and DstK8S_Name match the names of the corresponding enriched fields. > >## Dependencies > >https://github.com/netobserv/network-observability-operator/pull/732 for Mac enrichment > >## Checklist > >If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that. > >* [x] Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist. >* [x] Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix _(in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes)._ >* [ ] Does this PR require product documentation? > * [ ] If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs. >* [ ] Does this PR require a product release notes entry? > * [ ] If so, fill in "Release Note Text" in the JIRA. >* [ ] Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc. > * [ ] If so, make sure it is described in the JIRA ticket. >* QE requirements (check 1 from the list): > * [x] Standard QE validation, with pre-merge tests unless stated otherwise. > * [ ] Regression tests only (e.g. refactoring with no user-facing change). > * [ ] No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team). > Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=netobserv%2Fflowlogs-pipeline). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
openshift-ci-robot commented 1 month ago

@jotak: This pull request references NETOBSERV-1790 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.18.0" version, but no target version was set.

In response to [this](https://github.com/netobserv/flowlogs-pipeline/pull/674): >## Description > >Manage enrichment by extracting pod IPs from the annotation "k8s.v1.cni.cncf.io/network-status", which is used (at least) by multus > >This allows to correlate Pods with their Mac / IPs on secondary interfaces > >### Breaking change > >The API for `add_kubernetes_infra` transform stage has been modified to directly use enriched name & namespace to figure out the layer, instead of doing an informer lookup by IP. The reason is informers can now index by MAC. > >To migrate, if `add_kubernetes_infra` rule was used such as: > >```yaml > kubernetes_infra: > inputs: > - SrcAddr > - DstAddr > output: K8S_FlowLayer >``` > >it must be changed such as: > >```yaml > kubernetes_infra: > namespaceNameFields: > - namespace: SrcK8S_Namespace > name: SrcK8S_Name > - namespace: DstK8S_Namespace > name: DstK8S_Name > output: K8S_FlowLayer >``` > >where SrcK8S_Namespace, SrcK8S_Name, DstK8S_Namespace and DstK8S_Name match the names of the corresponding enriched fields. > >## Dependencies > >https://github.com/netobserv/network-observability-operator/pull/732 for Mac enrichment > >## Checklist > >If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that. > >* [x] Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist. >* [x] Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix _(in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes)._ >* [ ] Does this PR require product documentation? > * [ ] If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs. >* [ ] Does this PR require a product release notes entry? > * [ ] If so, fill in "Release Note Text" in the JIRA. >* [ ] Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc. > * [ ] If so, make sure it is described in the JIRA ticket. >* QE requirements (check 1 from the list): > * [x] Standard QE validation, with pre-merge tests unless stated otherwise. > * [ ] Regression tests only (e.g. refactoring with no user-facing change). > * [ ] No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team). > Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=netobserv%2Fflowlogs-pipeline). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
msherif1234 commented 1 month ago

/lgtm

jotak commented 4 weeks ago

/approve

openshift-ci[bot] commented 4 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/netobserv/flowlogs-pipeline/blob/main/OWNERS)~~ [jotak] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment