Skip to content

NETOBSERV-1248: shared k8s cache #681

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

Closed
wants to merge 2 commits into from
Closed

Conversation

jotak
Copy link
Member

@jotak jotak commented Jun 21, 2024

The goal is to allow deploying a dedicated FLP instance as just a k8s cache component, alongside with the "traditional" FLP deployments.
The k8s cache is a Kafka producer, and traditional instances are
consumers.

  • New FLP binary, k8s-cache, that just starts the informers and writes update events to
    Kafka
  • New optional config for kubernetes enrichment, allowing to read from
    kafka instead of using informers

cf #641

Operator PR: netobserv/network-observability-operator#684

Copy link

openshift-ci bot commented Jun 21, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link

openshift-ci bot commented Jun 21, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jotak. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jotak jotak force-pushed the poc-k8s-cache branch 2 times, most recently from 0f501fb to 0f0b00d Compare June 21, 2024 13:27
@jotak jotak changed the title Poc k8s cache NETOBSERV-1248: Poc k8s cache Jun 24, 2024
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jun 24, 2024

@jotak: This pull request references NETOBSERV-1248 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 spike to target the "4.17.0" version, but no target version was set.

In response to this:

Proof-of-concept that allows re-using the Kafka deployment for sharing transformed k8s meta-data from informers.

cf #641

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jun 24, 2024

@jotak: This pull request references NETOBSERV-1248 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 spike to target the "4.17.0" version, but no target version was set.

In response to this:

Proof-of-concept that allows re-using the Kafka deployment for sharing transformed k8s meta-data from informers.

cf #641

Operator PR: netobserv/network-observability-operator#684

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

The goal is to allow deploying a dedicated FLP instance as just a k8s cache component, alongside with the "traditional" FLP deployments.
The k8s cache is a Kafka producer, and traditional instances are
consumers.

- New FLP binary, k8s-cache, that just starts the informers and writes update events to
  Kafka
- New optional config for kubernetes enrichment, allowing to read from
  kafka instead of using informers
@jotak jotak changed the title NETOBSERV-1248: Poc k8s cache NETOBSERV-1248: shared k8s cache Jun 24, 2024
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jun 24, 2024

@jotak: This pull request references NETOBSERV-1248 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 spike to target the "4.17.0" version, but no target version was set.

In response to this:

The goal is to allow deploying a dedicated FLP instance as just a k8s cache component, alongside with the "traditional" FLP deployments.
The k8s cache is a Kafka producer, and traditional instances are
consumers.

  • New FLP binary, k8s-cache, that just starts the informers and writes update events to
    Kafka
  • New optional config for kubernetes enrichment, allowing to read from
    kafka instead of using informers

cf #641

Operator PR: netobserv/network-observability-operator#684

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jotak jotak marked this pull request as ready for review June 24, 2024 11:01
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 48.22695% with 219 lines in your changes missing coverage. Please review.

Project coverage is 63.97%. Comparing base (caf7ac2) to head (f91a734).
Report is 97 commits behind head on main.

Files with missing lines Patch % Lines
...peline/transform/kubernetes/informers/informers.go 18.46% 53 Missing ⚠️
...line/transform/kubernetes/datasource/datasource.go 50.70% 35 Missing ⚠️
cmd/k8s-cache/main.go 0.00% 32 Missing ⚠️
...ansform/kubernetes/informers/kafka_cache_writer.go 0.00% 30 Missing ⚠️
pkg/kafka/writer.go 52.27% 17 Missing and 4 partials ⚠️
pkg/kafka/reader.go 72.05% 14 Missing and 5 partials ⚠️
pkg/pipeline/transform/kubernetes/enrich.go 66.66% 10 Missing and 3 partials ⚠️
pkg/pipeline/transform/transform_network.go 16.66% 3 Missing and 2 partials ⚠️
pkg/pipeline/transform/kubernetes/model/model.go 69.23% 2 Missing and 2 partials ⚠️
...e/transform/kubernetes/informers/informers-mock.go 91.89% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #681      +/-   ##
==========================================
- Coverage   65.07%   63.97%   -1.11%     
==========================================
  Files         106      112       +6     
  Lines        6806     6984     +178     
