Skip to content

Add and use pod labels to avoid having to query all pods from kubernetes#481

Draft
otrosien wants to merge 14 commits intomasterfrom
pod-labels
Draft

Add and use pod labels to avoid having to query all pods from kubernetes#481
otrosien wants to merge 14 commits intomasterfrom
pod-labels

Conversation

@otrosien
Copy link
Member

@otrosien otrosien commented Jun 20, 2025

One-line summary

Implements pod labeling optimization for Kubernetes Elasticsearch operator to avoid querying all pods.

Issues

Key Changes:

  • Added migration logic in setupInformers() to ensure all existing EDS pods have the es-operator-dataset label
  • Modified collectResources() to use label selectors when fetching pods for each EDS
  • Updated templateInjectLabels() to always set labels (removed conditional check)
  • Added comprehensive logging and annotation-based migration tracking
  • Created E2E test to verify pod label migration functionality
  • Introduced new annotation es-operator.zalando.org/pod-label-migration-complete to track migration status

Impact:

  • Core change to pod discovery mechanism that could affect all EDS resources
  • Migration runs on every operator startup (with annotation-based skip logic)
  • Performance improvement expected from targeted pod queries vs. listing all pods

Types of Changes

  • New feature (non-breaking change which adds functionality)

Review

List of tasks the reviewer must do to review the PR

  • Tests
  • Documentation
  • CHANGELOG

Deployment Notes

  • Document migration steps

@zalando-compr-opensource
Copy link

invalid team ID

The team ID in your .zappr.yaml file does not appear to be valid. Please, fix
this before team ID checks will be added back into ComPR's specification check.

You can follow this guideline for help.

@otrosien otrosien added the major Major feature changes or updates, e.g. feature rollout to a new country, new API calls. label Nov 2, 2025
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
In `isPodOwnedByEDS()`, a new `context.Background()` is created instead of using the passed context. This bypasses cancellation propagation and could lead to hanging operations if the operator is shutting down during migration. Use the parent context throughout the call chain.

Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
Signed-off-by: Oliver Trosien <oliver.trosien@zalando.de>
@zalando-robot
Copy link

Deployment Checklist

This change falls under the deployment policy.

💁 Since Nov 10th, we are in the RED deployment zone. This means all changes released to production must adhere to the following requirements:

  • Detailed release notes are provided in this PR’s description.
  • Thorough load-testing has been performed, and is documented in the description/comment.
  • You can enable/disable the change via feature toggles, and have confirmed these toggles work as expected.
  • Technical review: A Principal Engineer, Engineering Manager or Head of Engineering have green-lit your changes, and the reviewer is named in the description/comments.
  • Application Owner (Director+) approval is given about the PR, and the approver is named in the description/comments.

👉 Regardless of which boxes you click in this comment, merge/deployment will not be blocked.
Reports about deployment policy adherence will be circulated daily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Major feature changes or updates, e.g. feature rollout to a new country, new API calls.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add and use pod labels to avoid having to query all pods from kubernetes

2 participants