feat(k8s): pod exclusion list#1239
Merged
Merged
Conversation
923f3c1 to
7b0f69f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configurable pod exclusion list to the k8s-assets scanner so specified pod groups are skipped and not reported to Heureka, with Helm and documentation support.
Changes:
- Add
excluded_podsto the advanced config and Helm chart template/values, and skip excluded pod groups during namespace processing. - Fix pod grouping for standalone pods so they don’t collapse into an empty generateName group.
- Add Ginkgo/Gomega tests for pod grouping and exclusion config parsing/matching.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scanner/k8s-assets/scanner/scanner.go | Adjust pod grouping to avoid empty keys when GenerateName is unset. |
| scanner/k8s-assets/scanner/scanner_test.go | Add unit tests for GroupPodsByGenerateName behavior across pod types. |
| scanner/k8s-assets/scanner/scanner_suite_test.go | Add Ginkgo test suite bootstrap for scanner package tests. |
| scanner/k8s-assets/README.md | Document advanced config and excluded_pods usage. |
| scanner/k8s-assets/processor/processor.go | Expose IsExcludedPod helper on Processor. |
| scanner/k8s-assets/processor/processor_test.go | Add tests for AdvancedConfig exclusion matching and YAML parsing. |
| scanner/k8s-assets/processor/config.go | Add excluded_pods to advanced config and matching logic. |
| scanner/k8s-assets/main.go | Skip excluded pod groups during processing. |
| scanner/k8s-assets/chart/k8s-assets-scanner/values.yaml | Add Helm value scanner.excluded_pods. |
| scanner/k8s-assets/chart/k8s-assets-scanner/templates/config/_scanner_config.yaml.tpl | Render excluded_pods into generated config YAML when set. |
Comments suppressed due to low confidence (1)
scanner/k8s-assets/processor/config.go:100
NewAdvancedConfigreadspathas a file, but in the Helm chart the ConfigMap is mounted as a directory containingconfig.yaml. Reading a directory here will error and make advanced config (including excluded pods) silently unusable.
b, err := os.ReadFile(path)
if err != nil {
// gracefully handle the case where the file does not exist and just return an empty Config
if os.IsNotExist(err) {
return cfg, nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+56
to
+60
| Additional behaviour is controlled via a YAML config file mounted at `CONFIG_PATH` (default: `/etc/config`). When deployed via Helm, this is populated from a ConfigMap. | ||
|
|
||
| ### Excluding pods | ||
|
|
||
| Pods whose `generateName` matches an entry in `excluded_pods` are silently skipped and never reported to Heureka. This is for infrastructure pods that should not appear as assets (e.g. `keep-image-pulled`). |
Comment on lines
+66
to
+76
| // ExcludedPodsSet returns a set of excluded pod name prefixes, lazy initialized from ExcludedPods. | ||
| func (c *AdvancedConfig) ExcludedPodsSet() map[string]struct{} { | ||
| if len(c.excludedPodsSet) == 0 && len(c.ExcludedPods) > 0 { | ||
| c.excludedPodsSet = make(map[string]struct{}, len(c.ExcludedPods)) | ||
| for _, name := range c.ExcludedPods { | ||
| c.excludedPodsSet[name] = struct{}{} | ||
| } | ||
| } | ||
|
|
||
| return c.excludedPodsSet | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Not sure that's the problem because sidecars have the same logic. If we didn't have problems with it, then it's not relevant
cc @MR2011
Signed-off-by: Kanstantsin Buklis <kanstantsin.buklis@sap.com>
7b0f69f to
a204261
Compare
MR2011
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In this PR I've added configuration for excluded pods won't be reported to Heureka
What type of PR is this? (check all applicable)
Related Tickets & Documents
Added tests?
Added to documentation?