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
|
# File 'lib/pfab/templates/cron.rb', line 12
def job
{
apiVersion: "batch/v1",
kind: "CronJob",
metadata: {
name: "#{@data['deployed_name']}-#{@data['sha']}",
namespace: get_namespace,
labels: {
application: @data['application'],
"deployed-name" => @data['deployed_name'],
"application-type" => application_type,
"deploy-id" => deploy_id,
"tags.datadoghq.com/env": @data['env'],
"tags.datadoghq.com/service": @data['deployed_name'],
"tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
}
},
spec: {
schedule: get("schedule"),
successfulJobsHistoryLimit: 1,
failedJobsHistoryLimit: 1,
jobTemplate: {
metadata: {
name: "#{@data['deployed_name']}-#{@data['sha']}",
namespace: get_namespace,
labels: {
application: @data['application'],
"deployed-name" => @data['deployed_name'],
"application-type" => "cron",
},
},
spec: {
template: {
metadata: {
labels: {
application: @data['application'],
"deployed-name" => @data['deployed_name'],
"application-type" => "cron",
"tags.datadoghq.com/env": @data['env'],
"tags.datadoghq.com/service": @data['deployed_name'],
"tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
},
},
spec: {
serviceAccountName: get('serviceAccountName'),
containers: [
{
image: image_name,
name: @data['deployed_name'],
command: get_command,
env: env_vars,
envFrom: env_from,
resources: resources,
},
],
restartPolicy: "Never",
}.compact,
},
backoffLimit: 2,
},
},
},
}
end
|