From 326da2d2747e61f89b627cbde68e2b1d29ea65e3 Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Mon, 18 Mar 2019 09:15:46 +0100 Subject: [PATCH] Propagate the labels form the build on the pod (#559) * Propagate the labels from the build to the pod This allows users to specify custom labels. * Fix typo in comment --- pkg/reconciler/build/resources/pod.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/reconciler/build/resources/pod.go b/pkg/reconciler/build/resources/pod.go index 58401544..588e5858 100644 --- a/pkg/reconciler/build/resources/pod.go +++ b/pkg/reconciler/build/resources/pod.go @@ -259,6 +259,14 @@ func MakePod(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po } annotations["sidecar.istio.io/inject"] = "false" + // Copy labels on the build through to the underlying pod to allow users + // to specify pod labels. + labels := map[string]string{} + for key, val := range build.Labels { + labels[key] = val + } + labels[buildNameLabelKey] = build.Name + cred, secrets, err := makeCredentialInitializer(build, kubeclient) if err != nil { return nil, err @@ -364,9 +372,7 @@ func MakePod(build *v1alpha1.Build, kubeclient kubernetes.Interface) (*corev1.Po }), }, Annotations: annotations, - Labels: map[string]string{ - buildNameLabelKey: build.Name, - }, + Labels: labels, }, Spec: corev1.PodSpec{ // If the build fails, don't restart it.