Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

IN-105: Enabled SSL and HTTPS for Elasticsearch #69

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
be830b0
IN-105: Implemented basic SSL for node communication but not https to…
michael-amiethyst Oct 25, 2018
568b92d
IN-105: Removed unneeded ssl config.
michael-amiethyst Oct 25, 2018
3fb01b7
IN-105: Enabled HTTPS client connections for elasticsearch.
michael-amiethyst Oct 26, 2018
a5dfd67
IN-105: Added Hello test script and basic Hashicorp Vault configuration.
michael-amiethyst Nov 1, 2018
cbbf3e6
IN-105: Removed initContainer, expanded shell script. Broken build.
michael-amiethyst Nov 2, 2018
e0710f1
IN-105: Removed postStart. Added permissions. Improved startscript.…
michael-amiethyst Nov 13, 2018
a9c1731
IN-105: Enabled SSL and HTTPS by base64 encoding the p12 cert file.
michael-amiethyst Nov 13, 2018
018988b
IN-105: Included .p12 certificate file as base64 encoded data in helm…
michael-amiethyst Nov 14, 2018
eaa559a
IN-105: Renamed hello.sh file to unencode-certificates.sh.
michael-amiethyst Nov 15, 2018
0c64826
IN-105: Minor comment change.
michael-amiethyst Nov 15, 2018
eb03e89
IN-105: Fixed unit test. Incremented version number.
michael-amiethyst Nov 19, 2018
7ce716a
IN-105: Removed unneeded RBAC and entry in values.yaml.
michael-amiethyst Nov 19, 2018
2c82271
IN-109: Removed unneeded comments.
michael-amiethyst Nov 26, 2018
5ef6f5a
chore: update maintainer
philoserf Nov 28, 2018
3a2c7ee
Merge pull request #70 from philoserf-contribs/update-maintainer
philoserf Nov 29, 2018
85bef94
JENKINSCISKIP
Nov 29, 2018
450653c
IN-9: Modified values.yaml to pass code review.
michael-amiethyst Dec 4, 2018
fc986ff
IN-105: Implemented basic SSL for node communication but not https to…
michael-amiethyst Oct 25, 2018
2ddc005
IN-105: Removed unneeded ssl config.
michael-amiethyst Oct 25, 2018
25e03bc
IN-105: Enabled HTTPS client connections for elasticsearch.
michael-amiethyst Oct 26, 2018
92ee593
IN-105: Added Hello test script and basic Hashicorp Vault configuration.
michael-amiethyst Nov 1, 2018
d9ed56e
IN-105: Removed initContainer, expanded shell script. Broken build.
michael-amiethyst Nov 2, 2018
c6580b2
IN-105: Removed postStart. Added permissions. Improved startscript.…
michael-amiethyst Nov 13, 2018
ba6730d
IN-105: Enabled SSL and HTTPS by base64 encoding the p12 cert file.
michael-amiethyst Nov 13, 2018
9a854eb
IN-105: Included .p12 certificate file as base64 encoded data in helm…
michael-amiethyst Nov 14, 2018
49854bf
IN-105: Renamed hello.sh file to unencode-certificates.sh.
michael-amiethyst Nov 15, 2018
bcc9613
IN-105: Minor comment change.
michael-amiethyst Nov 15, 2018
3791ebc
IN-105: Fixed unit test. Incremented version number.
michael-amiethyst Nov 19, 2018
a401b2a
IN-105: Removed unneeded RBAC and entry in values.yaml.
michael-amiethyst Nov 19, 2018
0f36c39
IN-109: Removed unneeded comments.
michael-amiethyst Nov 26, 2018
7873cee
IN-9: Modified values.yaml to pass code review.
michael-amiethyst Dec 4, 2018
1aeb824
Merge branch 'master' of https://github.com/michaelamiethyst/chart-el…
michael-amiethyst Dec 5, 2018
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
2 changes: 1 addition & 1 deletion .versionfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.12
0.1.13
6 changes: 3 additions & 3 deletions charts/elasticsearch-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: elasticsearch-chart
version: 0.1.12
version: 0.2.00
michaelamiethyst marked this conversation as resolved.
Show resolved Hide resolved
description: Elasticsearch for Kubernetes
keywords:
- elasticsearch
Expand All @@ -10,7 +10,7 @@ sources:
- https://github.com/samsung-cnct/chart-elasticsearch
- https://github.com/elastic/elasticsearch
maintainers:
- name: Samsung CNCT
email: samsung[email protected]
- name: Samsung CNCT OSS Maintainers
email: oss-maintainer@samsung-cnct.io
icon: https://github.com/samsung-cnct/solas/docs/images/samsung-logo.svg
engine: gotpl
4 changes: 4 additions & 0 deletions charts/elasticsearch-chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ data:
elasticsearch.yml: |-
{{- include "elasticsearch.yml.tpl" . | indent 4}}
{{ end }}
unencode-certificates.sh: |-
{{- include "unencode-certificates.sh.tpl" . | indent 4}}
elastic-certificates.p12.b64: |-
MIINbwIBAzCCDSgGCSqGSIb3DQEHAaCCDRkEgg0VMIINETCCBW0GCSqGSIb3DQEHAaCCBV4EggVaMIIFVjCCBVIGCyqGSIb3DQEMCgECoIIE+zCCBPcwKQYKKoZIhvcNAQwBAzAbBBSrTzyNwO6NPNKPDqQWk829cJnTWgIDAMNQBIIEyAnqtJHxp5lW2fg8J5DzKjAMjKQnY0lZ+M/Q6Bm0bNgQ+9QVRo+JjVXfIUTN7lFrLthPFNEmPToJmCWATTdy4j8B7mSvIXxk7VoOwCtwvxwMDgAGP/t7faSMx3F2pU7OADok8bv/BSS9QJx5P5ZJ/NsK/3ahPsxFJLWkxS6ZeWyfQympo7SkB8uyfMoBdf8OqjFtSU9INB9OM3V6dSt/KFg6wdEOXcJXt6Boplkj0SG/wa8HYQ8RO8wt8J7kEjM1NnRpP+o5SmkaS10Tn9m97EgdmOXd/ARYyqZBQSie6xUIL0b1yFqHK4y4XI0TlPb3cS372u8MyuBole1vEFfEqGu6goVquL7mx5YkK41vS/2Sed1gtzb5wpDKstblPgSS8ZaN5+DPeU2WMk0nuoKMZdNs0FPK33ZqkKKsy0asPdeIhCcPE+qPVRj9cdC1yw0wFJTyPs5Gh3l2Zsz3o15SeyWY9DyGnOninTZ0vz4eqv/Nlmc8A1b9XChkQReUDoYvFo8t24CrOPWyNySNb8P2NGqKF2Zbyw9K54u75QE9704BU+DeUhqB5VjtUCBDt8ZTCPWBut38J0f/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FiX0AONwn6oPib6Wv2sGNTf1LvIFc31J8Mu7ddPwGPxViJg38HFgZhUwnVCCS7wBNa9igRcM+ZvyZmsz4cKxBw1ZCDM58CfBsrD/F1MIY+XzMpKM76eFQXmA1teevNHfuDyCNQkM1IujG6zr1M2qoqpmkBDPdtC3KQ3aXrLbJfreFtlwLz1a3VGJU4opn/oxfZxfS7DSVH1En0ss3FAyUDuvB7bFiQHNUjsvg9MptHpIKTnCxDsgzVmvcTnbwBueJWvND+od+Pc5TOSMhkDGQPzRZ74FGllgr28B5f3AJCnijbNZ7l3iTxJWB+13Eyrw66bDWwdPVlE3RtHi2ZHB0MiVsYJ6xHXxWE5uP1EFRJ3BNiaWE+gStZ6nqRes3h5UVfcmQgasT1mClsUa+BPMpfDRInIwGUhSedN72rcTaCpNBHoGrKSQYqVqDiPr0LSgv8OZ7eJ8xeNOikBqd8wbX0v46aCF2gl4FmwsCKgvxAwnh3rrU6Fz5aMFxCUTA+MCEwCQYFKw4DAhoFAAQUWNwdo2TTaG/pJA13ZtfytFwyQt0EFAWBr+BamgLh50h4PIbRd6I6s/UMAgMBhqA=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't store this cert like this. Anyone has access, security issue.
we need to have logic that 1) checks for a stored cert (in the vault) and uses that, or 2) request a new cert if none is present and store that in the vault.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugger. It was a really elegant solution, but security trumps beauty.
I'll look into using Hashicorp Vault again.

