This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
svc.yml
84 lines (83 loc) · 2.88 KB
/
svc.yml
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
80
81
82
83
84
name: {{FRAMEWORK_NAME}}
scheduler:
principal: {{FRAMEWORK_PRINCIPAL}}
user: {{FRAMEWORK_USER}}
pods:
hello:
count: {{HELLO_COUNT}}
placement: '{{{HELLO_PLACEMENT}}}'
rlimits:
RLIMIT_NOFILE:
soft: {{HELLO_RLIMIT_NOFILE_SOFT}}
hard: {{HELLO_RLIMIT_NOFILE_HARD}}
tasks:
server:
goal: RUNNING
cmd: env && echo hello >> hello-container-path/output && sleep $SLEEP_DURATION
cpus: {{HELLO_CPUS}}
memory: {{HELLO_MEM}}
volume:
path: hello-container-path
type: ROOT
size: {{HELLO_DISK}}
env:
SLEEP_DURATION: {{SLEEP_DURATION}}
health-check:
cmd: stat hello-container-path/output
interval: 5
grace-period: 30
delay: 0
timeout: 10
max-consecutive-failures: 3
labels: {{HELLO_LABELS}}
world:
count: {{WORLD_COUNT}}
allow-decommission: true
placement: '{{{WORLD_PLACEMENT}}}'
rlimits:
RLIMIT_NOFILE:
soft: {{WORLD_RLIMIT_NOFILE_SOFT}}
hard: {{WORLD_RLIMIT_NOFILE_HARD}}
tasks:
server:
goal: RUNNING
cmd: |
# for graceful shutdown
# trap SIGTERM and mock a cleanup timeframe
terminated () {
echo "$(date) received SIGTERM, zzz for 3 ..."
sleep 3
echo "$(date) ... all clean, peace out"
exit 0
}
trap terminated SIGTERM
echo "$(date) trapping SIGTERM, watch here for the signal..."
echo 'world1' >>world-container-path1/output &&
echo 'world2' >>world-container-path2/output &&
# instead of running for a short duration (equal to SLEEP_DURATION), run infinitely
# to allow for testing of SIGTERM..grace..SIGKILL
while true; do
sleep 0.1
done
cpus: {{WORLD_CPUS}}
memory: {{WORLD_MEM}}
volumes:
vol1:
path: world-container-path1
type: ROOT
size: {{WORLD_DISK}}
vol2:
path: world-container-path2
type: ROOT
size: {{WORLD_DISK}}
env:
SLEEP_DURATION: {{SLEEP_DURATION}}
readiness-check:
# wordcount (wc) will report an error if the file does not exist, which effectively is zero (0) bytes
# so send the error to /dev/null, BUT also zero-left-pad the variable BYTES to ensure that it is zero
# on empty for comparison sake.
cmd: BYTES="$(wc -c world-container-path2/output 2>/dev/null| awk '{print $1;}')" && [ 0$BYTES -gt 0 ]
interval: {{WORLD_READINESS_CHECK_INTERVAL}}
delay: {{WORLD_READINESS_CHECK_DELAY}}
timeout: {{WORLD_READINESS_CHECK_TIMEOUT}}
kill-grace-period: {{WORLD_KILL_GRACE_PERIOD}}