Prometheus fixes

* Rename 'replica' to 'replicas' in docker/swarm/service/monitoring
* Add 'discovery_domain' environment for entrypoint
* Build prometheus/server/target/etcd.yml yourself
* Build prometheus/server/target/kubernetes.ym yourself
* Add prometheus/server/target/dns.yml
* Fix SSL permissions for prometheus

Change-Id: Icae085f6b0762ada58d03cde276963ec1e4bdefa
diff --git a/docker/swarm/service/monitoring/prometheus_alertmanager.yml b/docker/swarm/service/monitoring/prometheus_alertmanager.yml
index 99eb226..5d5f237 100644
--- a/docker/swarm/service/monitoring/prometheus_alertmanager.yml
+++ b/docker/swarm/service/monitoring/prometheus_alertmanager.yml
@@ -6,11 +6,12 @@
       service:
         prometheus_alertmanager:
           network: monitoring
-          replica: 2
+          replicas: 2
           environment:
             config_dir: /opt/alertmanager/config
             bind_port: ${prometheus:alertmanager:bind:port}
             bind_address: ${prometheus:alertmanager:bind:address}
+            discovery_domain: 'prometheus_alertmanager'
           restart:
             condition: any
           image: ${_param:docker_image_alertmanager}
diff --git a/docker/swarm/service/monitoring/prometheus_pushgateway.yml b/docker/swarm/service/monitoring/prometheus_pushgateway.yml
index 7ba37af..ad159b6 100644
--- a/docker/swarm/service/monitoring/prometheus_pushgateway.yml
+++ b/docker/swarm/service/monitoring/prometheus_pushgateway.yml
@@ -4,7 +4,7 @@
       service:
         prometheus_pushgateway:
           network: monitoring
-          replica: 2
+          replicas: 2
           restart:
             condition: any
           image: ${_param:docker_image_pushgateway}
diff --git a/docker/swarm/service/monitoring/prometheus_server.yml b/docker/swarm/service/monitoring/prometheus_server.yml
index 94207ca..37bb6d3 100644
--- a/docker/swarm/service/monitoring/prometheus_server.yml
+++ b/docker/swarm/service/monitoring/prometheus_server.yml
@@ -6,7 +6,7 @@
       service:
         prometheus_server:
           network: monitoring
-          replica: 1
+          replicas: 1
           environment:
             config_dir: /opt/prometheus/config
             bind_port: ${prometheus:server:bind:port}
@@ -17,6 +17,7 @@
             storage_local_memory_chunks: ${prometheus:server:storage:local:memory_chunks}
             storage_local_max_chunks_to_persist: ${prometheus:server:storage:local:max_chunks_to_persist}
             storage_local_num_fingerprint_mutexes: ${prometheus:server:storage:local:num_fingerprint_mutexes}
+            discovery_domain: 'prometheus_alertmanager'
           restart:
             condition: any
           image: ${_param:docker_image_prometheus}
diff --git a/prometheus/server/target/dns.yml b/prometheus/server/target/dns.yml
new file mode 100644
index 0000000..1dd3afb
--- /dev/null
+++ b/prometheus/server/target/dns.yml
@@ -0,0 +1,14 @@
+parameters:
+  server:
+    target:
+      dns:
+        - name: 'pushgateway'
+          domain:
+          - 'tasks.prometheus_pushgateway'
+          type: A
+          port: 9091
+        - name: 'prometheus'
+          domain:
+          - 'tasks.prometheus_server'
+          type: A
+          port: 9090
diff --git a/prometheus/server/target/etcd.yml b/prometheus/server/target/etcd.yml
index e343bda..41204b5 100644
--- a/prometheus/server/target/etcd.yml
+++ b/prometheus/server/target/etcd.yml
@@ -1,6 +1,10 @@
-classes:
-- service.etcd.server.cluster
 parameters:
   server:
     target:
-      etcd: ${etcd:server:members}
+      etcd:
+        - host: ${_param:cluster_node01_address}
+          port: ${_param:cluster_node01_port}
+        - host: ${_param:cluster_node02_address}
+          port: ${_param:cluster_node02_port}
+        - host: ${_param:cluster_node03_address}
+          port: ${_param:cluster_node03_port}
diff --git a/prometheus/server/target/kubernetes.yml b/prometheus/server/target/kubernetes.yml
index 293895b..d77ab3f 100644
--- a/prometheus/server/target/kubernetes.yml
+++ b/prometheus/server/target/kubernetes.yml
@@ -1,10 +1,8 @@
-classes:
-- service.kubernetes.master.cluster
 parameters:
   server:
     target:
       kubernetes:
-        api_ip: ${kubernetes:master:apiserver:address}
+        api_ip: ${_param:kubernetes_control_address}
         ssl_dir: /opt/prometheus/config
         cert_name: kubelet-client.crt
         key_name: kubelet-client.key
diff --git a/salt/minion/cert/k8s_client_prometheus.yml b/salt/minion/cert/k8s_client_prometheus.yml
index 678ddbe..138fce8 100644
--- a/salt/minion/cert/k8s_client_prometheus.yml
+++ b/salt/minion/cert/k8s_client_prometheus.yml
@@ -10,3 +10,4 @@
           common_name: kubelet-client
           signing_policy: cert_client
           alternative_names: IP:${_param:cluster_vip_address},IP:${_param:cluster_node01_address},IP:${_param:cluster_node02_address},IP:${_param:cluster_node03_address},IP:${_param:kubernetes_internal_api_address}
+          mode: '0444'