==========================================
+ Hits         4429     4468      +39     
- Misses       2063     2193     +130     
- Partials      314      323       +9     
Flag Coverage Δ
unittests 63.97% <48.22%> (-1.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/api/transform_network.go 100.00% <ø> (ø)
pkg/pipeline/utils/exit.go 100.00% <100.00%> (ø)
pkg/pipeline/encode/encode_kafka.go 65.51% <50.00%> (+8.16%) ⬆️
pkg/pipeline/ingest/ingest_kafka.go 56.98% <83.33%> (-5.91%) ⬇️
...e/transform/kubernetes/informers/informers-mock.go 93.25% <91.89%> (-3.26%) ⬇️
pkg/pipeline/transform/kubernetes/model/model.go 69.23% <69.23%> (ø)
pkg/pipeline/transform/transform_network.go 66.44% <16.66%> (-1.37%) ⬇️
pkg/pipeline/transform/kubernetes/enrich.go 69.90% <66.66%> (-7.28%) ⬇️
pkg/kafka/reader.go 72.05% <72.05%> (ø)
pkg/kafka/writer.go 52.27% <52.27%> (ø)
... and 4 more

... and 1 file with indirect coverage changes

@jotak jotak added the no-qe This PR doesn't necessitate QE approval label Jun 24, 2024
jotak added a commit to jotak/flowlogs-pipeline that referenced this pull request Mar 3, 2025
Related: netobserv#681

This is a preliminary work preparing the ground for NETOBSERV-1248.
No functional change here.
The goal is to minimize rebase hassle in netobserv#681
jotak added a commit to jotak/flowlogs-pipeline that referenced this pull request Mar 3, 2025
Related: netobserv#681

This is a preliminary work preparing the ground for NETOBSERV-1248.
No functional change here.
The goal is to minimize rebase hassle in netobserv#681

Details:
- Kafka read/write logic extracted from ingest/encode pipelines and put
  into a dedicated kafka package
- New k8s "datasource" struct for k8s enrichment - currently only has
  the usual informers datasource, but later will include a kafka-based
datasource as well
- Config related to k8s datasource moved into its own package. It
  includes the SecondaryNetwork config.
- Some minor variables/functions renaming
Comment on lines 63 to 81
define build_target
echo 'building image for arch $(1)'; \
DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETPLATFORM=linux/$(1) --build-arg TARGETARCH=$(1) --build-arg BUILDPLATFORM=linux/amd64 ${OCI_BUILD_OPTS} -t ${IMAGE}-$(1) -f contrib/docker/Dockerfile .;
DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETPLATFORM=linux/$(1) --build-arg TARGETARCH=$(1) --build-arg BUILDPLATFORM=linux/amd64 ${OCI_BUILD_OPTS} -t ${IMAGE_CACHE}-$(1) -f contrib/docker/cache.Dockerfile .;
endef

# push a single arch target image
define push_target
echo 'pushing image ${IMAGE}-$(1)'; \
DOCKER_BUILDKIT=1 $(OCI_BIN) push ${IMAGE}-$(1);
DOCKER_BUILDKIT=1 $(OCI_BIN) push ${IMAGE_CACHE}-$(1);
endef

# manifest create a single arch target provided as argument
define manifest_add_target
echo 'manifest add target $(1)'; \
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest add ${IMAGE} ${IMAGE}-$(1);
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest add ${IMAGE_CACHE} ${IMAGE_CACHE}-$(1);
endef
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to have dedicated functions for cache case ?
It would avoid building both when you need only one 🤔

Copy link
Member Author

@jotak jotak Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I rewrote that differently in #848
I don't build a new image anymore, instead I include both binaries in the same image. It avoids having to refactor all the build process. It also makes it a little simpler in the operator.

@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

jotak added a commit that referenced this pull request Mar 4, 2025
Related: #681

This is a preliminary work preparing the ground for NETOBSERV-1248.
No functional change here.
The goal is to minimize rebase hassle in #681

Details:
- Kafka read/write logic extracted from ingest/encode pipelines and put
  into a dedicated kafka package
- New k8s "datasource" struct for k8s enrichment - currently only has
  the usual informers datasource, but later will include a kafka-based
datasource as well
- Config related to k8s datasource moved into its own package. It
  includes the SecondaryNetwork config.
- Some minor variables/functions renaming
@jotak
Copy link
Member Author

jotak commented Mar 4, 2025

Superseded by #848

@jotak jotak closed this Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference needs-rebase no-qe This PR doesn't necessitate QE approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants