From 8e4da9da554f7865e7e69cb2a2990a75d39c3fe2 Mon Sep 17 00:00:00 2001
From: Steve Wilkerson <wilkers.steve@gmail.com>
Date: Mon, 12 Mar 2018 10:27:35 -0500
Subject: [PATCH] Revert Elasticsearch/Kibana image change

This reverts the changes made to Elasticsearch, Kibana and fluent
logging charts in https://review.openstack.org/#/c/550229/7.

Specifically, this moves the images back to previous used versions
and makes the required changes to the fluent-logging elasticsearch
template job to include the correct mapping directives for the
elasticsearch template.

This change was made to give more time for evaluating a more
robust solution for switching to the official upstream images that
will not cause intermittent gate failures as seen since 550229 was
merged

Change-Id: I9f70b3412a8edc5cb1d80937b158aa2fe7b1ec82
---
 elasticsearch/templates/bin/_elasticsearch.sh.tpl | 2 +-
 elasticsearch/templates/deployment-client.yaml    | 4 ++++
 elasticsearch/templates/deployment-master.yaml    | 4 ++++
 elasticsearch/templates/statefulset-data.yaml     | 4 ++++
 elasticsearch/values.yaml                         | 5 +----
 fluent-logging/templates/_helpers.tpl             | 4 ++++
 fluent-logging/values.yaml                        | 9 ++++++---
 kibana/templates/deployment.yaml                  | 2 --
 kibana/values.yaml                                | 2 +-
 9 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/elasticsearch/templates/bin/_elasticsearch.sh.tpl b/elasticsearch/templates/bin/_elasticsearch.sh.tpl
index f51059ce7..780ec6e76 100644
--- a/elasticsearch/templates/bin/_elasticsearch.sh.tpl
+++ b/elasticsearch/templates/bin/_elasticsearch.sh.tpl
@@ -20,7 +20,7 @@ COMMAND="${@:-start}"
 
 function start () {
   ulimit -l unlimited
-  exec /usr/local/bin/docker-entrypoint.sh
+  exec /docker-entrypoint.sh elasticsearch
 }
 
 function stop () {
diff --git a/elasticsearch/templates/deployment-client.yaml b/elasticsearch/templates/deployment-client.yaml
index 381a1a137..700a86c7b 100644
--- a/elasticsearch/templates/deployment-client.yaml
+++ b/elasticsearch/templates/deployment-client.yaml
@@ -207,6 +207,8 @@ spec:
               mountPath: /tmp/elasticsearch.sh
               subPath: elasticsearch.sh
               readOnly: true
+            - name: elasticsearch-config
+              mountPath: /usr/share/elasticsearch/config
             - name: elasticsearch-etc
               mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
               subPath: elasticsearch.yml
@@ -225,6 +227,8 @@ spec:
       volumes:
         - name: pod-etc-apache
           emptyDir: {}
+        - name: elasticsearch-config
+          emptyDir: {}
         - name: elasticsearch-logs
           emptyDir: {}
         - name: elasticsearch-bin
diff --git a/elasticsearch/templates/deployment-master.yaml b/elasticsearch/templates/deployment-master.yaml
index d455942fe..037b1de70 100644
--- a/elasticsearch/templates/deployment-master.yaml
+++ b/elasticsearch/templates/deployment-master.yaml
@@ -163,6 +163,8 @@ spec:
               mountPath: /tmp/elasticsearch.sh
               subPath: elasticsearch.sh
               readOnly: true
+            - name: elasticsearch-config
+              mountPath: /usr/share/elasticsearch/config
             - name: elasticsearch-etc
               mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
               subPath: elasticsearch.yml
@@ -181,6 +183,8 @@ spec:
       volumes:
         - name: elasticsearch-logs
           emptyDir: {}
+        - name: elasticsearch-config
+          emptyDir: {}
         - name: elasticsearch-bin
           configMap:
             name: elasticsearch-bin
diff --git a/elasticsearch/templates/statefulset-data.yaml b/elasticsearch/templates/statefulset-data.yaml
index 36745033a..c9be0a5d8 100644
--- a/elasticsearch/templates/statefulset-data.yaml
+++ b/elasticsearch/templates/statefulset-data.yaml
@@ -160,6 +160,8 @@ spec:
               mountPath: /tmp/elasticsearch.sh
               subPath: elasticsearch.sh
               readOnly: true
+            - name: elasticsearch-config
+              mountPath: /usr/share/elasticsearch/config
             - name: elasticsearch-etc
               mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
               subPath: elasticsearch.yml
@@ -178,6 +180,8 @@ spec:
       volumes:
         - name: elasticsearch-logs
           emptyDir: {}
+        - name: elasticsearch-config
+          emptyDir: {}
         - name: elasticsearch-bin
           configMap:
             name: elasticsearch-bin
diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml
index 5a10fc64b..df27d6819 100644
--- a/elasticsearch/values.yaml
+++ b/elasticsearch/values.yaml
@@ -21,7 +21,7 @@ images:
     apache_proxy: docker.io/httpd:2.4
     memory_init: docker.io/kolla/ubuntu-source-heat-engine:3.0.3
     curator:  docker.io/bobrik/curator:5.2.0
-    elasticsearch: docker.elastic.co/elasticsearch/elasticsearch:6.2.2
+    elasticsearch: docker.io/elasticsearch:5.6.4
     helm_tests: docker.io/kolla/ubuntu-source-heat-engine:3.0.3
     prometheus_elasticsearch_exporter: docker.io/justwatch/elasticsearch_exporter:1.0.1
     dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1
@@ -248,9 +248,6 @@ conf:
         blacklist: ['elasticsearch', 'urllib3']
   elasticsearch:
     config:
-      xpack:
-        security:
-          enabled: false
       bootstrap:
         memory_lock: true
       cluster:
diff --git a/fluent-logging/templates/_helpers.tpl b/fluent-logging/templates/_helpers.tpl
index c3dafbfd2..672209051 100644
--- a/fluent-logging/templates/_helpers.tpl
+++ b/fluent-logging/templates/_helpers.tpl
@@ -135,7 +135,11 @@ section):
 {{- include "fluent_logging.recursive_tuple" $value | indent 2 }}
 }
 {{- else }}
