This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
browser-job.yaml
225 lines (176 loc) · 4.7 KB
/
browser-job.yaml
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
211
212
213
214
215
216
217
218
219
220
221
222
223
apiVersion: batch/v1
kind: Job
activeDeadlineSeconds: 600
metadata:
name: "{{ job_name }}"
labels:
jobid: "{{ jobid }}"
{%- for name, value in labels.items() %}
{{ name }}: "{{ value }}"
{%- endfor %}
annotations:
{%- for name, value in annotations.items() %}
{{ name }}: "{{ value }}"
{%- endfor %}
spec:
backoffLimit: 2
{% if job_max_duration %}
activeDeadlineSeconds: {{ job_max_duration }}
{% endif %}
ttlSecondsAfterFinished: 120
template:
metadata:
labels:
jobid: "{{ jobid }}"
spec:
restartPolicy: "Never"
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "embedserver"
volumes:
- name: wacz
emptyDir: {}
- name: dshm
emptyDir:
medium: Memory
{% if mode != "headless" %}
- name: x11
emptyDir: {}
{% endif %}
{% if profile_url %}
- name: profile
emptyDir: {}
initContainers:
- name: init-profile
image: minio/mc
env:
- name: MC_HOST_profile
valueFrom:
secretKeyRef:
name: storage-auth
key: MC_HOST
command: ['/bin/sh']
args: ['-c', 'mc cp profile/{{ profile_url }} ./ && tar xvzf $(basename {{ profile_url }}) -C /profile && chown -R 1000:1000 /profile && echo "done"']
volumeMounts:
- name: profile
mountPath: '/profile'
{% endif %}
containers:
{% if mode != "headless" %}
- name: {{ mode }}
image: {{ vnc_image if mode == "vnc" else xvfb_image }}
imagePullPolicy: Always
volumeMounts:
- name: x11
mountPath: '/tmp/.X11-unix/'
- name: wacz
mountPath: '/tmp/out'
envFrom:
- configMapRef:
name: browser-config
env:
- name: VNC_PASS
value: "{{ annotations.vnc_pass }}"
- name: REQ_ID
value: "{{ jobid }}"
- name: NO_AUDIO
value: "1"
resources:
limits:
cpu: 100m
requests:
cpu: 25m
{% endif %}
# browser
# ==================================
- name: browser
image: {{ browser_image }}
imagePullPolicy: Always
envFrom:
- configMapRef:
name: browser-config
env:
- name: URL
value: "{{ start_url }}"
{% if use_proxy %}
- name: PROXY_HOST
value: "localhost"
{% endif %}
{% if mode == "headless" %}
- name: HEADLESS
value: "1"
{% else %}
- name: DISPLAY
value: ":99"
{% endif %}
securityContext:
capabilities: {'add': ['NET_ADMIN', 'SYS_ADMIN', 'SETUID']}
resources:
limits:
cpu: 500m
requests:
cpu: 100m
volumeMounts:
- name: wacz
mountPath: '/tmp/out'
- name: dshm
mountPath: '/dev/shm'
{% if mode != "headless" %}
- name: x11
mountPath: '/tmp/.X11-unix/'
{% endif %}
{% if profile_url %}
- name: profile
mountPath: "/tmp/profile"
#mountPath: '/home/browser/.config/google-chrome'
{% endif %}
{% if use_proxy %}
# pywb
# ==================================
- name: pywb
image: webrecorder/browserkube-pywb
imagePullPolicy: Always
env:
- name: INIT_COLLECTION
value: "capture"
resources:
limits:
cpu: 200m
requests:
cpu: 100m
volumeMounts:
- name: wacz
mountPath: '/tmp/out'
{% endif %}
{% if driver_image %}
# driver
# ==================================
- name: driver
image: {{ driver_image }}
imagePullPolicy: Always
resources:
limits:
cpu: 100m
requests:
cpu: 25m
volumeMounts:
- name: wacz
mountPath: '/tmp/out'
envFrom:
{%- if storage_prefix %}
- secretRef:
name: storage-auth
{% endif %}
- configMapRef:
name: browser-config
env:
{%- for name, value in driver_env.items() %}
- name: {{ name }}
value: "{{ value }}"
{%- endfor %}
{% if use_proxy %}
- name: PROXY_HOST
value: "localhost"
{% endif %}
{% endif %}