From ca5b5b005d2ca454015f8b0faa54372c60a0e40a Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 23 Feb 2018 02:16:43 +0100 Subject: GlusterFS subpaths, ADEI frontend pods, fixes --- roles/ands_kaas/tasks/do_project.yml | 1 - roles/ands_kaas/tasks/file.yml | 2 +- roles/ands_kaas/templates/0-gfs-volumes.yml.j2 | 39 ---- roles/ands_kaas/templates/00-gfs-volumes.yml.j2 | 39 ++++ roles/ands_kaas/templates/50-kaas-pods.yml.j2 | 200 +++++++++++++++++++++ roles/ands_kaas/templates/6-kaas-pods.yml.j2 | 199 -------------------- roles/openshift_resource/tasks/main.yml | 4 +- roles/openshift_resource/tasks/resource.yml | 8 +- setup/configs/openshift.yml | 2 +- setup/projects/adei/templates/10-adei-build.yml.j2 | 43 +++++ setup/projects/adei/templates/60-adei.yml.j2 | 149 +++++++++++++++ setup/projects/adei/vars/globals.yml | 143 +++++++++++++++ setup/projects/adei/vars/pods.yml | 14 +- setup/projects/adei/vars/volumes.yml | 19 ++ 14 files changed, 603 insertions(+), 259 deletions(-) delete mode 100644 roles/ands_kaas/templates/0-gfs-volumes.yml.j2 create mode 100644 roles/ands_kaas/templates/00-gfs-volumes.yml.j2 create mode 100644 roles/ands_kaas/templates/50-kaas-pods.yml.j2 delete mode 100644 roles/ands_kaas/templates/6-kaas-pods.yml.j2 create mode 100644 setup/projects/adei/templates/10-adei-build.yml.j2 create mode 100644 setup/projects/adei/templates/60-adei.yml.j2 create mode 100644 setup/projects/adei/vars/globals.yml create mode 100644 setup/projects/adei/vars/volumes.yml diff --git a/roles/ands_kaas/tasks/do_project.yml b/roles/ands_kaas/tasks/do_project.yml index 61b91d2..a876d94 100644 --- a/roles/ands_kaas/tasks/do_project.yml +++ b/roles/ands_kaas/tasks/do_project.yml @@ -59,4 +59,3 @@ - kaas_project_config.oc is undefined - kaas_project_config.pods != {} - diff --git a/roles/ands_kaas/tasks/file.yml b/roles/ands_kaas/tasks/file.yml index 479ec68..e6b2e8d 100644 --- a/roles/ands_kaas/tasks/file.yml +++ b/roles/ands_kaas/tasks/file.yml @@ -16,7 +16,7 @@ - name: "Setting up files in {{ path }}" file: path: "{{ path }}" - recurse: "{{ file.recurse | default(true) }}" + recurse: "{{ file.recurse | default(false) }}" mode: "{{ file.mode | default( ((file.state | default('directory')) == 'directory') | ternary('0755', '0644') ) }}" owner: "{{ owner }}" group: "{{ group }}" diff --git a/roles/ands_kaas/templates/0-gfs-volumes.yml.j2 b/roles/ands_kaas/templates/0-gfs-volumes.yml.j2 deleted file mode 100644 index 8e5842a..0000000 --- a/roles/ands_kaas/templates/0-gfs-volumes.yml.j2 +++ /dev/null @@ -1,39 +0,0 @@ ---- -apiVersion: v1 -kind: Template -metadata: - name: - annotations: - descriptions: "KATRIN Volumes" -objects: -{% for name, vol in (kaas_project_config.volumes | default(kaas_openshift_volumes)).iteritems() %} -{% set oc_name = vol.name | default(name) | regex_replace('_','-') %} - - apiVersion: v1 - kind: PersistentVolume - metadata: - name: {{ oc_name }} - spec: - persistentVolumeReclaimPolicy: Retain - glusterfs: - endpoints: {{ kaas_glusterfs_endpoints }} - path: {{ vol.volume }} - readOnly: {{ not (vol.write | default(false)) }} - accessModes: - - {{ vol.access | default('ReadWriteMany') }} - capacity: - storage: {{ vol.capacity | default(kaas_default_volume_capacity) }} - claimRef: - name: {{ oc_name }} - namespace: {{ kaas_project }} - - apiVersion: v1 - kind: PersistentVolumeClaim - metadata: - name: {{ oc_name }} - spec: - volumeName: {{ oc_name }} - accessModes: - - {{ vol.access | default('ReadWriteMany') }} - resources: - requests: - storage: {{ vol.capacity | default(kaas_default_volume_capacity) }} -{% endfor %} diff --git a/roles/ands_kaas/templates/00-gfs-volumes.yml.j2 b/roles/ands_kaas/templates/00-gfs-volumes.yml.j2 new file mode 100644 index 0000000..c90c610 --- /dev/null +++ b/roles/ands_kaas/templates/00-gfs-volumes.yml.j2 @@ -0,0 +1,39 @@ +--- +apiVersion: v1 +kind: Template +metadata: + name: + annotations: + descriptions: "KATRIN Volumes" +objects: +{% for name, vol in (kaas_project_config.volumes | default(kaas_openshift_volumes)).iteritems() %} +{% set oc_name = vol.name | default(name) | regex_replace('_','-') %} + - apiVersion: v1 + kind: PersistentVolume + metadata: + name: {{ oc_name }} + spec: + persistentVolumeReclaimPolicy: Retain + glusterfs: + endpoints: {{ kaas_glusterfs_endpoints }} + path: "{{ vol.volume }}{{vol.path}}" + readOnly: {{ not (vol.write | default(false)) }} + accessModes: + - {{ vol.access | default(vol.write | default(false) | ternary('ReadWriteMany', 'ReadOnlyMany')) }} + capacity: + storage: {{ vol.capacity | default(kaas_default_volume_capacity) }} + claimRef: + name: {{ oc_name }} + namespace: {{ kaas_project }} + - apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: {{ oc_name }} + spec: + volumeName: {{ oc_name }} + accessModes: + - {{ vol.access | default('ReadWriteMany') }} + resources: + requests: + storage: {{ vol.capacity | default(kaas_default_volume_capacity) }} +{% endfor %} diff --git a/roles/ands_kaas/templates/50-kaas-pods.yml.j2 b/roles/ands_kaas/templates/50-kaas-pods.yml.j2 new file mode 100644 index 0000000..49dab3f --- /dev/null +++ b/roles/ands_kaas/templates/50-kaas-pods.yml.j2 @@ -0,0 +1,200 @@ +#jinja2: trim_blocks: "true", lstrip_blocks: "false" +--- +apiVersion: v1 +kind: Template +metadata: + name: {{ kaas_project }}-pods + annotations: + descriptions: {{ kaas_project_config.description | default(kaas_project ~ "auto-generated pod template") }} +objects: +{% for name, pod in (kaas_project_config.pods | default(kaas_openshift_volumes)).iteritems() %} + {% set pubkey = "kaas_" ~ name ~ "_pubkey" %} + {% set privkey = "kaas_" ~ name ~ "_privkey" %} + {% set cakey = "kaas_" ~ name ~ "_ca" %} + {% if pod.variant is defined %} + {% set pod = pod[pod.variant] %} + {% endif %} + {% if pod.service is defined %} + - apiVersion: v1 + kind: Service + metadata: + name: {{ pod.name | default(name) }} + spec: + selector: + name: {{ pod.name | default(name) }} + {% if pod.service.ports is defined %} + ports: + {% for port in pod.service.ports %} + {% set portmap = (port | string).split('/') %} + - name: "{{ portmap[0] }}" + port: {{ portmap[0] }} + targetPort: {{ (portmap[1] is defined) | ternary(portmap[1], portmap[0]) }} + {% endfor %} + {% endif %} + {% if (pod.service.ports is defined) and (pod.service.host is defined) %} + {% set first_port = (pod.service.ports[0] | string).split('/') %} + - apiVersion: v1 + kind: Route + metadata: + name: {{ pod.name | default(name) }} + spec: + host: {{ pod.service.host }} + to: + kind: Service + name: {{ pod.name | default(name) }} + port: + targetPort: {{ (first_port[1] is defined) | ternary(first_port[1], first_port[0]) }} + {% if (first_port[0] == "80") %} + tls: + termination: edge + insecureEdgeTerminationPolicy: Allow + {% if hostvars[inventory_hostname][pubkey] is defined %} + certificate: |- + {{ hostvars[inventory_hostname][pubkey] | indent(10) }} + {% endif %} + {% if hostvars[inventory_hostname][privkey] is defined %} + key: |- + {{ hostvars[inventory_hostname][privkey] | indent(10) }} + {% endif %} + {% if hostvars[inventory_hostname][cakey] is defined %} + caCertificate: |- + {{ hostvars[inventory_hostname][cakey] | indent(10) }} + {% endif %} + {% endif %} + {% endif %} + {% endif %} + - apiVersion: v1 + kind: DeploymentConfig + metadata: + name: {{ pod.name | default(name) }} + spec: + replicas: {{ pod.sched.replicas | default(1) }} + revisionHistoryLimit: 2 + strategy: + type: {{ pod.sched.strategy | default('Rolling') }} + triggers: + - type: ConfigChange + selector: + name: {{ pod.name | default(name) }} + template: + metadata: + name: {{ pod.name | default(name) }} + labels: + name: {{ pod.name | default(name) }} + spec: + {% if pod.selector is defined %} + nodeSelector: + {% for skey, sval in pod.selector.iteritems() %} + {{ skey }}: "{{ sval }}" + {% endfor %} + {% endif %} + {% set mappings = (pod.images | json_query('[*].mappings') | length) %} + {% if mappings > 0 %} + volumes: + {% for img in pod.images %} + {% set imgidx = loop.index %} + {% for vol in img.mappings %} + {% set oc_name = vol.name | default(name) | regex_replace('_','-') %} + - name: vol-{{imgidx}}-{{loop.index}} + persistentVolumeClaim: + claimName: {{ oc_name }} + {% endfor %} + {% endfor %} + {% endif %} + {% if (pod.groups is defined) or (pod.run_as is defined) %} + securityContext: + {% if (pod.run_as is defined) %} + {% if (kaas_project_config.uids | default(kaas_openshift_uids))[pod.run_as] is defined %} + - {{ (kaas_project_config.uids | default(kaas_openshift_uids))[pod.run_as].id }} + {% else %} + - {{ pod.run_as }} + {% endif %} + {% endif %} + {% if (pod.groups is defined) %} + supplementalGroups: + {% for group in pod.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 %} + containers: + {% for img in pod.images %} + {% set imgidx = loop.index %} + - name: {{ img.name | default(pod.name) | default(name) }} + image: {{ img.image }} + imagePullPolicy: Always + ports: + {% if img.ports is defined %} + {% for port in img.ports %} + - containerPort: {{ port }} + {% endfor %} + {% else %} + {% for port in pod.service.ports %} + {% set portmap = (port | string).split('/') %} + - containerPort: {{ (portmap[1] is defined) | ternary(portmap[1], portmap[0]) }} + {% endfor %} + {% endif %} + {% if img.env is defined %} + env: + {% for env_item in img.env %} + {% set env_name = env_item.name %} + {% set env_val = env_item.value %} + {% set env_parts = (env_val | string).split('@') %} + - name: "{{ env_name }}" + {% if env_parts[0] == "secret" %} + {% set env_sec = (env_parts[1] | string).split('/') %} + valueFrom: + secretKeyRef: + name: {{ env_sec[0] }} + key: {{ env_sec[1] }} + {% elif env_parts[0] == "cm" %} + {% set env_cm = (env_parts[1] | string).split('/') %} + valueFrom: + configMapKeyRef: + name: {{ env_cm[0] }} + key: {{ env_cm[1] }} + {% else %} + value: "{{ env_val }}" + {% endif %} + {% endfor %} + {% endif %} + {% if img.mappings is defined %} + volumeMounts: + {% for vol in img.mappings %} + - name: vol-{{imgidx}}-{{loop.index}} + subPath: {{ vol.path | default("") }} + mountPath: {{ vol.mount }} + {% endfor %} + {% endif %} + {% if img.probes is defined %} + {% for probe in img.probes %} + {% if (probe.type is undefined) %} + {% set seq = ['livenessProbe', 'readinessProbe'] %} + {% elif (probe.type == "liveness") %} + {% set seq = ['livenessProbe'] %} + {% else %} + {% set seq = ['readinessProbe'] %} + {% endif %} + {% for type in seq %} + {{ type }}: + timeoutSeconds: {{ probe.timeout | default(1) }} + initialDelaySeconds: {{ probe.delay | default(10) }} + {% if (probe.cmd is defined) %} + command: "{{ probe.cmd }}" + {% elif (probe.path is defined) %} + httpGet: + path: {{ probe.path }} + port: {{ probe.port | default(80) }} + {% else %} + tcpSocket: + port: {{ probe.port | default(80) }} + {% endif %} + {% endfor %} + {% endfor %} + {% endif %} + {% endfor %} +{% endfor %} diff --git a/roles/ands_kaas/templates/6-kaas-pods.yml.j2 b/roles/ands_kaas/templates/6-kaas-pods.yml.j2 deleted file mode 100644 index d5418d3..0000000 --- a/roles/ands_kaas/templates/6-kaas-pods.yml.j2 +++ /dev/null @@ -1,199 +0,0 @@ -#jinja2: trim_blocks: "true", lstrip_blocks: "false" ---- -apiVersion: v1 -kind: Template -metadata: - name: {{ kaas_project }}-pods - annotations: - descriptions: {{ kaas_project_config.description | default(kaas_project ~ "auto-generated pod template") }} -objects: -{% for name, pod in (kaas_project_config.pods | default(kaas_openshift_volumes)).iteritems() %} - {% set pubkey = "kaas_" ~ name ~ "_pubkey" %} - {% set privkey = "kaas_" ~ name ~ "_privkey" %} - {% set cakey = "kaas_" ~ name ~ "_ca" %} - {% if pod.variant is defined %} - {% set pod = pod[pod.variant] %} - {% endif %} - {% if pod.service is defined %} - - apiVersion: v1 - kind: Service - metadata: - name: {{ pod.name | default(name) }} - spec: - selector: - name: {{ pod.name | default(name) }} - {% if pod.service.ports is defined %} - ports: - {% for port in pod.service.ports %} - {% set portmap = (port | string).split('/') %} - - name: "{{ portmap[0] }}" - port: {{ portmap[0] }} - targetPort: {{ (portmap[1] is defined) | ternary(portmap[1], portmap[0]) }} - {% endfor %} - {% endif %} - {% if (pod.service.ports is defined) and (pod.service.host is defined) %} - {% set first_port = (pod.service.ports[0] | string).split('/')[0] %} - - apiVersion: v1 - kind: Route - metadata: - name: {{ pod.name | default(name) }} - spec: - host: {{ pod.service.host }} - to: - kind: Service - name: {{ pod.name | default(name) }} - port: - targetPort: {{ first_port }} - {% if (first_port == "80") %} - tls: - termination: edge - insecureEdgeTerminationPolicy: Allow - {% if hostvars[inventory_hostname][pubkey] is defined %} - certificate: |- - {{ hostvars[inventory_hostname][pubkey] | indent(10) }} - {% endif %} - {% if hostvars[inventory_hostname][privkey] is defined %} - key: |- - {{ hostvars[inventory_hostname][privkey] | indent(10) }} - {% endif %} - {% if hostvars[inventory_hostname][cakey] is defined %} - caCertificate: |- - {{ hostvars[inventory_hostname][cakey] | indent(10) }} - {% endif %} - {% endif %} - {% endif %} - {% endif %} - - apiVersion: v1 - kind: DeploymentConfig - metadata: - name: {{ pod.name | default(name) }} - spec: - replicas: {{ pod.sched.replicas | default(1) }} - selector: - name: {{ pod.name | default(name) }} - template: - metadata: - name: {{ pod.name | default(name) }} - labels: - name: {{ pod.name | default(name) }} - strategy: - type: {{ pod.sched.strategy | default('Rolling') }} - triggers: - - type: ConfigChange - spec: - {% if pod.selector is defined %} - nodeSelector: - {% for skey, sval in pod.selector.iteritems() %} - {{ skey }}: "{{ sval }}" - {% endfor %} - {% endif %} - {% set mappings = (pod.images | json_query('[*].mappings') | length) %} - {% if mappings > 0 %} - volumes: - {% for img in pod.images %} - {% set imgidx = loop.index %} - {% for vol in img.mappings %} - {% set oc_name = vol.name | default(name) | regex_replace('_','-') %} - - name: vol-{{imgidx}}-{{loop.index}} - persistentVolumeClaim: - claimName: {{ oc_name }} - {% endfor %} - {% endfor %} - {% endif %} - {% if (pod.groups is defined) or (pod.run_as is defined) %} - securityContext: - {% if (pod.run_as is defined) %} - {% if (kaas_project_config.uids | default(kaas_openshift_uids))[pod.run_as] is defined %} - - {{ (kaas_project_config.uids | default(kaas_openshift_uids))[pod.run_as].id }} - {% else %} - - pod.run_as - {% endif %} - {% endif %} - {% if (pod.groups is defined) %} - supplementalGroups: - {% for group in pod.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 %} - containers: - {% for img in pod.images %} - {% set imgidx = loop.index %} - - name: {{ img.name | default(pod.name) | default(name) }} - image: {{ img.image }} - imagePullPolicy: Always - ports: - {% if img.ports is defined %} - {% for port in img.ports %} - - containerPort: {{ port }} - {% endfor %} - {% else %} - {% for port in pod.service.ports %} - {% set portmap = (port | string).split('/') %} - - containerPort: {{ (portmap[1] is defined) | ternary(portmap[1], portmap[0]) }} - {% endfor %} - {% endif %} - {% if img.env is defined %} - env: - {% for env_item in img.env %} - {% set env_name = env_item.name %} - {% set env_val = env_item.value %} - {% set env_parts = (env_val | string).split('@') %} - - name: "{{ env_name }}" - {% if env_parts[0] == "secret" %} - {% set env_sec = (env_parts[1] | string).split('/') %} - valueFrom: - secretKeyRef: - name: {{ env_sec[0] }} - key: {{ env_sec[1] }} - {% elif env_parts[0] == "cm" %} - {% set env_cm = (env_parts[1] | string).split('/') %} - valueFrom: - configMapKeyRef: - name: {{ env_cm[0] }} - key: {{ env_cm[1] }} - {% else %} - value: "{{ env_val }}" - {% endif %} - {% endfor %} - {% endif %} - {% if img.mappings is defined %} - volumeMounts: - {% for vol in img.mappings %} - - name: vol-{{imgidx}}-{{loop.index}} - subPath: {{ (((kaas_project_config.volumes | default(kaas_openshift_volumes))[vol.name].path | default("")) ~ "/") | regex_replace('^/','') }}{{ vol.path | default("") }} - mountPath: {{ vol.mount }} - {% endfor %} - {% endif %} - {% if img.probes is defined %} - {% for probe in img.probes %} - {% if (probe.type is undefined) %} - {% set seq = ['livenessProbe', 'readynessProbe'] %} - {% elif (probe.type == "liveness") %} - {% set seq = ['livenessProbe'] %} - {% else %} - {% set seq = ['readynessProbe'] %} - {% endif %} - {% for type in seq %} - {{ type }}: - timeoutSeconds: {{ probe.timeout | default(1) }} - initialDelaySeconds: {{ probe.delay | default(10) }} - {% if (probe.cmd is defined) %} - command: "{{ probe.cmd }}" - {% elif (probe.path is defined) %} - httpGet: - path: {{ probe.path }} - port: {{ probe.port | default(80) }} - {% else %} - tcpSocket: - port: {{ probe.port | default(80) }} - {% endif %} - {% endfor %} - {% endfor %} - {% endif %} - {% endfor %} -{% endfor %} diff --git a/roles/openshift_resource/tasks/main.yml b/roles/openshift_resource/tasks/main.yml index d44d2e0..af071f9 100644 --- a/roles/openshift_resource/tasks/main.yml +++ b/roles/openshift_resource/tasks/main.yml @@ -14,9 +14,9 @@ when: template.find(".json") == -1 - include_tasks: template.yml - when: tmpl.kind == "Template" + when: (tmpl.kind == "Template") and (tmpl.parameters is not defined) - include_tasks: resource.yml - when: tmpl.kind != "Template" + when: (tmpl.parameters is defined) or (tmpl.kind != "Template") run_once: true diff --git a/roles/openshift_resource/tasks/resource.yml b/roles/openshift_resource/tasks/resource.yml index 326abbb..769a89c 100644 --- a/roles/openshift_resource/tasks/resource.yml +++ b/roles/openshift_resource/tasks/resource.yml @@ -5,16 +5,18 @@ - name: Lookup the specified resource command: "oc get -n {{project}} {{rkind}}/{{rname}}" - register: result + register: find_result + changed_when: false failed_when: false - changed_when: (result | failed) - name: Detroy existing resources command: "oc delete -n {{project}} {{rkind}}/{{rname}}" + register: rm_result failed_when: false + changed_when: (rm_result | succeeded) when: (recreate|default(false)) - name: Create resources defined in template command: "oc create -n {{project}} -f '{{ template_path }}/{{ template }}' {{ create_args | default('') }}" - when: (recreate|default(false)) or (result | changed) + when: (recreate|default(false)) or (find_result.rc != 0) run_once: true diff --git a/setup/configs/openshift.yml b/setup/configs/openshift.yml index e2a2d6d..17351ac 100644 --- a/setup/configs/openshift.yml +++ b/setup/configs/openshift.yml @@ -1,8 +1,8 @@ --- ands_openshift_projects: - katrin: KArlsruhe TRItium Neutrino adei: ADEI +# katrin: KArlsruhe TRItium Neutrino # test: Tesing ands_openshift_users: diff --git a/setup/projects/adei/templates/10-adei-build.yml.j2 b/setup/projects/adei/templates/10-adei-build.yml.j2 new file mode 100644 index 0000000..f961219 --- /dev/null +++ b/setup/projects/adei/templates/10-adei-build.yml.j2 @@ -0,0 +1,43 @@ +apiVersion: v1 +kind: Template +metadata: + name: adei-build + annotations: + descriptions: "ADEI Build" +objects: + - kind: ImageStream + apiVersion: v1 + metadata: + name: adei + labels: + name: adei + - kind: "BuildConfig" + apiVersion: "v1" + metadata: + name: "adei" + labels: + name: adei + spec: +# runPolicy: "Serial" + triggers: + - type: "ConfigChange" + source: + type: "Git" + git: + uri: "http://adei.info/git/csa/devops/docker/adei.git" + contextDir: "adei" + strategy: + dockerStrategy: + dockerfilePath: Dockerfile + output: + to: + kind: "ImageStreamTag" + name: "adei:latest" + imageLabels: + - name: "vendor" + value: "KIT" + - name: "author" + value: "Suren A. Chilingaryan" + - name: "authoritative-source-url" + value: "adei.info" + diff --git a/setup/projects/adei/templates/60-adei.yml.j2 b/setup/projects/adei/templates/60-adei.yml.j2 new file mode 100644 index 0000000..991fc8d --- /dev/null +++ b/setup/projects/adei/templates/60-adei.yml.j2 @@ -0,0 +1,149 @@ +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" +labels: + name: adei +objects: +{% for name, cfg in adei_frontends.iteritems() %} +{% if (cfg.enabled | default(true)) %} + - apiVersion: v1 + kind: Service + metadata: + name: "{{ cfg.name }}" + spec: + selector: + name: "{{ cfg.name }}" + ports: + - name: "80" + port: 80 + targetPort: 8080 + - apiVersion: v1 + kind: Route + metadata: + name: "{{ cfg.name }}" + spec: + host: "{{ cfg.node }}" + to: + kind: Service + name: "{{ cfg.name }}" + port: + targetPort: 8080 + tls: + termination: edge + insecureEdgeTerminationPolicy: Allow + - 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 %} +{% 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 %} +{% 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: + command: + - /docker-entrypoint.sh + - /opt/scripts/adei-branch.sh +{% endif %} +{% endif %} +{% endfor %} + +parameters: + - name: setup + value: "autogen" + description: "ADEI setup" + - name: adei_replicas + value: "2" + description: "Number of frontend replics" + - name: cache_replicas + value: "1" + description: "Default number of backend caching replicas" + - name: apache_servers + value: "150" + - name: cache_parallel + value: "source" + description: "Type of caching parallelism: group, source, server" + - 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_revision" + value: "last:1" diff --git a/setup/projects/adei/vars/globals.yml b/setup/projects/adei/vars/globals.yml new file mode 100644 index 0000000..9ff9642 --- /dev/null +++ b/setup/projects/adei/vars/globals.yml @@ -0,0 +1,143 @@ +adei_domain: "{{ openshift_master_default_subdomain }}" + +adei_pod_env: + - name: "HOME" + value: "/tmp" + - name: "MYSQL_SERVER" + value: "mysql.adei.svc.cluster.local" + - name: "MYSQL_PORT" + value: "3306" + - name: "MYSQL_USER" + value: "adei" + - name: "MYSQL_PASSWORD" + value: "adei" + - name: "MYSQL_DATABASE" + value: "adei" + - name: "APACHE_SERVERS" + value: "${apache_servers}" + - name: "ADEI_PORTS" + value: "8080" + - name: "ADEI_SETUP" + value: "${setup}" + - name: "ADEI_ENABLED_SETUPS" + value: "${setup}" + - name: "ADEI_PARALLEL" + value: "${cache_parallel}" + - name: "ADEI_REVISION" + value: "${adei_revision}" + + +adei_prod_env: + - name: "ADEI_RELEASE" + value: "1" + - name: "ADEI_WRITE_LOGS" + value: "${enable_logs}" + - name: "ADEI_DEBUG" + value: "${enable_debug}" + +adei_log_env: + - name: "ADEI_RELEASE" + value: "1" + - name: "ADEI_WRITE_LOGS" + value: "0" + - name: "ADEI_DEBUG" + value: "0" + +adei_debug_env: + - name: "ADEI_RELEASE" + value: "0" + - name: "ADEI_WRITE_LOGS" + value: "0" + - name: "ADEI_DEBUG" + value: "0" + +adei_cron_env: + - name: "ADEI_SCHEDULER" + value: "0" + + + +adei_pod_vols: + - name: adei-etc + persistentVolumeClaim: + claimName: adei-etc + - name: adei-src + persistentVolumeClaim: + claimName: adei-src + - name: adei-cfg + persistentVolumeClaim: + claimName: adei-cfg + - name: adei-sys + persistentVolumeClaim: + claimName: adei-sys + - name: adei-tmp + persistentVolumeClaim: + claimName: adei-tmp + - name: adei-log + persistentVolumeClaim: + claimName: adei-log +# - name: adei-ovr +# emptyDir: {} + + +adei_prod_mounts: + - name: adei-src + subPath: prod + mountPath: /adei/src + +adei_dbg_mounts: + - name: adei-src + subPath: dbg + mountPath: /adei/src + +adei_pod_mounts: + - name: adei-cfg + subPath: "${setup}" + mountPath: /adei/cfg + - name: adei-sys + subPath: "${setup}" + mountPath: /adei/sys + - name: adei-tmp + subPath: "${setup}" + mountPath: /adei/tmp + - name: adei-log + subPath: "${setup}/apache2" + mountPath: /var/log/apache2 + +# Only backends... +# - name: adei-log +# subPath: "${setup}/mail" +# mountPath: /var/spool/mail + +#adei_prod_pod_mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}" +#adei_dbg_pod_mounts: "{{ adei_dbg_mounts | union(adei_pod_mounts) }}" + +adei_frontends: + frontend: + name: "adei-${setup}" + node: "adei-${setup}.{{ adei_domain }}" + replicas: "${adei_replicas}" + env: "{{ adei_pod_env | union(adei_prod_env) }}" + vols: "{{ adei_pod_vols }}" + mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}" + groups: [ "adei" ] + configure: true + debug: + name: "adei-${setup}-debug" + node: "adei-${setup}-debug.{{ adei_domain }}" + replicas: 1 + env: "{{ adei_pod_env | union(adei_debug_env) }}" + vols: "{{ adei_pod_vols }}" + mounts: "{{ adei_dbg_mounts | union(adei_pod_mounts) }}" + groups: [ "adei" ] + enabled: false + configure: true + logs: + name: "adei-${setup}-logs" + node: "adei-${setup}-logs.{{ adei_domain }}" + replicas: 1 + env: "{{ adei_pod_env | union(adei_log_env) }}" + vols: "{{ adei_pod_vols }}" + mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}" + groups: [ "adei" ] + enabled: false diff --git a/setup/projects/adei/vars/pods.yml b/setup/projects/adei/vars/pods.yml index 3b104ea..c0b943c 100644 --- a/setup/projects/adei/vars/pods.yml +++ b/setup/projects/adei/vars/pods.yml @@ -1,19 +1,7 @@ -volumes: - adei_etc: { volume: "openshift", path: "/adei/etc" } - adei_db: { volume: "databases", path: "/adei", write: true} - -gids: - adei: { id: 5010 } - adei_db: { id: 5011 } - -files: - - { osv: "adei_db", path: "mysql", state: "directory", group: "adei_db", mode: "0775" } - - pods: mysql: service: { ports: [ 3306 ] } - sched: { replicas: 1, selector: { master: 1 } } + sched: { replicas: 1, strategy: "Recreate", selector: { master: 1 } } selector: { master: 1 } groups: [ "adei_db" ] images: diff --git a/setup/projects/adei/vars/volumes.yml b/setup/projects/adei/vars/volumes.yml new file mode 100644 index 0000000..3a0fe4d --- /dev/null +++ b/setup/projects/adei/vars/volumes.yml @@ -0,0 +1,19 @@ +volumes: + adei_etc: { volume: "openshift", path: "/adei/etc" } # mysql + adei_src: { volume: "openshift", path: "/adei/src", write: true } # prod & debug (init creates setup links) + adei_cfg: { volume: "openshift", path: "/adei/cfg", write: true } # per-setup configs (ADEI/wiki modifies setup) + adei_sys: { volume: "openshift", path: "/adei/sys" } # per-setup cron-jon overrides + adei_tmp: { volume: "temporary", path: "/adei/tmp", write: true } # per-setup temporary files + adei_log: { volume: "temporary", path: "/adei/log", write: true } # per-replica (should be fine) temporary files + adei_db: { volume: "databases", path: "/adei", write: true} + +gids: + adei: { id: 5010 } + adei_db: { id: 5011 } + +files: + - { osv: "adei_cfg", path: "/", state: "directory", group: "adei", mode: "0775" } + - { osv: "adei_src", path: "/", state: "directory", group: "adei", mode: "0775" } + - { osv: "adei_log", path: "/", state: "directory", group: "adei", mode: "0775" } + - { osv: "adei_tmp", path: "/", state: "directory", group: "adei", mode: "0775" } + - { osv: "adei_db", path: "mysql", state: "directory", group: "adei_db", mode: "0775" } -- cgit v1.2.3