From a2abd0d8669ade7124bbcb95b8f095da27f5e805 Mon Sep 17 00:00:00 2001 From: mosesyou Date: Thu, 12 Nov 2020 11:38:34 +0800 Subject: [PATCH 1/2] add ScaledJob's label to its job Signed-off-by: mosesyou --- pkg/scaling/executor/scale_jobs.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/scaling/executor/scale_jobs.go b/pkg/scaling/executor/scale_jobs.go index 81eac699629..6b976973ff3 100644 --- a/pkg/scaling/executor/scale_jobs.go +++ b/pkg/scaling/executor/scale_jobs.go @@ -63,18 +63,23 @@ func (e *scaleExecutor) createJobs(logger logr.Logger, scaledJob *kedav1alpha1.S } logger.Info("Creating jobs", "Number of jobs", scaleTo) + labels := map[string]string{ + "app.kubernetes.io/name": scaledJob.GetName(), + "app.kubernetes.io/version": version.Version, + "app.kubernetes.io/part-of": scaledJob.GetName(), + "app.kubernetes.io/managed-by": "keda-operator", + "scaledjob": scaledJob.GetName(), + } + for key, value := range scaledJob.ObjectMeta.Labels { + labels[key] = value + } + for i := 0; i < int(scaleTo); i++ { job := &batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ GenerateName: scaledJob.GetName() + "-", Namespace: scaledJob.GetNamespace(), - Labels: map[string]string{ - "app.kubernetes.io/name": scaledJob.GetName(), - "app.kubernetes.io/version": version.Version, - "app.kubernetes.io/part-of": scaledJob.GetName(), - "app.kubernetes.io/managed-by": "keda-operator", - "scaledjob": scaledJob.GetName(), - }, + Labels: labels, }, Spec: *scaledJob.Spec.JobTargetRef.DeepCopy(), } From 3fab5e439e2c3f08ba0148779e043f212cc2010c Mon Sep 17 00:00:00 2001 From: mosesyou Date: Mon, 16 Nov 2020 15:27:21 +0800 Subject: [PATCH 2/2] Changelog: Add ScaledJob's label to its job Signed-off-by: mosesyou --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c58175825c..09e2c8de845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ ### Improvements +- Support add ScaledJob's label to its job ([#1311](https://github.com/kedacore/keda/issues/1311)) + ### Breaking Changes ### Other