-
Notifications
You must be signed in to change notification settings - Fork 1
/
terraform_example.tf
177 lines (173 loc) · 5.37 KB
/
terraform_example.tf
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Configure config file
resource "kubernetes_secret_v1" "Your_secret_name" {
metadata {
name = "backup-secret"
namespace = "namespace"
}
data = {
"key.pub.pem" = "Crypt4gh public key from vault",
"key.sec.pem," = "Crypt4gh private key from vault",
"config.yaml" = yamlencode({
# configuring path to where keys will be mounted
"crypt4ghPublicKey" : "/.secrets/keys/key.pub.pem",
"crypt4ghPrivateKey" :"/.secrets/keys/key.sec.pem",
"crypt4ghPassphrase" : "your passphrase"
"loglevel": "debug",
"db" : {
"host" : "IP address of DB or name",
"user" : "postgres",
"password" : "password",
"database" : "postgres",
"sslmode" : "disable",
"cacert": "path/to/ca-root",
"clientcert": "path/to/clientcert", #only needed if sslmode = verify-peer
"clientkey": "path/to/clientkey" #only needed if sslmode = verify-peer
"sslmode": "verify-peer"
},
"s3" : {
"url": "FQDN URI" #https://s3.example.com
#"port": "9000" #only needed if the port difers from the standard HTTP/HTTPS ports
"accesskey": "accesskey"
"secretkey": "secret-accesskey"
"bucket": "bucket-name"
#"cacert": "path/to/ca-root"
},
"elastic":{
"host": "FQDN URI" # https://es.example.com
#port: 9200 # only needed if the port difers from the standard HTTP/HTTPS ports
"user": "elastic-user"
"password": "elastic-password"
#cacert: "path/to/ca-root"
"batchSize": "50" # How many documents to retrieve from elastic search at a time, default 50 (should probably be at least 2000
"filePrefix": "" # Can be emtpy string, useful in case an index has been written to and you want to backup a new copy
},
"mongo":{
"host": "hostname or IP with portnuber" #example.com:portnumber, 127.0.0.1:27017
"user": "backup"
"password": "backup"
"authSource": "admin"
"replicaset": ""
#"tls": "true"
#"cacert": "path/to/ca-root" #optional
#"clientcert": "path/to/clientcert" # needed if tls=true
}
})
}
}
resource "kubernetes_cron_job" "Your_cronjob_name" {
metadata {
name = "Your_cronjob_name"
namespace = "Your_namespace_name"
}
spec {
concurrency_policy = "Forbid"
schedule = "0 0 1 * *"
starting_deadline_seconds = 3600
job_template {
metadata {
name = "Your_cronjob_name"
}
spec {
backoff_limit = 2
ttl_seconds_after_finished = 120
template {
metadata {
labels = {
jobs = "backup"
}
}
spec {
container {
name = "Container_name"
image = "ghcr.io/nbisweden/sda-services-backup"
command = ["/usr/local/bin/backup-svc", "--action", "pg_dump"]
env {
name = "CONFIGFILE"
value = "/.secrets/config.yaml"
}
resources {
limits = {
cpu = "100m"
memory = "128M"
}
requests = {
cpu = "100m"
memory = "128M"
}
}
security_context {
allow_privilege_escalation = "false"
read_only_root_filesystem = "true"
capabilities {
drop = [ "ALL" ]
}
}
volume_mount {
name = "tmp"
mount_path = "/tmp"
}
volume_mount {
name = "tls-certs"
mount_path = "/.secrets/tls"
}
# Mounting config file declared above
volume_mount {
name = "name"
mount_path = "/.secrets/config.yaml"
sub_path = "config.yaml"
}
# Crytp4gh public key
volume_mount {
name = "name"
mount_path = "/.secrets/keys/key.pub.pem"
sub_path = "key.pub.pem"
}
# Crytp4gh private key
volume_mount {
name = "name"
mount_path = "/.secrets/keys/key.sec.pem"
sub_path = "key.sec.pem"
}
}
security_context {
fs_group = 1000
run_as_user = 1000
run_as_group = 1000
seccomp_profile {
type = "RuntimeDefault"
}
}
volume {
name = "tmp"
empty_dir {
size_limit = "1Gi"
}
}
volume {
name = "cronjob"
projected {
default_mode = "0400"
sources {
secret {
name = kubernetes_secret_v1.Your_secret_name.metadata[0].name
}
}
}
}
volume {
name = "tls-certs"
projected {
default_mode = "0400"
sources {
secret {
name = "your_certs"
}
}
}
}
}
}
}
}
}
}