From 9cd1db3fd3581ea36423a76c9a74be8054e846d4 Mon Sep 17 00:00:00 2001
From: "Suren A. Chilingaryan" <csa@suren.me>
Date: Thu, 29 Aug 2019 05:07:50 +0200
Subject: Munin support for ADEI

---
 setup/projects/adei/templates/60-adei.yml.j2 | 25 +++++++++++++++--
 setup/projects/adei/vars/apps.yml            |  3 +-
 setup/projects/adei/vars/globals.yml         | 41 ++++++++++++++++------------
 setup/projects/adei/vars/munin.yml           | 20 ++++++++++++++
 setup/projects/adei/vars/volumes.yml         | 10 +++++--
 5 files changed, 75 insertions(+), 24 deletions(-)
 create mode 100644 setup/projects/adei/vars/munin.yml

(limited to 'setup')

diff --git a/setup/projects/adei/templates/60-adei.yml.j2 b/setup/projects/adei/templates/60-adei.yml.j2
index 87f734d..6d0ccae 100644
--- a/setup/projects/adei/templates/60-adei.yml.j2
+++ b/setup/projects/adei/templates/60-adei.yml.j2
@@ -135,15 +135,18 @@ objects:
 {%       if (cfg.groups is defined) or (cfg.run_as is defined) %}
                 securityContext:
 {%         if (cfg.run_as is defined) %}
-                  runAsUser: {{ (kaas_project_uids[cfg.run_as] is defined) | ternary(kaas_project_uids[cfg.run_as].id, cfg.run_as) }}
+{%             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" %}
-                  fsGroup: {{ (kaas_project_gids[cfg.groups[0]] is defined) | ternary(kaas_project_gids[cfg.groups[0]].id, cfg.groups[0]) }}
+{%             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 %}
-                    - {{ (kaas_project_gids[group] is defined) | ternary(kaas_project_gids[group].id, group) }}
+{%             set group_info = kaas_project_gids[group] | default({}) %}
+                    - {{ ('id' in group_info) | ternary(group_info.id, group) }}
 {%           endfor %}
 {%         endif %}
 {%       endif %}
@@ -214,8 +217,21 @@ 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"  
@@ -236,6 +252,9 @@ parameters:
   - 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)"
diff --git a/setup/projects/adei/vars/apps.yml b/setup/projects/adei/vars/apps.yml
index 1c2aad3..bc4ed1e 100644
--- a/setup/projects/adei/vars/apps.yml
+++ b/setup/projects/adei/vars/apps.yml
@@ -1,5 +1,6 @@
 apps:
   mysql:                { provision: true, instantiate: true }
-  galera:               { provision: true, instantiate: false }
+  galera:               { provision: false, instantiate: false }
 #  simple_mysql:        { provision: false, instantiate: false }
   phpmyadmin:           { provision: true, instantiate: true }
+  munin:                { provision: true, instantiate: false }
diff --git a/setup/projects/adei/vars/globals.yml b/setup/projects/adei/vars/globals.yml
index 8638e44..8f67572 100644
--- a/setup/projects/adei/vars/globals.yml
+++ b/setup/projects/adei/vars/globals.yml
@@ -6,7 +6,7 @@ adei_pod_env:
     - name: "ENV"
       value: "~/.bashrc"
     - name: "HOME"
-      value: "/data/home"
+      value: "/data"
     - name: "SHELL"
       value: "/bin/bash"
     - name: "MYSQL_MASTER_SERVER"
@@ -178,11 +178,14 @@ adei_pod_vols:
     - name: adei-log
       persistentVolumeClaim: 
         claimName: adei-log
-
-adei_admin_vols:
     - name: adei-data
       persistentVolumeClaim:
-        claimName: adei-data
+        claimName: "${data_volume}"
+    
+adei_admin_vols:
+    - name: adei-home
+      persistentVolumeClaim:
+        claimName: adei-home
 
 adei_pod_mounts:
     - name: adei-cfg
@@ -197,7 +200,11 @@ adei_pod_mounts:
     - name: adei-log
       subPath: "${setup}/apache2"
       mountPath: /var/log/apache2
-
+    - name: adei-data
+      subPath: "${data_path}"
+      mountPath: "/adei/data/${setup}"
+      readOnly: "${{ '{{' }}forbid_data_writes{{ '}}' }}"
+    
 adei_prod_mounts:
     - name: adei-src
       subPath: prod
@@ -209,7 +216,7 @@ adei_dbg_mounts:
       mountPath: /adei/src
 
 adei_admin_mounts:
-    - name: adei-data
+    - name: adei-home
       mountPath: /data
 
 adei_frontends:
@@ -220,7 +227,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_prod_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       configure: true
     debug:
       name: "adei-${setup}-debug"
@@ -229,7 +236,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_debug_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_dbg_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       configure: true
       enabled: true
     logs:
@@ -239,7 +246,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_log_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     cacher:
       name: "adei-${setup}-cacher"
