Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-flock / stx-monitor-armada-app / monitor-helm / 0003-helm-chart-changes-for-stx-monitor.patch
1 From d22ad4870b78f74298189e383697ae6163ef49d7 Mon Sep 17 00:00:00 2001
2 From: Kevin Smith <kevin.smith@windriver.com>
3 Date: Wed, 17 Jul 2019 15:13:44 -0400
4 Subject: [PATCH 1/1] helm chart changes for stx monitor
5
6 ---
7  stable/elasticsearch/values.yaml           |  2 +-
8  stable/filebeat/templates/configmap.yaml   | 34 ++++++++++++++++++++++++++++++
9  stable/filebeat/templates/daemonset.yaml   | 15 +++++++++++++
10  stable/filebeat/values.yaml                |  9 ++------
11  stable/kibana/values.yaml                  |  4 ++--
12  stable/logstash/templates/ingress.yaml     |  2 +-
13  stable/logstash/templates/statefulset.yaml |  7 +++---
14  stable/logstash/values.yaml                |  3 ++-
15  stable/metricbeat/templates/configmap.yaml | 34 ++++++++++++++++++++++++++++++
16  stable/metricbeat/templates/daemonset.yaml | 26 +++++++++++++++++++++++
17  stable/metricbeat/values.yaml              |  4 ++--
18  11 files changed, 122 insertions(+), 18 deletions(-)
19  create mode 100755 stable/filebeat/templates/configmap.yaml
20  create mode 100755 stable/metricbeat/templates/configmap.yaml
21
22 diff --git a/stable/elasticsearch/values.yaml b/stable/elasticsearch/values.yaml
23 index bbc03dd..6dcd9b0 100644
24 --- a/stable/elasticsearch/values.yaml
25 +++ b/stable/elasticsearch/values.yaml
26 @@ -33,7 +33,7 @@ podSecurityPolicy:
27  
28  image:
29    repository: "docker.elastic.co/elasticsearch/elasticsearch-oss"
30 -  tag: "6.7.0"
31 +  tag: "7.2.0"
32    pullPolicy: "IfNotPresent"
33    # If specified, use these secrets to access the image
34    # pullSecrets:
35 diff --git a/stable/filebeat/templates/configmap.yaml b/stable/filebeat/templates/configmap.yaml
36 new file mode 100755
37 index 0000000..c895965
38 --- /dev/null
39 +++ b/stable/filebeat/templates/configmap.yaml
40 @@ -0,0 +1,34 @@
41 +apiVersion: v1
42 +kind: ConfigMap
43 +metadata:
44 +  name: {{ template "filebeat.fullname" . }}
45 +  labels:
46 +    app: {{ template "filebeat.fullname" . }}
47 +    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
48 +    release: "{{ .Release.Name }}"
49 +    heritage: "{{ .Release.Service }}"
50 +data:
51 +  setup-script.sh: |-
52 +    #!/bin/bash
53 +    BEAT='filebeat'
54 +    BEAT_VER=$($BEAT version | awk '{print $3}')
55 +    # check if logstash output is enabled, via crude parsing of the .yml file.
56 +    sed -e '/output.logstash/,/enabled:/!d' ${BEAT}.yml  | grep -i true
57 +    if [[ $? -eq 0 ]]; then
58 +       echo "logstash configured, exporting template to elasticsearch"
59 +       $BEAT export template > /tmp/beat.template.json
60 +       # remove the lifecycle section of the yaml, as elasticsearch will choke
61 +       # on it as oss version does not support ilm.
62 +       sed -i '/lifecycle/,+3d' /tmp/beat.template.json
63 +       curl -XPUT -H "Content-Type: application/json" http://{$STX_ELASTICSEARCH_CLIENT_SERVICE_HOST}:{$STX_ELASTICSEARCH_CLIENT_SERVICE_PORT_HTTP}/_template/{$BEAT}-{$BEAT_VER} -d@/tmp/beat.template.json
64 +       # prime the index as a write index
65 +       curl -XPUT -H "Content-Type: application/json" -d   "{
66 +          \"aliases\": {
67 +             \"{BEAT}-{$BEAT_VER}\": {
68 +                \"is_write_index\": \"true\"
69 +             }
70 +          }
71 +       }" http://{$STX_ELASTICSEARCH_CLIENT_SERVICE_HOST}:{$STX_ELASTICSEARCH_CLIENT_SERVICE_PORT_HTTP}/{$BEAT}-{$BEAT_VER}-000001
72 +    else
73 +        echo "logstash not configured, not exporting template, should be done for us."
74 +    fi
75 diff --git a/stable/filebeat/templates/daemonset.yaml b/stable/filebeat/templates/daemonset.yaml
76 index 2b8e265..00a5519 100644
77 --- a/stable/filebeat/templates/daemonset.yaml
78 +++ b/stable/filebeat/templates/daemonset.yaml
79 @@ -38,6 +38,21 @@ spec:
80        priorityClassName: "{{ .Values.priorityClassName }}"
81  {{- end }}
82        initContainers:
83 +      - name: "setup-script"
84 +        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
85 +        imagePullPolicy: {{ .Values.image.pullPolicy }}
86 +        command:
87 +        - /bin/bash
88 +        - -c
89 +        - /usr/share/filebeat/setup-script.sh
90 +        volumeMounts:
91 +        - mountPath: /usr/share/filebeat/setup-script.sh
92 +          name: setupscript 
93 +          subPath: setup-script.sh
94 +        - name: filebeat-config
95 +          mountPath: /usr/share/filebeat/filebeat.yml
96 +          readOnly: true
97 +          subPath: filebeat.yml
98  {{- if .Values.indexTemplateLoad }}
99        - name: "load-es-template"
100          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
101 diff --git a/stable/filebeat/values.yaml b/stable/filebeat/values.yaml
102 index 1907ffa..b4b766f 100644
103 --- a/stable/filebeat/values.yaml
104 +++ b/stable/filebeat/values.yaml
105 @@ -1,15 +1,10 @@
106  image:
107    repository: docker.elastic.co/beats/filebeat-oss
108 -  tag: 6.7.0
109 +  tag: 7.2.0
110    pullPolicy: IfNotPresent
111  
112  config:
113    filebeat.config:
114 -    prospectors:
115 -      # Mounted `filebeat-prospectors` configmap:
116 -      path: ${path.config}/prospectors.d/*.yml
117 -      # Reload prospectors configs as they change:
118 -      reload.enabled: false
119      modules:
120        path: ${path.config}/modules.d/*.yml
121        # Reload module configs as they change:
122 @@ -18,7 +13,7 @@ config:
123    processors:
124      - add_cloud_metadata:
125  
126 -  filebeat.prospectors:
127 +  filebeat.inputs:
128      - type: log
129        enabled: true
130        paths:
131 diff --git a/stable/kibana/values.yaml b/stable/kibana/values.yaml
132 index a3310f9..4ce4b2a 100644
133 --- a/stable/kibana/values.yaml
134 +++ b/stable/kibana/values.yaml
135 @@ -1,6 +1,6 @@
136  image:
137    repository: "docker.elastic.co/kibana/kibana-oss"
138 -  tag: "6.7.0"
139 +  tag: "7.2.0"
140    pullPolicy: "IfNotPresent"
141  
142  testFramework:
143 @@ -25,7 +25,7 @@ files:
144      ## Default Kibana configuration from kibana-docker.
145      server.name: kibana
146      server.host: "0"
147 -    elasticsearch.url: http://elasticsearch:9200
148 +    elasticsearch.hosts: http://elasticsearch:9200
149  
150      ## Custom config properties below
151      ## Ref: https://www.elastic.co/guide/en/kibana/current/settings.html
152 diff --git a/stable/logstash/templates/ingress.yaml b/stable/logstash/templates/ingress.yaml
153 index d924504..0e26f89 100644
154 --- a/stable/logstash/templates/ingress.yaml
155 +++ b/stable/logstash/templates/ingress.yaml
156 @@ -33,6 +33,6 @@ spec:
157            - path: {{ $ingressPath }}
158              backend:
159                serviceName: {{ $fullName }}
160 -              servicePort: http
161 +              servicePort: 9600
162    {{- end }}
163  {{- end }}
164 diff --git a/stable/logstash/templates/statefulset.yaml b/stable/logstash/templates/statefulset.yaml
165 index d2bbc32..cca0050 100644
166 --- a/stable/logstash/templates/statefulset.yaml
167 +++ b/stable/logstash/templates/statefulset.yaml
168 @@ -25,11 +25,8 @@ spec:
169          {{ $key }}: {{ $value | quote }}
170          {{- end }}
171        {{- end }}
172 -      annotations:
173 -        checksum/patterns: {{ include (print $.Template.BasePath "/patterns-config.yaml") . | sha256sum }}
174 -        checksum/templates: {{ include (print $.Template.BasePath "/files-config.yaml") . | sha256sum }}
175 -        checksum/pipeline: {{ include (print $.Template.BasePath "/pipeline-config.yaml") . | sha256sum }}
176        {{- if .Values.podAnnotations }}
177 +      annotations:
178          ## Custom pod annotations
179          {{- range $key, $value := .Values.podAnnotations }}
180          {{ $key }}: {{ $value | quote }}
181 @@ -46,6 +43,8 @@ spec:
182        imagePullSecrets:
183  {{ toYaml .Values.image.pullSecrets | indent 8 }}
184        {{- end }}
185 +      hostNetwork: true
186 +      dnsPolicy: ClusterFirstWithHostNet
187        containers:
188  
189          ## logstash
190 diff --git a/stable/logstash/values.yaml b/stable/logstash/values.yaml
191 index a9eb158..9a452b1 100644
192 --- a/stable/logstash/values.yaml
193 +++ b/stable/logstash/values.yaml
194 @@ -10,7 +10,7 @@ terminationGracePeriodSeconds: 30
195  
196  image:
197    repository: docker.elastic.co/logstash/logstash-oss
198 -  tag: 6.7.0
199 +  tag: 7.2.0
200    pullPolicy: IfNotPresent
201    ## Add secrets manually via kubectl on kubernetes cluster and reference here
202    #  pullSecrets:
203 @@ -67,6 +67,7 @@ ingress:
204    path: /
205    hosts:
206      - logstash.cluster.local
207 +  servicePort: 5044
208    tls: []
209    #  - secretName: logstash-tls
210    #    hosts:
211 diff --git a/stable/metricbeat/templates/configmap.yaml b/stable/metricbeat/templates/configmap.yaml
212 new file mode 100755
213 index 0000000..21890b4
214 --- /dev/null
215 +++ b/stable/metricbeat/templates/configmap.yaml
216 @@ -0,0 +1,34 @@
217 +apiVersion: v1
218 +kind: ConfigMap
219 +metadata:
220 +  name: {{ template "metricbeat.fullname" . }}
221 +  labels:
222 +    app: {{ template "metricbeat.fullname" . }}
223 +    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
224 +    release: "{{ .Release.Name }}"
225 +    heritage: "{{ .Release.Service }}"
226 +data:
227 +  setup-script.sh: |-
228 +    #!/bin/bash
229 +    BEAT='metricbeat'
230 +    BEAT_VER=$($BEAT version | awk '{print $3}')
231 +    # check if logstash output is enabled, via crude parsing of the .yml file.
232 +    sed -e '/output.logstash/,/enabled:/!d' ${BEAT}.yml  | grep -i true
233 +    if [[ $? -eq 0 ]]; then
234 +       echo "logstash configured, exporting template to elasticsearch"
235 +       $BEAT export template > /tmp/beat.template.json
236 +       # remove the lifecycle section of the yaml, as elasticsearch will choke
237 +       # on it as oss version does not support ilm.
238 +       sed -i '/lifecycle/,+3d' /tmp/beat.template.json
239 +       curl -XPUT -H "Content-Type: application/json" http://{$STX_ELASTICSEARCH_CLIENT_SERVICE_HOST}:{$STX_ELASTICSEARCH_CLIENT_SERVICE_PORT_HTTP}/_template/{$BEAT}-{$BEAT_VER} -d@/tmp/beat.template.json
240 +       # prime the index as a write index
241 +       curl -XPUT -H "Content-Type: application/json" -d   "{
242 +          \"aliases\": {
243 +             \"{BEAT}-{$BEAT_VER}\": {
244 +                \"is_write_index\": \"true\"
245 +             }
246 +          }
247 +       }" http://{$STX_ELASTICSEARCH_CLIENT_SERVICE_HOST}:{$STX_ELASTICSEARCH_CLIENT_SERVICE_PORT_HTTP}/{$BEAT}-{$BEAT_VER}-000001
248 +    else
249 +        echo "logstash not configured, not exporting template, should be done for us."
250 +    fi
251 diff --git a/stable/metricbeat/templates/daemonset.yaml b/stable/metricbeat/templates/daemonset.yaml
252 index eadfb96..e3d7437 100644
253 --- a/stable/metricbeat/templates/daemonset.yaml
254 +++ b/stable/metricbeat/templates/daemonset.yaml
255 @@ -32,6 +32,23 @@ spec:
256    {{- end }}
257  {{- end }}
258      spec:
259 +      initContainers:
260 +      - name: "setup-script"
261 +        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
262 +        imagePullPolicy: {{ .Values.image.pullPolicy }}
263 +        command:
264 +        - /bin/bash
265 +        - -c
266 +        - /usr/share/metricbeat/setup-script.sh
267 +        volumeMounts:
268 +        - mountPath: /usr/share/metricbeat/setup-script.sh
269 +          name: setupscript
270 +          subPath: setup-script.sh
271 +        - name: config
272 +          mountPath: /usr/share/metricbeat/metricbeat.yml
273 +          readOnly: true
274 +          subPath: metricbeat.yml
275 +        env:
276        containers:
277        - name: {{ .Chart.Name }}
278          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
279 @@ -62,6 +79,7 @@ spec:
280          securityContext:
281            runAsUser: 0
282          resources:
283 +
284  {{- if .Values.daemonset.resources }}
285  {{ toYaml .Values.daemonset.resources | indent 10 }}
286  {{- else if .Values.resources }}
287 @@ -85,6 +103,10 @@ spec:
288            readOnly: true
289          - name: dockersock
290            mountPath: /var/run/docker.sock
291 +#Mount the script so we can see it from running containter
292 +        - mountPath: /usr/share/metricbeat/setup-script.sh
293 +          name: setupscript
294 +          subPath: setup-script.sh
295  {{- if .Values.extraVolumeMounts }}
296  {{ toYaml .Values.extraVolumeMounts | indent 8 }}
297  {{- end }}
298 @@ -108,6 +130,10 @@ spec:
299        - name: dockersock
300          hostPath:
301            path: /var/run/docker.sock
302 +      - name: setupscript
303 +        configMap:
304 +          name: {{ template "metricbeat.fullname" . }}
305 +          defaultMode: 0755
306  {{- if .Values.extraVolumes }}
307  {{ toYaml .Values.extraVolumes | indent 6 }}
308  {{- end }}
309 diff --git a/stable/metricbeat/values.yaml b/stable/metricbeat/values.yaml
310 index 5094639..2908a1b 100644
311 --- a/stable/metricbeat/values.yaml
312 +++ b/stable/metricbeat/values.yaml
313 @@ -1,6 +1,6 @@
314  image:
315 -  repository: docker.elastic.co/beats/metricbeat
316 -  tag: 6.7.0
317 +  repository: docker.elastic.co/beats/metricbeat-oss
318 +  tag: 7.2.0
319    pullPolicy: IfNotPresent
320  
321  # The instances created by daemonset retrieve most metrics from the host
322 -- 
323 1.8.3.1
324