generated from Skatteetaten/vagrant-hashistack-template
-
Notifications
You must be signed in to change notification settings - Fork 13
/
presto_standalone.hcl
210 lines (201 loc) · 5.65 KB
/
presto_standalone.hcl
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
job "${nomad_job_name}" {
type = "service"
datacenters = "${datacenters}"
namespace = "${namespace}"
update {
max_parallel = 1
health_check = "checks"
min_healthy_time = "10s"
healthy_deadline = "12m"
progress_deadline = "15m"
%{ if use_canary }
canary = 1
auto_promote = true
auto_revert = true
%{ endif }
stagger = "30s"
}
group "standalone" {
count = 1
network {
mode = "bridge"
}
service {
name = "${service_name}"
port = 8080
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "${hivemetastore_service_name}"
local_bind_port = "${hivemetastore_port}"
}
upstreams {
destination_name = "${minio_service_name}"
local_bind_port = "${minio_port}"
}
}
}
}
check {
task = "server"
name = "presto-hive-availability"
type = "script"
command = "presto"
args = ["--execute", "SHOW TABLES IN hive.default"]
interval = "30s"
timeout = "15s"
}
check {
expose = true
name = "presto-info"
type = "http"
path = "/v1/info"
interval = "10s"
timeout = "2s"
}
}
task "waitfor-hive-metastore" {
restart {
attempts = 100
delay = "5s"
}
lifecycle {
hook = "prestart"
}
driver = "docker"
resources {
memory = 32
}
config {
image = "consul:1.8"
entrypoint = ["/bin/sh"]
args = ["-c", "jq </local/service.json -e '.[].Status|select(. == \"passing\")'"]
volumes = ["tmp/service.json:/local/service.json" ]
}
template {
destination = "tmp/service.json"
data = <<EOH
{{- service "${hivemetastore_service_name}" | toJSON -}}
EOH
}
}
task "waitfor-minio" {
restart {
attempts = 100
delay = "5s"
}
lifecycle {
hook = "prestart"
}
driver = "docker"
resources {
memory = 32
}
config {
image = "consul:1.8"
entrypoint = ["/bin/sh"]
args = ["-c", "jq </local/service.json -e '.[].Status|select(. == \"passing\")'"]
volumes = ["tmp/service.json:/local/service.json" ]
}
template {
destination = "tmp/service.json"
data = <<EOH
{{- service "${minio_service_name}" | toJSON -}}
EOH
}
}
task "server" {
driver = "docker"
%{ if local_docker_image }
artifact {
source = "s3::http://127.0.0.1:9000/dev/tmp/docker_image.tar"
options {
aws_access_key_id = "minioadmin"
aws_access_key_secret = "minioadmin"
}
}
config {
load = "docker_image.tar"
image = "docker_image:local"
%{ else }
config {
image = "${docker_image}"
%{ endif }
volumes = [
"local/presto/config.properties:/lib/presto/default/etc/config.properties",
"local/presto/catalog/hive.properties:/lib/presto/default/etc/catalog/hive.properties",
# JVM settings. Memory GC etc.
"local/presto/jvm.config:/lib/presto/default/etc/jvm.config",
# Mount for debug purposes
%{ if debug }"local/presto/log.properties:/lib/presto/default/etc/log.properties",%{ endif }
]
}
template {
data = <<EOH
MINIO_ACCESS_KEY = "${minio_access_key}"
MINIO_SECRET_KEY = "${minio_secret_key}"
EOH
destination = "secrets/.env"
env = true
}
// NB! If credentials set as env variable, during spin up of this container it could be sort of race condition and query `SELECT * FROM hive.default.iris;`
// could end up with exception: The AWS Access Key Id you provided does not exist in our records.
// Looks like, slow render of env variables (when one template depends on other template). Maybe because, all runs on local machine
template {
destination = "/local/presto/catalog/hive.properties"
data = <<EOH
connector.name=hive-hadoop2
hive.metastore.uri=thrift://{{ env "NOMAD_UPSTREAM_ADDR_${hivemetastore_service_name}" }}
hive.metastore-timeout=1m
hive.s3.aws-access-key=${minio_access_key}
hive.s3.aws-secret-key=${minio_secret_key}
hive.s3.endpoint=http://{{ env "NOMAD_UPSTREAM_ADDR_${minio_service_name}" }}
hive.s3.path-style-access=true
hive.s3.ssl.enabled=false
hive.s3.socket-timeout=15m
EOH
}
template {
destination = "local/presto/config.properties"
data = <<EOH
node-scheduler.include-coordinator=true
http-server.http.port=8080
discovery-server.enabled=true
discovery.uri=http://127.0.0.1:8080
EOH
} # Total memory allocation is subtracted by 256MB to keep something for the OS.
template {
data = <<EOF
-server
-Xmx{{ env "NOMAD_MEMORY_LIMIT" | parseInt | subtract 256 }}M
EOF
destination = "local/presto/jvm.config"
}
template {
data = <<EOF
#
# WARNING
# ^^^^^^^
# This configuration file is for development only and should NOT be used
# in production. For example configuration, see the Presto documentation.
#
io.prestosql=DEBUG
io.airlift=DEBUG
EOF
destination = "local/presto/log.properties"
}
template {
destination = "local/data/.additional-envs"
change_mode = "noop"
env = true
data = <<EOF
${envs}
EOF
}
resources {
memory = ${memory}
}
}
}
}