Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit 717878f

Browse files
committed
Skip referencing the secret elasticsearch-certs if .Values.elasticsearchCertificateSecret is empty
Signed-off-by: Nobi <[email protected]>
1 parent 2fd64d0 commit 717878f

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

kibana/templates/configmap-helm-scripts.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ metadata:
1414
{{- end }}
1515
data:
1616
manage-es-token.js: |
17+
const http = require('http');
1718
const https = require('https');
1819
const fs = require('fs');
1920
@@ -31,8 +32,8 @@ data:
3132
const esUsername = getEnvVar('ELASTICSEARCH_USERNAME');
3233
const esPassword = getEnvVar('ELASTICSEARCH_PASSWORD');
3334
const esAuth = esUsername + ':' + esPassword;
34-
const esCaFile = getEnvVar('ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES');
35-
const esCa = fs.readFileSync(esCaFile);
35+
const esCaFile = process.env['ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES'];
36+
const esCa = esCaFile ? fs.readFileSync(esCaFile) : null;
3637
3738
// Kubernetes API
3839
const k8sHostname = getEnvVar('KUBERNETES_SERVICE_HOST');
@@ -75,9 +76,9 @@ data:
7576
};
7677
7778
// With thanks to https://stackoverflow.com/questions/57332374/how-to-chain-http-request
78-
function requestPromise(url, httpsOptions, extraOptions = {}) {
79+
function requestPromise(url, httpOptions, extraOptions = {}) {
7980
return new Promise((resolve, reject) => {
80-
const request = https.request(url, httpsOptions, response => {
81+
const request = (/^https:/.test(url) ? https : http).request(url, httpOptions, response => {
8182
8283
console.log('statusCode:', response.statusCode);
8384

kibana/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ spec:
4949
volumes:
5050
- name: kibana-tokens
5151
emptyDir: {}
52+
{{- if .Values.elasticsearchCertificateSecret }}
5253
- name: elasticsearch-certs
5354
secret:
5455
secretName: {{ .Values.elasticsearchCertificateSecret }}
56+
{{- end }}
5557
{{- if .Values.kibanaConfig }}
5658
- name: kibanaconfig
5759
configMap:
@@ -163,9 +165,11 @@ spec:
163165
resources:
164166
{{ toYaml .Values.resources | indent 10 }}
165167
volumeMounts:
168+
{{- if .Values.elasticsearchCertificateSecret }}
166169
- name: elasticsearch-certs
167170
mountPath: {{ template "kibana.home_dir" . }}/config/certs
168171
readOnly: true
172+
{{- end }}
169173
- name: kibana-tokens
170174
mountPath: {{ template "kibana.home_dir" . }}/config/tokens
171175
readOnly: true

kibana/templates/post-delete-job.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,20 @@ spec:
3838
- name: ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES
3939
value: "{{ template "kibana.home_dir" . }}/config/certs/{{ .Values.elasticsearchCertificateAuthoritiesFile }}"
4040
volumeMounts:
41+
{{- if .Values.elasticsearchCertificateSecret }}
4142
- name: elasticsearch-certs
4243
mountPath: {{ template "kibana.home_dir" . }}/config/certs
4344
readOnly: true
45+
{{- end }}
4446
- name: kibana-helm-scripts
4547
mountPath: {{ template "kibana.home_dir" . }}/helm-scripts
4648
serviceAccount: post-delete-{{ template "kibana.fullname" . }}
4749
volumes:
50+
{{- if .Values.elasticsearchCertificateSecret }}
4851
- name: elasticsearch-certs
4952
secret:
5053
secretName: {{ .Values.elasticsearchCertificateSecret }}
54+
{{- end }}
5155
- name: kibana-helm-scripts
5256
configMap:
5357
name: {{ template "kibana.fullname" . }}-helm-scripts

kibana/templates/pre-install-job.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,25 @@ spec:
3535
secretKeyRef:
3636
name: {{ .Values.elasticsearchCredentialSecret }}
3737
key: password
38+
{{- if .Values.elasticsearchCertificateSecret }}
3839
- name: ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES
3940
value: "{{ template "kibana.home_dir" . }}/config/certs/{{ .Values.elasticsearchCertificateAuthoritiesFile }}"
41+
{{- end }}
4042
volumeMounts:
43+
{{- if .Values.elasticsearchCertificateSecret }}
4144
- name: elasticsearch-certs
4245
mountPath: {{ template "kibana.home_dir" . }}/config/certs
4346
readOnly: true
47+
{{- end }}
4448
- name: kibana-helm-scripts
4549
mountPath: {{ template "kibana.home_dir" . }}/helm-scripts
4650
serviceAccount: pre-install-{{ template "kibana.fullname" . }}
4751
volumes:
52+
{{- if .Values.elasticsearchCertificateSecret }}
4853
- name: elasticsearch-certs
4954
secret:
5055
secretName: {{ .Values.elasticsearchCertificateSecret }}
56+
{{- end }}
5157
- name: kibana-helm-scripts
5258
configMap:
5359
name: {{ template "kibana.fullname" . }}-helm-scripts

0 commit comments

Comments
 (0)