Deploy Galera on monitoring nodes

Grafana requires a MySQL database to store users, groups and dashboards.

Change-Id: Id77f69def97537b9ca0128ee2c2a8ea64241daef
Depends-On: I0932d9a7520d998fd259821f5b5e7113cb3a9ced
diff --git a/classes/cluster/virtual-mcp11-k8s-calico/infra/config.yml b/classes/cluster/virtual-mcp11-k8s-calico/infra/config.yml
index a7fb048..ee53ccc 100644
--- a/classes/cluster/virtual-mcp11-k8s-calico/infra/config.yml
+++ b/classes/cluster/virtual-mcp11-k8s-calico/infra/config.yml
@@ -5,6 +5,8 @@
 - system.salt.minion.ca.salt_master
 - system.salt.master.api
 - system.salt.minion.cert.k8s_server
+- system.mysql.client
+- system.mysql.client.database.grafana
 - system.reclass.storage.salt
 - system.reclass.storage.system.kubernetes_control_cluster
 - cluster.virtual-mcp11-k8s-calico.infra
@@ -52,6 +54,7 @@
           name: ${_param:docker_swarm_node01_hostname}
           domain: ${_param:cluster_domain}
           classes:
+          - service.galera.master.cluster
           - cluster.${_param:cluster_name}.swarm.master
           - cluster.${_param:cluster_name}.monitoring.client
           - cluster.${_param:cluster_name}.monitoring.server
@@ -60,10 +63,12 @@
             linux_system_codename: xenial
             single_address: ${_param:docker_swarm_node01_address}
             keepalived_vip_priority: 100
+            mysql_cluster_role: master
         docker_swarm_node02:
           name: ${_param:docker_swarm_node02_hostname}
           domain: ${_param:cluster_domain}
           classes:
+          - service.galera.slave.cluster
           - cluster.${_param:cluster_name}.swarm.slave
           - cluster.${_param:cluster_name}.monitoring.server
           params:
@@ -71,10 +76,12 @@
             linux_system_codename: xenial
             single_address: ${_param:docker_swarm_node02_address}
             keepalived_vip_priority: 101
+            mysql_cluster_role: slave
         docker_swarm_node03:
           name: ${_param:docker_swarm_node03_hostname}
           domain: ${_param:cluster_domain}
           classes:
+          - service.galera.slave.cluster
           - cluster.${_param:cluster_name}.swarm.slave
           - cluster.${_param:cluster_name}.monitoring.server
           params:
@@ -82,3 +89,4 @@
             linux_system_codename: xenial
             single_address: ${_param:docker_swarm_node03_address}
             keepalived_vip_priority: 102
+            mysql_cluster_role: slave
diff --git a/classes/cluster/virtual-mcp11-k8s-calico/monitoring/init.yml b/classes/cluster/virtual-mcp11-k8s-calico/monitoring/init.yml
index 96c462b..4f8fc0a 100644
--- a/classes/cluster/virtual-mcp11-k8s-calico/monitoring/init.yml
+++ b/classes/cluster/virtual-mcp11-k8s-calico/monitoring/init.yml
@@ -5,3 +5,12 @@
 
     # prometheus
     prometheus_control_address: ${_param:docker_swarm_address}
+
+    mysql_admin_user: root
+    mysql_admin_password: workshop
+
+    mysql_grafana_password: password
+    cluster_local_address: ${_param:single_address}
+    galera_server_cluster_name: monitoring_cluster
+    galera_server_maintenance_password: workshop
+    galera_server_admin_password: workshop
diff --git a/classes/cluster/virtual-mcp11-k8s-calico/monitoring/server.yml b/classes/cluster/virtual-mcp11-k8s-calico/monitoring/server.yml
index 5a62ed5..ba34577 100644
--- a/classes/cluster/virtual-mcp11-k8s-calico/monitoring/server.yml
+++ b/classes/cluster/virtual-mcp11-k8s-calico/monitoring/server.yml
@@ -1,5 +1,7 @@
 classes:
 - system.linux.system.repo.tcp_elastic
+# Needed to install Galera packages
+- system.linux.system.repo.mcp.openstack
 - system.elasticsearch.server.cluster
 - system.elasticsearch.server.curator
 - system.kibana.server.single
@@ -10,6 +12,8 @@
 - system.glusterfs.client.volume.prometheus
 - system.glusterfs.server.cluster
 - system.glusterfs.server.volume.prometheus
+- system.galera.server.cluster
+- system.galera.server.database.grafana
 - system.salt.minion.cert.prometheus_server
 - system.keepalived.cluster.instance.prometheus_server_vip
 - system.prometheus.server.target.etcd
@@ -38,3 +42,10 @@
     cluster_node02_address: ${_param:docker_swarm_node02_address}
     cluster_node03_hostname: ${_param:docker_swarm_node03_hostname}
     cluster_node03_address: ${_param:docker_swarm_node03_address}
+    # Galera
+    openstack_version: newton
+  keepalived:
+    cluster:
+      instance:
+        VIP:
+          enabled: false