13 changes: 13 additions & 0 deletions charts/elasticsearch-chart/templates/elasticsearch.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ action.auto_create_index: true
xpack.security.enabled: true
xpack.license.self_generated.type: trial
xpack.monitoring.enabled: false

# enable and configure SSL for intra-node communication
# .p12 file must be executable (e.g. chmod 700)
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

# enable HTTPS
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: elastic-certificates.p12
xpack.security.http.ssl.truststore.path: elastic-certificates.p12

#xpack.monitoring.exporters.my_local:
# type: local
# use_ingest: false
Expand Down
17 changes: 17 additions & 0 deletions charts/elasticsearch-chart/templates/es-data-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ spec:
containers:
- name: {{.Values.name}}
image: {{.Values.image}}
# run unencode-certificates.sh
# Elasticsearch bin directory
# copy from read only filesystem chmod in read-write filesystem run file run normal start script
command: [ "/bin/bash", "-c", "BIN=$(pwd)/bin;cp ${BIN}/unencode-certificates.sh ${BIN}/unencode-certificates2.sh; chmod 777 ${BIN}/unencode-certificates2.sh; ${BIN}/unencode-certificates2.sh; /usr/local/bin/docker-entrypoint.sh eswrapper" ]
ports:
- name: {{ .Values.services.discovery.cluster_port_name }}
containerPort: {{ .Values.services.discovery.cluster_port }}
Expand Down Expand Up @@ -120,18 +124,31 @@ spec:
- name: esconfig
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
subPath: elasticsearch.yml
- name: unencode-certificates
mountPath: /usr/share/elasticsearch/bin/unencode-certificates.sh
subPath: unencode-certificates.sh
- name: elasticcertificates
mountPath: /usr/share/elasticsearch/config/elastic-certificates.p12.b64
subPath: elastic-certificates.p12.b64
- name: esdata
mountPath: {{ .Values.data_data_mount }}
volumes:
- name: esconfig
configMap:
name: {{ template "name" . }}
- name: unencode-certificates
configMap:
name: {{ template "name" . }}
- name: elasticcertificates
configMap:
name: {{ template "name" . }}
volumeClaimTemplates:
- metadata:
name: esdata
annotations:
{{ .Values.data_storage_class_key }}: {{ .Values.data_storage_class_value }}
spec:
# unbound persistant volume claims if ReadWriteMany
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
Expand Down
16 changes: 16 additions & 0 deletions charts/elasticsearch-chart/templates/es-master-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ spec:
containers:
- name: {{.Values.name}}
image: {{.Values.image}}
# run unencode-certificates.sh
# Elasticsearch bin directory
# copy from read only filesystem chmod in read-write filesystem run file run normal start script
command: [ "/bin/bash", "-c", "BIN=$(pwd)/bin;cp ${BIN}/unencode-certificates.sh ${BIN}/unencode-certificates2.sh; chmod 777 ${BIN}/unencode-certificates2.sh; ${BIN}/unencode-certificates2.sh; /usr/local/bin/docker-entrypoint.sh eswrapper" ]
ports:
- name: {{ .Values.services.discovery.cluster_port_name }}
containerPort: {{ .Values.services.discovery.cluster_port }}
Expand Down Expand Up @@ -118,12 +122,24 @@ spec:
- name: esconfig
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
subPath: elasticsearch.yml
- name: unencode-certificates
mountPath: /usr/share/elasticsearch/bin/unencode-certificates.sh
subPath: unencode-certificates.sh
- name: elasticcertificates
mountPath: /usr/share/elasticsearch/config/elastic-certificates.p12.b64
subPath: elastic-certificates.p12.b64
- name: esdata
mountPath: {{ .Values.master_data_mount }}
volumes:
- name: esconfig
configMap:
name: {{ template "name" . }}
- name: unencode-certificates
configMap:
name: {{ template "name" . }}
- name: elasticcertificates
configMap:
name: {{ template "name" . }}
volumeClaimTemplates:
- metadata:
name: esdata
Expand Down
1 change: 0 additions & 1 deletion charts/elasticsearch-chart/templates/es-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rules:
- endpoints
verbs:
- get