@@ -249,16 +256,16 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_cache_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     archive_cacher:
       name: "adei-${setup}-archive-cacher"
-      replicas: "1"
+      replicas: "${archive_replicas}"
       cmd: [ "/openshift-entrypoint.sh", "/adei/src/scripts/system/cacher.sh",  "-m",  "archive" ]
       env: "{{ adei_pod_env | union(adei_arc_cache_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     log_cacher:
       name: "adei-${setup}-log-cacher"
@@ -267,7 +274,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_log_cache_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     update:
       name: "adei-${setup}-update"
@@ -276,7 +283,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_cron_env) | union(adei_update_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     maintain:
       name: "adei-${setup}-maintain"
@@ -285,7 +292,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_cron_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     clean:
       name: "adei-${setup}-clean"
@@ -294,7 +301,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_cron_env) }}"
       vols: "{{ adei_pod_vols }}"
       mounts: "{{ adei_prod_mounts | union(adei_pod_mounts) }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
     admin:
       name: "adei-${setup}-admin"
@@ -305,7 +312,7 @@ adei_frontends:
       env: "{{ adei_pod_env | union(adei_admin_env) }}"
       vols: "{{ adei_pod_vols | union(adei_admin_vols) }}"
       mounts: "{{ adei_dbg_mounts | union(adei_pod_mounts) | union(adei_admin_mounts)  }}"
-      groups: [ "adei" ]
+      groups: [ "adei", "${{ '{{' }}data_group{{ '}}' }}" ]
       enabled: true
 
 # Extra options:
diff --git a/setup/projects/adei/vars/munin.yml b/setup/projects/adei/vars/munin.yml
new file mode 100644
index 0000000..e00c742
--- /dev/null
+++ b/setup/projects/adei/vars/munin.yml
@@ -0,0 +1,20 @@
+munin:
+  builders:
+    munin:  { src: "{{ ands_repos.docker }}/munin.git" }
+
+  pods:
+    munin:
+      service: { host: "munin.{{ openshift_master_default_subdomain }}", ports: [ 80/8080 ] }
+      sched: { replicas: 1 }
+      groups: [ "adei_data" ]
+      images:
+        - stream: "munin:latest"
+          mappings: 
+            - { name: "adei_data", path: "munin",     mount: "/munin/db" }
+          probes:
+            - { port: 8080 }
+          env:
+            - { name: "NODES", value: "${munin_nodes}" }
+
+  parameters:
+    - { name: munin_nodes, description: "List of munin nodes to monitor" }
diff --git a/setup/projects/adei/vars/volumes.yml b/setup/projects/adei/vars/volumes.yml
index f86e2a2..1d61230 100644
--- a/setup/projects/adei/vars/volumes.yml
+++ b/setup/projects/adei/vars/volumes.yml
@@ -1,10 +1,12 @@
 gids:
   adei: { id: 6001, users: [ 'csa' ]  }
   adei_db: { id: 6002 }
+  adei_data: { id: 6003 }
 
 volumes:
   adei_host: { volume: "hostraid",  path: "/adei",       write: true }                  # mysql
-  adei_data: { volume: "datastore", path: "/adei",       write: true }                  # temporary home for administrator pods
+  adei_data: { volume: "datastore", path: "/adei",       write: true }                  # Source data (e.g. RRD) for ADEI pods
+  adei_home: { volume: "datastore", path: "/adei/home",  write: true }                  # temporary home for administrator pods
   adei_init: { volume: "openshift", path: "/adei/init"}                                 # simple mysql (or obsolete)
   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)
@@ -27,8 +29,10 @@ files:
   - { osv: "adei_sys", path: "/",               state: "directory", group: "adei", mode: "02775" }
   - { osv: "adei_log", path: "/",               state: "directory", group: "adei", mode: "02775" }
   - { osv: "adei_tmp", path: "/",               state: "directory", group: "adei", mode: "02775" }
-  - { osv: "adei_data",path: "/",               state: "directory", group: "adei", mode: "02775" }
-  - { osv: "adei_data",path: "/home",           state: "directory", group: "adei", mode: "02775" }
+  - { osv: "adei_home",path: "/",               state: "directory", group: "adei", mode: "02775" }
+  - { osv: "adei_data",path: "/",               state: "directory", group: "adei_data", mode: "02775" }
+  - { osv: "adei_data",path: "/data",           state: "directory", group: "adei_data", mode: "02775" }
+  - { osv: "adei_data",path: "/munin",          state: "directory", group: "adei_data", mode: "02775" }
   - { osv: "adei_host",path: "mysql",           state: "directory", group: "adei_db", mode: "02775" }
   - { osv: "adei_host",path: "galera",          state: "directory", group: "adei_db", mode: "02775" }
   - { osv: "adei_host",path: "mysql_master",    state: "directory", group: "adei_db", mode: "02775" }
-- 
cgit v1.2.3