Skip to content

Commit

Permalink
Reflect tektoncd/pipeline release version as an annotation on pod
Browse files Browse the repository at this point in the history
As a followup to #1650 ,
the `tekton.dev/release` annotation is set on the pod to reflect
the value of version.PipelineVersion

Signed-off-by: Vibhav Bobade <[email protected]>
  • Loading branch information
waveywaves committed Dec 20, 2019
1 parent 0f20c35 commit 26ea656
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion pkg/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/names"
"github.com/tektoncd/pipeline/pkg/version"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand Down
4 changes: 3 additions & 1 deletion pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ func TestMakePod(t *testing.T) {
Image: "sidecar-image",
}},
},
wantAnnotations: map[string]string{},
wantAnnotations: map[string]string{
"tekton.dev/release": "devel",
},
want: &corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyNever,
InitContainers: []corev1.Container{placeToolsInit},
Expand Down
3 changes: 3 additions & 0 deletions tekton/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 26ea656

Please sign in to comment.