summaryrefslogtreecommitdiffstats
path: root/roles/ands_kaas/templates
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-08-15 06:57:07 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-08-15 06:57:07 +0200
commite41e21f6d0f5ca7aace86bf60e8b503bb20fdcd5 (patch)
tree390101c89a5e8f5c8c8dd23263730821f7edbbeb /roles/ands_kaas/templates
parent79b191d207d7670295781c550847ce7d695cc388 (diff)
downloadands-e41e21f6d0f5ca7aace86bf60e8b503bb20fdcd5.tar.gz
ands-e41e21f6d0f5ca7aace86bf60e8b503bb20fdcd5.tar.bz2
ands-e41e21f6d0f5ca7aace86bf60e8b503bb20fdcd5.tar.xz
ands-e41e21f6d0f5ca7aace86bf60e8b503bb20fdcd5.zip
Support BuildConfig in ands_kaas role
Diffstat (limited to 'roles/ands_kaas/templates')
-rw-r--r--roles/ands_kaas/templates/40-kaas-app-builders.yml.j293
-rw-r--r--roles/ands_kaas/templates/50-kaas-app-pods.yml.j2 (renamed from roles/ands_kaas/templates/50-kaas-pods.yml.j2)19
2 files changed, 111 insertions, 1 deletions
diff --git a/roles/ands_kaas/templates/40-kaas-app-builders.yml.j2 b/roles/ands_kaas/templates/40-kaas-app-builders.yml.j2
new file mode 100644
index 0000000..090f15a
--- /dev/null
+++ b/roles/ands_kaas/templates/40-kaas-app-builders.yml.j2
@@ -0,0 +1,93 @@
+#jinja2: trim_blocks: "true", lstrip_blocks: "false"
+---
+{% set app = app | default('{}') %}
+{% set have_triggers = 0 %}
+apiVersion: v1
+kind: Template
+metadata:
+ name: {{ appname | default(kaas_project) }}-builders
+ annotations:
+ descriptions: {{ kaas_project_config.description | default(appname | default(kaas_project) ~ " auto-generated image-builder template") }}
+{% set applabels = ( app.labels | default({}) | combine( { 'app': appname }) ) if appname is defined else (app.labels | default({})) %}
+{% if applabels | length > 0 %}
+ labels: {{ applabels | to_json }}
+{% endif %}
+objects:
+{% for name, builder in builders.iteritems() %}
+ {% set isname = builder.name | default(name) | regex_replace('_','-') %}
+ {% set istag = builder.version | default("latest") %}
+ {% set type = builder.type | default("Docker") %}
+ {% set src_type = builder.src_type | default("git") %}
+ {% set image_type = builder.image_type | default("ImageStreamTag") %}
+ - kind: ImageStream
+ apiVersion: v1
+ metadata:
+ name: {{ isname }}
+ - kind: "BuildConfig"
+ apiVersion: v1
+ metadata:
+ name: {{ isname }}
+ spec:
+ successfulBuildsHistoryLimit: "{{ kaas_pod_history_limit }}"
+ failedBuildsHistoryLimit: "{{ kaas_pod_history_limit }}"
+ triggers:
+ - type: "ConfigChange"
+ source:
+ type: {{ src_type }}
+ {{ src_type }}:
+ uri: "{{ builder.src }}"
+ {% if builder.src_path is defined %}
+ contextDir: "{{ builder.src_path }}"
+ {% endif %}
+ strategy:
+ {% if type == 'Docker' %}
+ type: {{ type }}
+ {{ type | lower }}Strategy:
+ dockerfilePath: "{{ builder.dockerfile | default('Dockerfile') }}"
+ {% if builder.args is defined %}
+ buildArgs: {{ builder.args | to_json }}
+ {% endif %}
+ {% else %}
+ type: {{ type }}
+ {{ type | lower }}Strategy:
+ {% if builder.image is defined %}
+ from:
+ kind: {{ image_type }}
+ name: "{{ builder.image }}"
+ {% if image_type == 'ImageStreamTag' %}
+ namespace: "{{ builder.image_namespace | default('openshift') }}"
+ {% endif %}
+ {% endif %}
+ {% endif %}
+ {% if builder.env is defined %}
+ env: {{ builder.env | to_json }}
+ {% endif %}
+ output:
+ to:
+ kind: "ImageStreamTag"
+ name: "{{ isname }}:{{ istag }}"
+ imageLabels:
+ - name: "vendor"
+ value: "{{ builder.vendor | default(ands_info.vendor) }}"
+ - name: "author"
+ value: "{{ builder.author | default(ands_info.admin) }}"
+ - name: "authoritative-source-url"
+ value: "{{ builder.url | default(ands_info.git_url) }}"
+ triggers:
+ - type: ConfigChange
+ - type: ImageChange
+ {% if builder.trigger is defined %}
+ {% set have_triggers = 1 %}
+ {% set trigger_type = "Generic" if 'github.com' in builder.src else "Generic" %}
+ - type: {{ trigger_type }}
+ {{ trigger_type | lower }}:
+ secret: ${TRIGGER_SECRET}
+ {% endif %}
+{% endfor %}
+parameters:
+{% if have_triggers %}
+ - description: Trigger secret
+ from: '[a-zA-Z0-9]{8}'
+ generate: expression
+ name: TRIGGER_SECRET
+{% endif %}
diff --git a/roles/ands_kaas/templates/50-kaas-pods.yml.j2 b/roles/ands_kaas/templates/50-kaas-app-pods.yml.j2
index 8c7fe85..2174962 100644
--- a/roles/ands_kaas/templates/50-kaas-pods.yml.j2
+++ b/roles/ands_kaas/templates/50-kaas-app-pods.yml.j2
@@ -133,6 +133,23 @@ objects:
{% endif %}
triggers:
- type: ConfigChange
+ {% for img in pod.images %}
+ {% if img.stream is defined %}
+ {% set stream = img.stream.split('/') %}
+ {% set stream_name = stream[1] | default(stream[0]) %}
+ - type: ImageChange
+ imageChangeParams:
+ automatic: true
+ containerNames:
+ - {{ img.name | default(podname) }}
+ from:
+ kind: "ImageStreamTag"
+ name: {{ stream_name }}
+ {% if (stream[1] is defined) %}
+ namespace: {{ stream[0] }}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
{% if kind == 'StatefulSet' %}
{% if headless %}
serviceName: {{ podname }}-ss
@@ -230,7 +247,7 @@ objects:
{% for img in pod.images %}
{% set imgidx = loop.index %}
- name: {{ img.name | default(podname) }}
- image: {{ img.image }}
+ image: {{ img.stream | default(img.image) }}
imagePullPolicy: {{ img.pull | default('Always') }}
{% if (img.command is defined) %}
command: {{ img.command | to_json }}