-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathextra-volume-mounts-sidecar.yaml
More file actions
79 lines (77 loc) · 3.25 KB
/
Copy pathextra-volume-mounts-sidecar.yaml
File metadata and controls
79 lines (77 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
agents:
queue: "{{.queue}}"
steps:
- label: ":k8s: Write file to extraVolumeMount on sidecar containers"
key: write-file-to-extra-volume-mount-sidecar
plugins:
- kubernetes:
sidecars:
- image: alpine:latest
volumeMounts:
- name: host-volume
mountPath: /tmp/extra-volume-mount
subPath: extra-volume-mount
- name: host-volume
mountPath: /tmp/extra-volume-mount-sidecar
subPath: extra-volume-mount-sidecar
command: ["sh"]
args:
- "-c"
- |-
touch /tmp/extra-volume-mount-sidecar/pass-the-parcel
rm -f "/tmp/extra-volume-mount/pass-the-parcel"
mv /tmp/extra-volume-mount-sidecar/pass-the-parcel /tmp/extra-volume-mount/pass-the-parcel
ls -lah /tmp/extra-volume-mount-sidecar
ls -lah /tmp/extra-volume-mount
# So Kubernetes can mark this as Started
# In reality a sidecar should not be used like this.
# As this is effectively an ad-hoc initContainer.
sleep infinity
podSpec:
containers:
- image: alpine:latest
volumeMounts:
- name: host-volume-duplicate
mountPath: /tmp/extra-volume-mount
subPath: extra-volume-mount
- name: host-volume-duplicate
mountPath: /tmp/extra-volume-mount-sidecar
subPath: extra-volume-mount-sidecar
command:
- |-
COUNT=0
until [[ $$((COUNT++)) == 15 ]]; do
[[ -f "/tmp/extra-volume-mount/pass-the-parcel" ]] && break
echo "⚠️ Waiting for my package to be delivered..."
sleep 1
done
if ! [[ -f "/tmp/extra-volume-mount/pass-the-parcel" ]]; then
echo "⛔ My package has not been delivered!"
exit 1
fi
echo "✅ My package has been delivered!"
rm -f "/tmp/extra-volume-mount/pass-the-parcel"
volumes:
- name: host-volume
hostPath:
path: "/tmp/volumes/{{.queue}}"
type: DirectoryOrCreate
- name: host-volume-duplicate
hostPath:
path: "/tmp/volumes/{{.queue}}"
type: DirectoryOrCreate
sidecarParams:
extraVolumeMounts:
- name: host-volume
mountPath: /tmp/extra-volume-mount-sidecar
subPath: extra-volume-mount-sidecar
- name: host-volume-duplicate
mountPath: /tmp/extra-volume-mount-sidecar
subPath: extra-volume-mount-sidecar
extraVolumeMounts:
- name: host-volume
mountPath: /tmp/extra-volume-mount
subPath: extra-volume-mount
- name: host-volume-duplicate
mountPath: /tmp/extra-volume-mount
subPath: extra-volume-mount