-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Logstash keystore performance #7642
Changes from 5 commits
1de6734
5200697
5f4066b
1a23eb9
1650de9
150620e
5b468c4
55fb1c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,52 @@ const ( | |
) | ||
|
||
var ( | ||
keystoreCommand = "echo 'y' | /usr/share/logstash/bin/logstash-keystore" | ||
// containerCommand runs in every pod creation to regenerate keystore. | ||
// `logstash-keystore` allows for adding multiple keys in a single operation. | ||
// All keys and values must be ASCII and non-empty string. Values are input via stdin, delimited by \n. | ||
containerCommand = `#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
{{ if not .SkipInitializedFlag -}} | ||
keystore_initialized_flag={{ .KeystoreVolumePath }}/elastic-internal-init-keystore.ok | ||
|
||
if [[ -f "${keystore_initialized_flag}" ]]; then | ||
echo "Keystore already initialized." | ||
exit 0 | ||
fi | ||
|
||
{{ end -}} | ||
echo "Initializing keystore." | ||
|
||
# create a keystore in the default data path | ||
{{ .KeystoreCreateCommand }} | ||
|
||
# add all existing secret entries to keys (Array), vals (String). | ||
for filename in {{ .SecureSettingsVolumeMountPath }}/*; do | ||
[[ -e "$filename" ]] || continue # glob does not match | ||
key=$(basename "$filename") | ||
keys+=("$key") | ||
vals+=$(cat "$filename") | ||
vals+="\n" | ||
done | ||
|
||
# remove the trailing '\n' from the end of the vals | ||
vals=${vals%'\n'} | ||
|
||
# add multiple keys to keystore | ||
echo -e "$vals" | bin/logstash-keystore add "${keys[@]}" | ||
|
||
{{ if not .SkipInitializedFlag -}} | ||
touch {{ .KeystoreVolumePath }}/elastic-internal-init-keystore.ok | ||
{{ end -}} | ||
|
||
echo "Keystore initialization successful." | ||
` | ||
|
||
initContainersParameters = keystore.InitContainerParameters{ | ||
KeystoreCreateCommand: keystoreCommand + " create", | ||
KeystoreAddCommand: keystoreCommand + ` add "$key" < "$filename"`, | ||
KeystoreCreateCommand: "echo 'y' | /usr/share/logstash/bin/logstash-keystore create", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency, we might want to think about using both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the command for consistency |
||
ContainerCommand: containerCommand, | ||
SecureSettingsVolumeMountPath: keystore.SecureSettingsVolumeMountPath, | ||
KeystoreVolumePath: volume.ConfigMountPath, | ||
Resources: corev1.ResourceRequirements{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be easier to follow, if we call this
CustomScript
, and comment to state that this is a script to run that overrides the default Keystore script?