Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-flock / stx-monitor-armada-app / monitor-helm / 0004-ipv6-helm-chart-changes.patch
1 From 33fc3cb13670c8e76e7a93455865c81b9f13b0e0 Mon Sep 17 00:00:00 2001
2 From: Kevin Smith <kevin.smith@windriver.com>
3 Date: Tue, 3 Sep 2019 10:43:50 -0400
4 Subject: [PATCH 1/1] ipv6 helm chart changes
5
6 ---
7  .../elasticsearch/templates/client-deployment.yaml |  2 +-
8  .../elasticsearch/templates/data-statefulset.yaml  |  2 +-
9  .../templates/master-statefulset.yaml              |  2 +-
10  stable/filebeat/templates/configmap.yaml           | 47 +++++++++++++++++-----
11  stable/filebeat/templates/daemonset.yaml           | 21 ++++++++++
12  stable/metricbeat/templates/configmap.yaml         | 47 +++++++++++++++++-----
13  stable/metricbeat/templates/daemonset.yaml         | 21 ++++++++++
14  7 files changed, 119 insertions(+), 23 deletions(-)
15
16 diff --git a/stable/elasticsearch/templates/client-deployment.yaml b/stable/elasticsearch/templates/client-deployment.yaml
17 index 047e3c8..5625ee0 100644
18 --- a/stable/elasticsearch/templates/client-deployment.yaml
19 +++ b/stable/elasticsearch/templates/client-deployment.yaml
20 @@ -102,7 +102,7 @@ spec:
21              resourceFieldRef:
22                resource: limits.cpu
23          - name: ES_JAVA_OPTS
24 -          value: "-Djava.net.preferIPv4Stack=true -Xms{{ .Values.client.heapSize }} -Xmx{{ .Values.client.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.client.additionalJavaOpts }}"
25 +          value: "-Djava.net.preferIPv6Addresses=true -Xms{{ .Values.client.heapSize }} -Xmx{{ .Values.client.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.client.additionalJavaOpts }}"
26          {{- range $key, $value :=  .Values.cluster.env }}
27          - name: {{ $key }}
28            value: {{ $value | quote }}
29 diff --git a/stable/elasticsearch/templates/data-statefulset.yaml b/stable/elasticsearch/templates/data-statefulset.yaml
30 index a407803..44b6be1 100644
31 --- a/stable/elasticsearch/templates/data-statefulset.yaml
32 +++ b/stable/elasticsearch/templates/data-statefulset.yaml
33 @@ -120,7 +120,7 @@ spec:
34              resourceFieldRef:
35                resource: limits.cpu
36          - name: ES_JAVA_OPTS
37 -          value: "-Djava.net.preferIPv4Stack=true -Xms{{ .Values.data.heapSize }} -Xmx{{ .Values.data.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.data.additionalJavaOpts }}"
38 +          value: "-Djava.net.preferIPv6Addresses=true -Xms{{ .Values.data.heapSize }} -Xmx{{ .Values.data.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.data.additionalJavaOpts }}"
39          {{- range $key, $value :=  .Values.cluster.env }}
40          - name: {{ $key }}
41            value: {{ $value | quote }}
42 diff --git a/stable/elasticsearch/templates/master-statefulset.yaml b/stable/elasticsearch/templates/master-statefulset.yaml
43 index 048535c..7c48fe3 100644
44 --- a/stable/elasticsearch/templates/master-statefulset.yaml
45 +++ b/stable/elasticsearch/templates/master-statefulset.yaml
46 @@ -124,7 +124,7 @@ spec:
47              resourceFieldRef:
48                resource: limits.cpu
49          - name: ES_JAVA_OPTS
50 -          value: "-Djava.net.preferIPv4Stack=true -Xms{{ .Values.master.heapSize }} -Xmx{{ .Values.master.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.master.additionalJavaOpts }}"
51 +          value: "-Djava.net.preferIPv6Addresses=true -Xms{{ .Values.master.heapSize }} -Xmx{{ .Values.master.heapSize }} {{ .Values.cluster.additionalJavaOpts }} {{ .Values.master.additionalJavaOpts }}"
52          {{- range $key, $value :=  .Values.cluster.env }}
53          - name: {{ $key }}
54            value: {{ $value | quote }}
55 diff --git a/stable/filebeat/templates/configmap.yaml b/stable/filebeat/templates/configmap.yaml
56 index c895965..9433176 100644
57 --- a/stable/filebeat/templates/configmap.yaml
58 +++ b/stable/filebeat/templates/configmap.yaml
59 @@ -10,8 +10,41 @@ metadata:
60  data:
61    setup-script.sh: |-
62      #!/bin/bash
63 +    #
64 +    # This is best effort to load the template into elasticsearch
65 +    # if beats are going to elasticsearch via logstash.
66 +    #
67      BEAT='filebeat'
68      BEAT_VER=$($BEAT version | awk '{print $3}')
69 +
70 +    ADDR=$OUTPUT_ELASTICSEARCH_HOSTS
71 +    echo $ADDR
72 +
73 +    # Check if this is a map of entries.  If so, we'll only export the template
74 +    # to the first address
75 +    if [[ ${ADDR:0:1} == [ ]]; then
76 +       # Remove the square brackets
77 +       ADDR=${ADDR:1:-1}
78 +       # Take the first entry in case there are more than one
79 +       ADDR=${ADDR%%,*}
80 +    fi
81 +    echo $ADDR
82 +
83 +    # Check if user has formatted with http:// on front, if not we need to add
84 +    HTTP='http://'
85 +    if [[ ${ADDR} == http* ]]; then
86 +       HTTP=''
87 +    fi
88 +    echo $HTTP
89 +
90 +    # Check for ip address containing special characters where -g must be used in curl command
91 +    # IPV6 Addresses should come in with square braces around the address.
92 +    CURL_G=''
93 +    if [[ ${ADDR} == *[* ]]; then
94 +       CURL_G=' -g  '
95 +    fi
96 +    echo $CURL_G
97 +
98      # check if logstash output is enabled, via crude parsing of the .yml file.
99      sed -e '/output.logstash/,/enabled:/!d' ${BEAT}.yml  | grep -i true
100      if [[ $? -eq 0 ]]; then
101 @@ -20,15 +53,9 @@ data:
102         # remove the lifecycle section of the yaml, as elasticsearch will choke
103         # on it as oss version does not support ilm.
104         sed -i '/lifecycle/,+3d' /tmp/beat.template.json
105 -       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
106 -       # prime the index as a write index
107 -       curl -XPUT -H "Content-Type: application/json" -d   "{
108 -          \"aliases\": {
109 -             \"{BEAT}-{$BEAT_VER}\": {
110 -                \"is_write_index\": \"true\"
111 -             }
112 -          }
113 -       }" http://{$STX_ELASTICSEARCH_CLIENT_SERVICE_HOST}:{$STX_ELASTICSEARCH_CLIENT_SERVICE_PORT_HTTP}/{$BEAT}-{$BEAT_VER}-000001
114 +       curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR/_template/$BEAT-$BEAT_VER -d@/tmp/beat.template.json
115      else
116 -        echo "logstash not configured, not exporting template, should be done for us."
117 +       echo "logstash not configured, not exporting template, should be done for us."
118      fi
119 +    # Above is non-fatal if there is a problem.  Always pass.
120 +    exit 0
121 diff --git a/stable/filebeat/templates/daemonset.yaml b/stable/filebeat/templates/daemonset.yaml
122 index 00a5519..b8536fb 100644
123 --- a/stable/filebeat/templates/daemonset.yaml
124 +++ b/stable/filebeat/templates/daemonset.yaml
125 @@ -53,6 +53,17 @@ spec:
126            mountPath: /usr/share/filebeat/filebeat.yml
127            readOnly: true
128            subPath: filebeat.yml
129 +        env:
130 +      ## make output.elasticsearch parms visible
131 +      {{- range $key, $value := .Values.config}}
132 +      {{- $configname := $key | upper | replace "." "_" -}}
133 +      {{ if eq $configname "OUTPUT_ELASTICSEARCH" -}}
134 +      {{- range $key2, $value2 := $value}}
135 +        - name: "{{ $configname }}_{{ $key2 | upper }}"
136 +          value: {{ $value2 | quote }}
137 +      {{- end }}
138 +      {{- end }}
139 +      {{- end }}
140  {{- if .Values.indexTemplateLoad }}
141        - name: "load-es-template"
142          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
143 @@ -95,6 +106,16 @@ spec:
144            valueFrom:
145              fieldRef:
146                fieldPath: spec.nodeName
147 +      ## make output.elasticsearch parms visible
148 +      {{- range $key, $value := .Values.config}}
149 +      {{- $configname := $key | upper | replace "." "_" -}}
150 +      {{ if eq $configname "OUTPUT_ELASTICSEARCH" -}}
151 +      {{- range $key2, $value2 := $value}}
152 +        - name: "{{ $configname }}_{{ $key2 | upper }}"
153 +          value: {{ $value2 | quote }}
154 +      {{- end }}
155 +      {{- end }}
156 +      {{- end }}
157  {{- if .Values.extraVars }}
158  {{ toYaml .Values.extraVars | indent 8 }}
159  {{- end }}
160 diff --git a/stable/metricbeat/templates/configmap.yaml b/stable/metricbeat/templates/configmap.yaml
161 index 21890b4..f990f0c 100644
162 --- a/stable/metricbeat/templates/configmap.yaml
163 +++ b/stable/metricbeat/templates/configmap.yaml
164 @@ -10,8 +10,41 @@ metadata:
165  data:
166    setup-script.sh: |-
167      #!/bin/bash
168 +    #
169 +    # This is best effort to load the template into elasticsearch
170 +    # if beats are going to elasticsearch via logstash.
171 +    #
172      BEAT='metricbeat'
173      BEAT_VER=$($BEAT version | awk '{print $3}')
174 +
175 +    ADDR=$OUTPUT_ELASTICSEARCH_HOSTS
176 +    echo $ADDR
177 +
178 +    # Check if this is a map of entries.  If so, we'll only export the template
179 +    # to the first address
180 +    if [[ ${ADDR:0:1} == [ ]]; then
181 +       # Remove the square brackets
182 +       ADDR=${ADDR:1:-1}
183 +       # Take the first entry in case there are more than one
184 +       ADDR=${ADDR%%,*}
185 +    fi
186 +    echo $ADDR
187 +
188 +    # Check if user has formatted with http:// on front, if not we need to add
189 +    HTTP='http://'
190 +    if [[ ${ADDR} == http* ]]; then
191 +       HTTP=''
192 +    fi
193 +    echo $HTTP
194 +
195 +    # Check for ip address containing special characters where -g must be used in curl command
196 +    # IPV6 Addresses should come in with square braces around the address.
197 +    CURL_G=''
198 +    if [[ ${ADDR} == *[* ]]; then
199 +       CURL_G=' -g  '
200 +    fi
201 +    echo $CURL_G
202 +
203      # check if logstash output is enabled, via crude parsing of the .yml file.
204      sed -e '/output.logstash/,/enabled:/!d' ${BEAT}.yml  | grep -i true
205      if [[ $? -eq 0 ]]; then
206 @@ -20,15 +53,9 @@ data:
207         # remove the lifecycle section of the yaml, as elasticsearch will choke
208         # on it as oss version does not support ilm.
209         sed -i '/lifecycle/,+3d' /tmp/beat.template.json
210 -       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
211 -       # prime the index as a write index
212 -       curl -XPUT -H "Content-Type: application/json" -d   "{
213 -          \"aliases\": {
214 -             \"{BEAT}-{$BEAT_VER}\": {
215 -                \"is_write_index\": \"true\"
216 -             }
217 -          }
218 -       }" http://{$STX_ELASTICSEARCH_CLIENT_SERVICE_HOST}:{$STX_ELASTICSEARCH_CLIENT_SERVICE_PORT_HTTP}/{$BEAT}-{$BEAT_VER}-000001
219 +       curl -v $CURL_G -XPUT -H "Content-Type: application/json" $HTTP$ADDR/_template/$BEAT-$BEAT_VER -d@/tmp/beat.template.json
220      else
221 -        echo "logstash not configured, not exporting template, should be done for us."
222 +       echo "logstash not configured, not exporting template, should be done for us."
223      fi
224 +    # Above is non-fatal if there is a problem.  Always pass.
225 +    exit 0
226 diff --git a/stable/metricbeat/templates/daemonset.yaml b/stable/metricbeat/templates/daemonset.yaml
227 index e3d7437..1ae3a34 100644
228 --- a/stable/metricbeat/templates/daemonset.yaml
229 +++ b/stable/metricbeat/templates/daemonset.yaml
230 @@ -49,6 +49,17 @@ spec:
231            readOnly: true
232            subPath: metricbeat.yml
233          env:
234 +      ## make output.elasticsearch parms visible
235 +      {{- range $key, $value := .Values.daemonset.config}}
236 +      {{- $configname := $key | upper | replace "." "_" -}}
237 +      {{ if eq $configname "OUTPUT_ELASTICSEARCH" -}}
238 +      {{- range $key2, $value2 := $value}}
239 +        - name: "{{ $configname }}_{{ $key2 | upper }}"
240 +          value: {{ $value2 | quote }}
241 +      {{- end }}
242 +      {{- end }}
243 +      {{- end }}
244 +
245        containers:
246        - name: {{ .Chart.Name }}
247          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
248 @@ -73,6 +84,16 @@ spec:
249            valueFrom:
250              fieldRef:
251                fieldPath: spec.nodeName
252 +      ## make output.elasticsearch parms visible
253 +      {{- range $key, $value := .Values.daemonset.config}}
254 +      {{- $configname := $key | upper | replace "." "_" -}}
255 +      {{ if eq $configname "OUTPUT_ELASTICSEARCH" -}}
256 +      {{- range $key2, $value2 := $value}}
257 +        - name: "{{ $configname }}_{{ $key2 | upper }}"
258 +          value: {{ $value2 | quote }}
259 +      {{- end }}
260 +      {{- end }}
261 +      {{- end }}
262  {{- if .Values.extraEnv }}
263  {{ toYaml .Values.extraEnv | indent 8 }}
264  {{- end }}
265 -- 
266 1.8.3.1
267