+{{- if eq $key "index_patterns"}}
+{{ $key | quote -}}: [{{ $value | quote }}]
+{{- else }}
 {{ $key | quote -}}:{{ $value | quote }}
 {{- end }}
 {{- end }}
 {{- end }}
+{{- end }}
diff --git a/fluent-logging/values.yaml b/fluent-logging/values.yaml
index 486ee4d48..f816a9e4c 100644
--- a/fluent-logging/values.yaml
+++ b/fluent-logging/values.yaml
@@ -73,6 +73,8 @@ dependencies:
         - endpoint: internal
           service: fluentd
     fluentd:
+      jobs:
+        - elasticsearch-template
       services:
         - endpoint: internal
           service: elasticsearch
@@ -159,17 +161,18 @@ conf:
         max_retry_wait: 300
         disable_retry_limit: ""
         num_threads: 8
+        type_name: fluentd
   fluentd_exporter:
     log:
       format: "logger:stdout?json=true"
       level: "info"
   template:
     template: "logstash-*"
+    index_patterns: "logstash-*"
     settings:
-      number_of_shards: 5
-      number_of_replicas: 1
+      number_of_shards: 1
     mappings:
-      _doc:
+      doc:
         properties:
           kubernetes:
             properties:
diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml
index 8bf88a3ea..ca6f7faba 100644
--- a/kibana/templates/deployment.yaml
+++ b/kibana/templates/deployment.yaml
@@ -90,8 +90,6 @@ spec:
         - name: kibana
 {{ tuple $envAll "kibana" | include "helm-toolkit.snippets.image" | indent 10 }}
 {{ tuple $envAll $envAll.Values.pod.resources.kibana | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
-          securityContext:
-            runAsUser: 1000
           command:
             - /tmp/kibana.sh
             - start
diff --git a/kibana/values.yaml b/kibana/values.yaml
index 295f6b43c..e1b43f619 100644
--- a/kibana/values.yaml
+++ b/kibana/values.yaml
@@ -20,7 +20,7 @@ labels:
 images:
   tags:
     apache_proxy: docker.io/httpd:2.4
-    kibana: docker.elastic.co/kibana/kibana:6.2.2
+    kibana: docker.io/kibana:5.6.4
     dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1
     image_repo_sync: docker.io/docker:17.07.0
   pull_policy: IfNotPresent