summaryrefslogtreecommitdiffstats
path: root/setup
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-02-23 18:49:34 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-02-23 18:49:34 +0100
commit0caad1cc2ddd16ef41a7fe870640207d69e21046 (patch)
tree12eb16ddb8c55d501e658d16ca92c93cfd597edd /setup
parentca5b5b005d2ca454015f8b0faa54372c60a0e40a (diff)
downloadands-0caad1cc2ddd16ef41a7fe870640207d69e21046.tar.gz
ands-0caad1cc2ddd16ef41a7fe870640207d69e21046.tar.bz2
ands-0caad1cc2ddd16ef41a7fe870640207d69e21046.tar.xz
ands-0caad1cc2ddd16ef41a7fe870640207d69e21046.zip
ADEI cron jobs
Diffstat (limited to 'setup')
-rw-r--r--setup/projects/adei/templates/60-adei.yml.j2202
-rw-r--r--setup/projects/adei/vars/globals.yml38
2 files changed, 161 insertions, 79 deletions
diff --git a/setup/projects/adei/templates/60-adei.yml.j2 b/setup/projects/adei/templates/60-adei.yml.j2
index 991fc8d..88bfa89 100644
--- a/setup/projects/adei/templates/60-adei.yml.j2
+++ b/setup/projects/adei/templates/60-adei.yml.j2
@@ -13,6 +13,21 @@ labels:
objects:
{% for name, cfg in adei_frontends.iteritems() %}
{% 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 = "cacher" %}
+{% set pull_policy = "Always" %}
+{% set restart_policy = "Always" %}
+{% endif %}
+{% if (cfg.node is defined) %}
- apiVersion: v1
kind: Service
metadata:
@@ -38,90 +53,118 @@ objects:
tls:
termination: edge
insecureEdgeTerminationPolicy: Allow
+{% endif %}
+{% if (cfg.cron is defined) %}
+ - apiVersion: batch/v2alpha1
+ kind: CronJob
+ metadata:
+ name: "{{ cfg.name }}"
+ spec:
+ schedule: "{{ cfg.cron }}"
+ concurrencyPolicy: "Forbid"
+ jobTemplate:
+ spec:
+ completions: "1"
+ activeDeadlineSeconds: "3600"
+# restartPolicy: "Never"
+ template:
+ metadata:
+ annotations:
+ alpha.image.policy.openshift.io/resolve-names: "*"
+{% else %}
- apiVersion: v1
kind: DeploymentConfig
metadata:
name: "{{ cfg.name }}"
spec:
- replicas: "{{ cfg.replicas }}"
- revisionHistoryLimit: 2
- selector:
- name: "{{ cfg.name }}"
- strategy:
- type: Rolling
- triggers:
- - type: ConfigChange
- - type: ImageChange
- imageChangeParams:
- automatic: true
- from:
- kind: "ImageStreamTag"
- name: "adei:latest"
- containerNames:
- - "{{ cfg.name }}"
- template:
- metadata:
- name: "{{ cfg.name }}"
- labels:
- type: "adei"
- name: "{{ cfg.name }}"
- adei-type: "{{ name }}"
- adei-setup: "${setup}"
- spec:
- volumes: {{ cfg.vols | to_json }}
-{% if (cfg.groups is defined) or (cfg.run_as is defined) %}
- securityContext:
-{% if (cfg.run_as is defined) %}
-{% if (kaas_project_config.uids | default(kaas_openshift_uids))[cfg.run_as] is defined %}
- - {{ (kaas_project_config.uids | default(kaas_openshift_uids))[cfg.run_as].id }}
-{% else %}
- - {{ cfg.run_as }}
-{% endif %}
-{% endif %}
+ replicas: "{{ cfg.replicas }}"
+ revisionHistoryLimit: 2
+ selector:
+ name: "{{ cfg.name }}"
+ strategy:
+ type: Rolling
+ triggers:
+ - type: ConfigChange
+ - type: ImageChange
+ imageChangeParams:
+ automatic: true
+ from:
+ kind: "ImageStreamTag"
+ name: "adei:latest"
+ containerNames:
+ - "{{ cfg.name }}"
+ template:
+ metadata:
+{% endif %}
+ name: "{{ cfg.name }}"
+ labels:
+ app: "adei"
+ name: "{{ cfg.name }}"
+ adei-type: "{{ pod_type }}"
+ adei-name: "{{ name }}"
+ adei-setup: "${setup}"
+ spec:
+ restartPolicy: {{ restart_policy }}
+ volumes: {{ cfg.vols | to_json }}
+{% if (cfg.groups is defined) or (cfg.run_as is defined) %}
+ securityContext:
+{% if (cfg.run_as is defined) %}
+{% if (kaas_project_config.uids | default(kaas_openshift_uids))[cfg.run_as] is defined %}
+ - {{ (kaas_project_config.uids | default(kaas_openshift_uids))[cfg.run_as].id }}
+{% else %}
+ - {{ cfg.run_as }}
+{% endif %}
+{% endif %}
{% if (cfg.groups is defined) %}
- supplementalGroups:
-{% for group in cfg.groups %}
-{% if (kaas_project_config.gids | default(kaas_openshift_gids))[group] is defined %}
- - {{ (kaas_project_config.gids | default(kaas_openshift_gids))[group].id }}
-{% else %}
- - {{ group }}
-{% endif %}
-{% endfor %}
+ supplementalGroups:
+{% for group in cfg.groups %}
+{% if (kaas_project_config.gids | default(kaas_openshift_gids))[group] is defined %}
+ - {{ (kaas_project_config.gids | default(kaas_openshift_gids))[group].id }}
+{% else %}
+ - {{ group }}
+{% endif %}
+{% endfor %}
+{% endif %}
{% endif %}
-{% endif %}
- containers:
- - name: "{{ cfg.name }}"
- image: adei
- imagePullPolicy: Always
- command:
- - /opt/scripts/run-apache.sh
- ports:
- - containerPort: 8080
- env: {{ cfg.env | to_json }}
- volumeMounts: {{ cfg.mounts | to_json }}
- livenessProbe:
- timeoutSeconds: 1
- periodSeconds: 300
- initialDelaySeconds: 300
- httpGet:
- path: /adei/probe.php
- port: 8080
- readinessProbe:
- timeoutSeconds: 1
- periodSeconds: 10
- initialDelaySeconds: 10
- httpGet:
- path: /adei/probe.php
- port: 8080
- lifecycle:
-{% if (cfg.configure | default(false)) %}
- postStart:
- exec:
+ containers:
+ - name: "{{ cfg.name }}"
+ image: adei
+ imagePullPolicy: {{ pull_policy }}
+{% if (cfg.node is defined) %}
command:
- - /docker-entrypoint.sh
- - /opt/scripts/adei-branch.sh
-{% endif %}
+ - /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.node is defined) %}
+ livenessProbe:
+ timeoutSeconds: 1
+ periodSeconds: 300
+ initialDelaySeconds: 300
+ httpGet:
+ path: /adei/probe.php
+ port: 8080
+ readinessProbe:
+ timeoutSeconds: 1
+ periodSeconds: 10
+ initialDelaySeconds: 10
+ 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:
@@ -136,6 +179,15 @@ parameters:
description: "Default number of backend caching replicas"
- name: apache_servers
value: "150"
+ - name: adei_schedule_cache
+ value: "*/5 * * * *"
+ description: "Schedule of caching group updates"
+ - name: adei_schedule_maintain
+ value: "*/15 * * * *"
+ description: "Schedule of maintain tasks"
+ - name: adei_schedule_clean
+ value: "9 3 * * *"
+ description: "Schedule of cleaning tasks"
- name: cache_parallel
value: "source"
description: "Type of caching parallelism: group, source, server"
diff --git a/setup/projects/adei/vars/globals.yml b/setup/projects/adei/vars/globals.yml
index 9ff9642..60cb212 100644
--- a/setup/projects/adei/vars/globals.yml
+++ b/setup/projects/adei/vars/globals.yml
@@ -13,8 +13,6 @@ adei_pod_env:
value: "adei"
- name: "MYSQL_DATABASE"
value: "adei"
- - name: "APACHE_SERVERS"
- value: "${apache_servers}"
- name: "ADEI_PORTS"
value: "8080"
- name: "ADEI_SETUP"
@@ -34,6 +32,8 @@ adei_prod_env:
value: "${enable_logs}"
- name: "ADEI_DEBUG"
value: "${enable_debug}"
+ - name: "APACHE_SERVERS"
+ value: "${apache_servers}"
adei_log_env:
- name: "ADEI_RELEASE"
@@ -42,6 +42,8 @@ adei_log_env:
value: "0"
- name: "ADEI_DEBUG"
value: "0"
+ - name: "APACHE_SERVERS"
+ value: "5"
adei_debug_env:
- name: "ADEI_RELEASE"
@@ -50,11 +52,12 @@ adei_debug_env:
value: "0"
- name: "ADEI_DEBUG"
value: "0"
+ - name: "APACHE_SERVERS"
+ value: "5"
adei_cron_env:
- name: "ADEI_SCHEDULER"
- value: "0"
-
+ value: "1"
adei_pod_vols:
@@ -113,6 +116,33 @@ adei_pod_mounts:
#adei_dbg_pod_mounts: "{{ adei_dbg_mounts | union(adei_pod_mounts) }}"
adei_frontends:
+ update:
+ name: "adei-${setup}-update"
+ cron: "${adei_schedule_cache}"
+ cmd: [ "/bin/bash", "/adei/src/scripts/cron/adei.cron.sh" ]
+ env: "{{ adei_pod_env | union(adei_cron_env) }}"
+ vols: "{{ adei_pod_vols }}"
+ mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
+ groups: [ "adei" ]
+ enabled: true
+ maintain:
+ name: "adei-${setup}-maintain"
+ cron: "${adei_schedule_cache}"
+ cmd: [ "/bin/bash", "/adei/src/scripts/cron/adei_manager.cron.sh" ]
+ env: "{{ adei_pod_env | union(adei_cron_env) }}"
+ vols: "{{ adei_pod_vols }}"
+ mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
+ groups: [ "adei" ]
+ enabled: false
+ clean:
+ name: "adei-${setup}-clean"
+ cron: "${adei_schedule_cache}"
+ cmd: [ "/bin/bash", "/adei/src/scripts/cron/adei_clean.cron.sh" ]
+ env: "{{ adei_pod_env | union(adei_cron_env) }}"
+ vols: "{{ adei_pod_vols }}"
+ mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
+ groups: [ "adei" ]
+ enabled: false
frontend:
name: "adei-${setup}"
node: "adei-${setup}.{{ adei_domain }}"