---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ data:

# run until either cluster status is green or 10 minute timeout
timeout=0
url=https://${ELASTICSEARCH_PORT_9200_TCP_ADDR}:9200/_cat/health
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may work, but I would prefer you left this one how it was {{ .Values.name }}.{{ .Release.Namespace }} because CI may run many tests and they each have a different namespace and name...so they don't clash.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't see this set anyplace ELASTICSEARCH_PORT_9200_TCP_ADDR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was failing locally with the original values. We could have two URLs (e.g. $url_second or some such) and only try the second if we can't connect to the first.

echo "Getting health status from url ${url}."
until [ "${clusterHealth}" == "green" -o ${timeout} -gt 600 ]; do
run curl -s --connect-timeout 1 \
# -k lets us accept an unsigned certificate for HTTPS
run curl -s -k --connect-timeout 1 \
-u {{ .Values.test.account }}:${ELASTIC_PASSWORD} \
--location http://{{ .Values.name }}.{{ .Release.Namespace }}:9200/_cat/health
--location ${url}

if [ $status -ne 0 ];then
echo "curl ES error: $status" >&3
Expand Down
21 changes: 21 additions & 0 deletions charts/elasticsearch-chart/templates/unencode-certificates.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ define "unencode-certificates.sh.tpl" }}

#!/bin/bash

echo 'Starting startup script.'

# strict mode
set -euo pipefail

# lazy init elastic-certificates.p12 file; try to read and if read fails create cert and write it to Vault
# an unset value comes back as as empty response return 0 (success)
export P12=/usr/share/elasticsearch/config/elastic-certificates.p12
base64 -d ${P12}.b64 > $P12

echo "Setting permissions"
# set permissions of elastic-certificates.p12
chown elasticsearch $P12
chmod 700 $P12
echo "Done with startup script."

{{ end }}