summaryrefslogtreecommitdiffstats
path: root/setup/projects/adei/templates/60-adei.yml.j2
blob: 5e508bc9c3faf30af2f3bb37eda39b006deb404f (plain)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
apiVersion: v1
kind: Template
metadata:
  name: "adei"
  annotations:
    openshift.io/display-name: "Advanced Data Extraction Infrastructure"
    descriptions: "A complete ADEI deployment for a single setup"
    openshift.io/provider-display-name: "KIT"
    openshift.io/documentation-url: "http://adei.info"
    openshift.io/support-url: "http://adei.info"
    kaas/strategy: "manual"
labels:
  app: "adei"
objects:
{% for name, cfg in adei_frontends.items() %}
{%   if (cfg.enabled | default(true))  %}
{%     if (cfg.cron is defined)  %}
{%        set pod_type = "cron" %}
{%        set pull_policy = "IfNotPresent" %}
{%        set restart_policy = "OnFailure" %}
{#        set restart_policy = "Never" #}
{%     elif (cfg.node is defined)  %}
{%        set pod_type = "frontend" %}
{%        set pull_policy = "Always" %}
{%        set restart_policy = "Always" %}
{%     else %}
{%        set pod_type = cfg.type | default("cacher") %}
{%        set pull_policy = "Always" %}
{%        set restart_policy = "Always" %}
{%     endif %}
{%     if (cfg.node is defined)  %}
  - apiVersion: v1
    kind: Service
    metadata:
      name: "{{ cfg.name }}"
      labels:
        adei-type: "{{ pod_type }}"
        adei-name: "{{ name }}"
        adei-setup: "${setup}"
    spec:
      selector:
        name: "{{ cfg.name }}"
      ports:
        - name: "80"
          port: 80
          targetPort: 8080
  - apiVersion: v1
    kind: Route
    metadata:
      name: "{{ cfg.name }}"
      annotations:
        haproxy.router.openshift.io/timeout: "${haproxy_timeout}"
      labels:
        adei-type: "{{ pod_type }}"
        adei-name: "{{ name }}"
        adei-setup: "${setup}"
    spec:
      host: "{{ cfg.node }}"
      to:
        kind: Service
        name: "{{ cfg.name }}"
      port:
        targetPort: 8080
      tls:
        termination: edge
        insecureEdgeTerminationPolicy: Allow
{%     endif  %}
{%     if (cfg.cron is defined)  %}
  - apiVersion: batch/v2alpha1
    kind: CronJob
    metadata:
      name: "{{ cfg.name }}"
      labels:
        adei-type: "{{ pod_type }}"
        adei-name: "{{ name }}"
        adei-setup: "${setup}"
    spec:
      schedule: "{{ cfg.cron }}"
      concurrencyPolicy: "Forbid"
      startingDeadlineSeconds: "{{ cfg.start_tolerance | default(30) }}"
      successfulJobsHistoryLimit: "{{ adei_pod_history_limit }}"
      failedJobsHistoryLimit: "{{ adei_pod_history_limit }}"
      jobTemplate:
        spec:
            completions: "1"
            activeDeadlineSeconds: "{{ cfg.max_run_time | default(600) }}"
#            restartPolicy: "Never"
            template:
              metadata:
                annotations:
                  alpha.image.policy.openshift.io/resolve-names: "*"
{%     else %}
  - apiVersion: v1
    kind: DeploymentConfig
    metadata:
      name: "{{ cfg.name }}"
      labels:
        adei-type: "{{ pod_type }}"
        adei-name: "{{ name }}"
        adei-setup: "${setup}"
      annotations:
        kaas/replicas: "{{ cfg.replicas }}"
    spec:
            replicas: "{{ cfg.replicas }}"
            revisionHistoryLimit: "{{ adei_pod_history_limit }}"
            selector:
              name: "{{ cfg.name }}"
            strategy:
              type: Rolling
            triggers:
              - type: ConfigChange
              - type: ImageChange
                imageChangeParams:
                  automatic: true
                  from:
                    kind: "ImageStreamTag"
                    name: "{{ cfg.image | default('adei:latest') }}"
                  containerNames:
                    - "{{ cfg.name }}"
            template:
              metadata:
{%     endif  %}
                name: "{{ cfg.name }}"
                labels:
                  name: "{{ cfg.name }}"
                  adei-type: "{{ pod_type }}"
                  adei-name: "{{ name }}"
                  adei-setup: "${setup}"
              spec:
                restartPolicy: {{ restart_policy }}
{%       if (ands_default_node_selector is defined) and (ands_default_node_selector | length > 0) %}
                nodeSelector: {{ ands_default_node_selector | to_json }}
{%       endif %}
                volumes: {{ cfg.vols | to_json }}
{%       if (cfg.groups is defined) or (cfg.run_as is defined) %}
                securityContext:
{%         if (cfg.run_as is defined) %}
{%             set user_info = kaas_project_uids[cfg.run_as] | default({}) %}
                  runAsUser: {{ ('id' in user_info) | ternary(user_info.id, cfg.run_as) }}
{%         endif %}
{%       if (cfg.groups is defined) %}
{%         if (ands_openshift_gid_mode | default('')) == "RunAsAny" %}
{%             set group_info = kaas_project_gids[cfg.groups[0]] | default({}) %}
                  fsGroup: {{ ('id' in group_info) | ternary(group_info.id, cfg.groups[0]) }}
{%         endif %}
                  supplementalGroups:
{%           for group in cfg.groups %}
{%             set group_info = kaas_project_gids[group] | default({}) %}
                    - {{ ('id' in group_info) | ternary(group_info.id, group) }}
{%           endfor %}
{%         endif %}
{%       endif %}
                containers:
                  - name: "{{ cfg.name }}"
                    image: "{{ cfg.image | default('adei:latest') }}"
                    imagePullPolicy: {{ pull_policy }}
{%     if (cfg.node is defined)  %}
                    command: 
                      - /opt/scripts/run-apache.sh
                    ports:
                      - containerPort: 8080
{%     else %}
                    command: {{ cfg.cmd | to_json }} 
{%     endif %}
                    env: {{ cfg.env | to_json }}
                    volumeMounts: {{ cfg.mounts | to_json }}
{%     if cfg.resources is defined %}
                    resources:
{%       if cfg.resources.request is defined %}
{%         set res = cfg.resources.request %}
                      requests:
{%         if res.cpu %}
                        cpu: {{ res.cpu }}
{%         endif %}
{%         if res.cpu %}
                        memory: {{ res.mem }}
{%         endif %}
{%       endif %}
{%       if cfg.resources.limit is defined %}
{%         set res = cfg.resources.limit %}
                      limits:
{%         if res.cpu %}
                        cpu: {{ res.cpu }}
{%         endif %}
{%         if res.cpu %}
                        memory: {{ res.mem }}
{%         endif %}
{%       endif %}
{%     endif %}
{%     if (cfg.node is defined)  %}
                    livenessProbe:
                      timeoutSeconds: 1
                      periodSeconds: 300
                      initialDelaySeconds: 300
                      tcpSocket:
                        port: 8080
                    readinessProbe:
                      timeoutSeconds: 1
                      periodSeconds: 30
                      initialDelaySeconds: 5
                      httpGet:
                        path: /adei/probe.php
                        port: 8080
{%       endif %}
                    lifecycle:
{%       if (cfg.configure | default(false)) %}
                      postStart:
                        exec: 
                          command: 
                            - /docker-entrypoint.sh
                            - /opt/scripts/adei-branch.sh
{%       endif  %}
{%   endif %}
{% endfor %}

parameters:
  - name: setup
    value: "autogen"
    description: "ADEI setup"
  - name: data_group
    value: "{{ kaas_project_gids['adei_data'].id }}"
    description: "gid (numerical only) to access the ADEI external data"
  - name: data_volume
    value: "adei-data"
    description: "pvc providing access to the ADEI external data"
  - name: data_path
    value: "data"
    description: "Path to ADEI external data on the specified pvc"
  - name: forbid_data_writes
    value: "true"
    description: "Set to false to allow writes on the ADEI data volume"
  - name: haproxy_timeout
    value: "30s"
    description: "Maximum service duration. HTTP error is returned if ADEI does not provide data within this time"
  - name: continuous_caching
    value: "1"
    description: "Stop cachers if no work or poll the source continously"  
  - name: enable_logs
    value: "1"
    description: "Enable detailed ADEI logging (large volume)"
  - name: enable_debug
    value: "0"
    description: "Include debugging information in ADEI logs (huge volume)"
  - name: adei_replicas
    value: "2"
    description: "Number of frontend replics"
  - name: apache_servers
    value: "150"
  - name: sched_parallel
    value: "sources"
    description: "Basic unit of scheduling (servers or sources)"
  - name: cache_replicas
    value: "2"
    description: "Default number of backend caching replicas"
  - name: archive_replicas
    value: "1"
    description: "Number of backend replicas caching archived data"
  - name: cache_parallel
    value: "sources"
    description: "Type of caching parallelism by a cacher replica: (sources or groups)"
  - name: update_schedule
    value: "*/13 * * * *"
    description: "Schedule of caching group updates"
  - name: maintain_schedule
    value: "*/31 * * * *"
    description: "Schedule of maintain tasks"
  - name: clean_schedule
    value: "9 3 * * *"
    description: "Schedule of cleaning tasks"
  - name: "adei_revision"
    value: "last:1"
  - name: "maintainer"
    value: "Suren A. Chilingaryan <csa@suren.me>"