From aecb5ceeae2ace0b35f3a01f8fa9440b7b2d859c Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 26 Nov 2019 09:26:32 -0500 Subject: [PATCH] Add an example that demonstrates waiting for a sidecar to become Ready This example includes a sidecar that takes some time after it starts running to report as Ready, and a step that relies on the behavior of the sidecar being Ready, not just started. --- examples/taskruns/sidecar-ready.yaml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/taskruns/sidecar-ready.yaml diff --git a/examples/taskruns/sidecar-ready.yaml b/examples/taskruns/sidecar-ready.yaml new file mode 100644 index 00000000000..8c33ee10728 --- /dev/null +++ b/examples/taskruns/sidecar-ready.yaml @@ -0,0 +1,38 @@ +apiVersion: tekton.dev/v1alpha1 +kind: TaskRun +metadata: + generateName: sidecar-ready- +spec: + taskSpec: + sidecars: + - name: slow-sidecar + image: ubuntu + command: ['sleep', 'infinity'] + # The sidecar takes 5s to report as Ready, even after it starts. If the + # step runs as soon as the sidecar starts, it will fail because + # /shared/ready isn't available yet. + readinessProbe: + exec: + command: + - sh + - -c + - sleep 5 && touch /shared/ready + volumeMounts: + - name: shared + mountPath: /shared + + steps: + - name: check-ready + image: ubuntu + # The step will only succeed if the sidecar has written this file, which + # it does 5s after it starts, before it reports Ready. + command: ['cat', '/shared/ready'] + volumeMounts: + - name: shared + mountPath: /shared + + # Sidecars don't have /workspace mounted by default, so we have to define + # our own shared volume. + volumes: + - name: shared + emptyDir: {}