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

Skip referencing the secret elasticsearch-certs if .Values.elasticsearchCertificateSecret is empty #1745

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions kibana/templates/configmap-helm-scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ metadata:
{{- end }}
data:
manage-es-token.js: |
const http = require('http');
const https = require('https');
const fs = require('fs');

Expand All @@ -31,8 +32,8 @@ data:
const esUsername = getEnvVar('ELASTICSEARCH_USERNAME');
const esPassword = getEnvVar('ELASTICSEARCH_PASSWORD');
const esAuth = esUsername + ':' + esPassword;
const esCaFile = getEnvVar('ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES');
const esCa = fs.readFileSync(esCaFile);
const esCaFile = process.env['ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES'];
const esCa = esCaFile ? fs.readFileSync(esCaFile) : null;

// Kubernetes API
const k8sHostname = getEnvVar('KUBERNETES_SERVICE_HOST');
Expand Down Expand Up @@ -75,9 +76,9 @@ data:
};

// With thanks to https://stackoverflow.com/questions/57332374/how-to-chain-http-request
function requestPromise(url, httpsOptions, extraOptions = {}) {
function requestPromise(url, httpOptions, extraOptions = {}) {
return new Promise((resolve, reject) => {
const request = https.request(url, httpsOptions, response => {
const request = (/^https:/.test(url) ? https : http).request(url, httpOptions, response => {

console.log('statusCode:', response.statusCode);

Expand Down
4 changes: 4 additions & 0 deletions kibana/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ spec:
volumes:
- name: kibana-tokens
emptyDir: {}
{{- if .Values.elasticsearchCertificateSecret }}
- name: elasticsearch-certs
secret:
secretName: {{ .Values.elasticsearchCertificateSecret }}
{{- end }}
{{- if .Values.kibanaConfig }}
- name: kibanaconfig
configMap:
Expand Down Expand Up @@ -163,9 +165,11 @@ spec:
resources:
{{ toYaml .Values.resources | indent 10 }}
volumeMounts:
{{- if .Values.elasticsearchCertificateSecret }}
- name: elasticsearch-certs
mountPath: {{ template "kibana.home_dir" . }}/config/certs
readOnly: true
{{- end }}
- name: kibana-tokens
mountPath: {{ template "kibana.home_dir" . }}/config/tokens
readOnly: true
Expand Down
4 changes: 4 additions & 0 deletions kibana/templates/post-delete-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@ spec:
- name: ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES
value: "{{ template "kibana.home_dir" . }}/config/certs/{{ .Values.elasticsearchCertificateAuthoritiesFile }}"
volumeMounts:
{{- if .Values.elasticsearchCertificateSecret }}
- name: elasticsearch-certs
mountPath: {{ template "kibana.home_dir" . }}/config/certs
readOnly: true
{{- end }}
- name: kibana-helm-scripts
mountPath: {{ template "kibana.home_dir" . }}/helm-scripts
serviceAccount: post-delete-{{ template "kibana.fullname" . }}
volumes:
{{- if .Values.elasticsearchCertificateSecret }}
- name: elasticsearch-certs
secret:
secretName: {{ .Values.elasticsearchCertificateSecret }}
{{- end }}
- name: kibana-helm-scripts
configMap:
name: {{ template "kibana.fullname" . }}-helm-scripts
Expand Down
6 changes: 6 additions & 0 deletions kibana/templates/pre-install-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,25 @@ spec:
secretKeyRef:
name: {{ .Values.elasticsearchCredentialSecret }}
key: password
{{- if .Values.elasticsearchCertificateSecret }}
- name: ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES
value: "{{ template "kibana.home_dir" . }}/config/certs/{{ .Values.elasticsearchCertificateAuthoritiesFile }}"
{{- end }}
volumeMounts:
{{- if .Values.elasticsearchCertificateSecret }}
- name: elasticsearch-certs
mountPath: {{ template "kibana.home_dir" . }}/config/certs
readOnly: true
{{- end }}
- name: kibana-helm-scripts
mountPath: {{ template "kibana.home_dir" . }}/helm-scripts
serviceAccount: pre-install-{{ template "kibana.fullname" . }}
volumes:
{{- if .Values.elasticsearchCertificateSecret }}
- name: elasticsearch-certs
secret:
secretName: {{ .Values.elasticsearchCertificateSecret }}
{{- end }}
- name: kibana-helm-scripts
configMap:
name: {{ template "kibana.fullname" . }}-helm-scripts
Expand Down