Skip to content

Add cluster_labels and annotations to logical backup CronJob and Jobs#3085

Open
raphaeltorquat0 wants to merge 1 commit intozalando:masterfrom
raphaeltorquat0:fix/cronjob-cluster-labels
Open

Add cluster_labels and annotations to logical backup CronJob and Jobs#3085
raphaeltorquat0 wants to merge 1 commit intozalando:masterfrom
raphaeltorquat0:fix/cronjob-cluster-labels

Conversation

@raphaeltorquat0
Copy link
Copy Markdown

What this PR does

When using the logical backup feature, the CronJob and its created Jobs were missing the cluster_labels and annotations that are applied to other cluster resources like Pods, StatefulSets, and Services.

This made it difficult to filter or identify backup jobs using the same labels as other cluster components.

Fixes #1834

Changes

  • Added ObjectMeta with labels and annotations to JobTemplateSpec, so Jobs created by the CronJob inherit the cluster labels
  • Updated CronJob ObjectMeta to use the merged labels (including application: spilo-logical-backup)
  • Updated tests to expect the new labels

Example

Before this fix, a logical backup CronJob would only have:

labels:
  cluster-name: my-cluster
  team: myteam

After this fix:

labels:
  application: spilo-logical-backup
  cluster-name: my-cluster
  team: myteam
  app.kubernetes.io/name: db-postgres  # custom cluster_label

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Note: parts of this implementation were developed with AI assistance.

When using the logical backup feature, the CronJob and its created Jobs
were missing the cluster_labels and annotations that are applied to
other cluster resources. This made it difficult to filter or identify
backup jobs using the same labels as other cluster components.

Changes:
- Added ObjectMeta with labels and annotations to JobTemplateSpec
- Updated CronJob ObjectMeta to use the merged labels (including
  'application: spilo-logical-backup')
- Updated tests to expect the new labels

Fixes zalando#1834
@raphaeltorquat0
Copy link
Copy Markdown
Author

Hi! Could a maintainer please add the bugfix label to this PR? Thank you!

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.

Set cluster_labels for template CronJob

1 participant