Skip to content

feat(k8s): pod exclusion list#1239

Merged
MR2011 merged 1 commit into
mainfrom
kanstantsinbuklis-sap/issue-1233/pod-exclusion-list
Jul 1, 2026
Merged

feat(k8s): pod exclusion list#1239
MR2011 merged 1 commit into
mainfrom
kanstantsinbuklis-sap/issue-1233/pod-exclusion-list

Conversation

@kanstantsinbuklis-sap

@kanstantsinbuklis-sap kanstantsinbuklis-sap commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

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)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

Added to documentation?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Copilot AI review requested due to automatic review settings June 29, 2026 10:04
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1233/pod-exclusion-list branch from 923f3c1 to 7b0f69f Compare June 29, 2026 10:05
@kanstantsinbuklis-sap kanstantsinbuklis-sap linked an issue Jun 29, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_pods to 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

  • NewAdvancedConfig reads path as a file, but in the Helm chart the ConfigMap is mounted as a directory containing config.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 thread scanner/k8s-assets/processor/config.go Outdated
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
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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>
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1233/pod-exclusion-list branch from 7b0f69f to a204261 Compare June 30, 2026 12:14
@MR2011 MR2011 merged commit 7d54f52 into main Jul 1, 2026
11 checks passed
@MR2011 MR2011 deleted the kanstantsinbuklis-sap/issue-1233/pod-exclusion-list branch July 1, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(k8s): pod exclusion list

3 participants