From 264bcc413a27cbc079901748bc32c433d1c2c833 Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Tue, 17 Dec 2019 08:34:39 +0530 Subject: [PATCH] Reflect tektoncd/pipeline release version as an annotation on pod As a followup to https://github.com/tektoncd/pipeline/pull/1650 , the `tekton.dev/release` annotation is set on the pod to reflect the value of version.PipelineVersion Signed-off-by: Vibhav Bobade --- config/controller.yaml | 2 ++ pkg/pod/entrypoint.go | 1 + pkg/pod/pod.go | 9 ++++++++- tekton/publish.yaml | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config/controller.yaml b/config/controller.yaml index 6a3f8ba55fb..bcf7e9a8cc4 100644 --- a/config/controller.yaml +++ b/config/controller.yaml @@ -28,6 +28,8 @@ spec: metadata: annotations: cluster-autoscaler.kubernetes.io/safe-to-evict: "false" + # tekton.dev/release value replaced with inputs.params.versionTag in pipeline/tekton/publish.yaml + tekton.dev/release: "devel" labels: app: tekton-pipelines-controller app.kubernetes.io/name: tekton-pipelines diff --git a/pkg/pod/entrypoint.go b/pkg/pod/entrypoint.go index 20e286b1408..52090b8c6ea 100644 --- a/pkg/pod/entrypoint.go +++ b/pkg/pod/entrypoint.go @@ -19,6 +19,7 @@ package pod import ( "errors" "fmt" + "github.com/tektoncd/pipeline/pkg/version" "path/filepath" "strings" diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 0455968a9be..97d46bb8ada 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -18,6 +18,7 @@ package pod import ( "fmt" + "github.com/tektoncd/pipeline/pkg/version" "path/filepath" "github.com/tektoncd/pipeline/pkg/apis/pipeline" @@ -42,6 +43,9 @@ const ( // These are effectively const, but Go doesn't have such an annotation. var ( + releaseAnnotation = "tekton.dev/release" + releaseAnnotationValue = version.PipelineVersion + groupVersionKind = schema.GroupVersionKind{ Group: v1alpha1.SchemeGroupVersion.Group, Version: v1alpha1.SchemeGroupVersion.Version, @@ -179,6 +183,9 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha mergedPodContainers = append(mergedPodContainers, sc) } + podAnnotations := taskRun.Annotations + podAnnotations[releaseAnnotation] = releaseAnnotationValue + return &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ // We execute the build's pod in the same namespace as where the build was @@ -193,7 +200,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(taskRun, groupVersionKind), }, - Annotations: taskRun.Annotations, + Annotations: podAnnotations, Labels: makeLabels(taskRun), }, Spec: corev1.PodSpec{ diff --git a/tekton/publish.yaml b/tekton/publish.yaml index 771bf8a9632..66c9befd179 100644 --- a/tekton/publish.yaml +++ b/tekton/publish.yaml @@ -139,6 +139,9 @@ spec: ln -s ${TMPDIR}/source.tar.gz ${d}/kodata/ done + # Rewrite "devel" to inputs.params.versionTag + sed -i 's/devel/$(inputs.params.versionTag)/g' /workspace/go/src/github.com/tektoncd/pipeline/config/controller.yaml + # Publish images and create release.yaml ko resolve --preserve-import-paths -t $(inputs.params.versionTag) -f /workspace/go/src/github.com/tektoncd/pipeline/config/ > /workspace/output/bucket/latest/release.yaml volumeMounts: