Closed davidc-donorschoose closed 6 years ago
Hi @davidc-donorschoose
Thanks for opening this issue. Having the same behavior than CronJob
seems legit for me too.
We will be more than happy to have your contribution for this enhancement.
Let me know or @sdminonne if you have any questions.
Thanks
SGTM too, happy to review a PR or to fix it. Thanks!
Pull request #68 contains my implementation.
Close this issue since pull request #68 has been merged.
The
jobTemplate.spec.template.metadata.labels
in thesteps
of a Workflow manifest only becomemetadata.labels
for the Pods that are created, not for the Jobs. When the samejobTemplate
is used for a CronJob, they appear for both Pods and the Jobs.The CronJob behavior seems correct to me. Having the labels appear on both Pods and Jobs is very useful for monitoring tools. I would like to use an
app
label on my Workflow steps to filter monitoring metrics in tools such as Prometheus (or DataDog, etc). It is possible to drill down to Pod metrics by theapp
label, since kube-state-metrics creates akube_pod_labels
that can be joined to metrics such askube_pod_status_ready
(matching by thepod
and/ornamespace
name). It is not currently possible to drill down to Job metrics with myapp
label: although there is akube_job_labels
that can be joined to metrics such askube_job_status_active
, there is nolabel_app
field for Workflow because there is noapp
label on the Job. (On the other hand, this does work for CronJob).It's possible that the
controller_util.go
source file intended to do what I need in its func getJobLabelsSet. There is a loop to copyrange template.Labels
into thedesiredLabels
for the Job, but the code seems to be a no-op (a silent failure). I don't think thattemplate.Labels
is parsed from the Workflow manifest by low-level code. (1) I don't see it in the spec. (2) I've triedjobTemplate.labels
,jobTemplate.spec.labels
,jobTemplate.spec.template.labels
, andjobTemplate.spec.template.metadata.labels
in my Workflow manifests. None appear on the Jobs.The latter (
jobTemplate.spec.template.metadata.labels
) do appear as Pod labels with both Workflow and CronJob, but they only appear as Job labels with CronJob. Iffunc getJobLabelsSet
were to use a different variable reference (perhapsrange template.template.metadata.labels
), I believe it would do what I need - apply the labels to Jobs as well as Pods. If you are interested in this enhancement, I can send a pull request when I get it to work.