This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix cluster outage, add masterService template #41
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ed67799
fix cluster outage, add masterService template
kimxogus 17fe76d
bump chart version
kimxogus f2ba6e0
Merge branch 'master' into fix/cluster-outage
kimxogus 1048ce3
default value for secretMounts
kimxogus 95cf412
use touch instead of echo ""
kimxogus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ maintainers: | |
- email: [email protected] | ||
name: Elastic | ||
name: elasticsearch | ||
version: 6.5.4-alpha3 | ||
version: 6.5.4-alpha4 | ||
appVersion: 6.5.4 | ||
sources: | ||
- https://github.com/elastic/elasticsearch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{{ if eq .Values.roles.master "true" }} | ||
{{- range $i := until (int .Values.replicas) }} | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ template "uname" $ }}-announce-{{ $i }} | ||
labels: | ||
heritage: {{ $.Release.Service | quote }} | ||
release: {{ $.Release.Name | quote }} | ||
chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" | ||
app: "{{ template "uname" $ }}" | ||
annotations: | ||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" | ||
spec: | ||
type: ClusterIP | ||
publishNotReadyAddresses: true | ||
ports: | ||
- name: transport | ||
port: 9300 | ||
targetPort: transport | ||
selector: | ||
heritage: {{ $.Release.Service | quote }} | ||
release: {{ $.Release.Name | quote }} | ||
chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" | ||
app: "{{ template "uname" $ }}" | ||
statefulset.kubernetes.io/pod-name: {{ template "masterService" $ }}-{{ $i }} | ||
{{ end }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,8 @@ spec: | |
secret: | ||
secretName: {{ .name }} | ||
{{- end }} | ||
- name: config | ||
emptyDir: {} | ||
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. Why should we store the configuration here instead of regenerating it at each start? |
||
{{- if .Values.esConfig }} | ||
- name: esconfig | ||
configMap: | ||
|
@@ -100,6 +102,41 @@ spec: | |
image: "{{ .Values.image }}:{{ .Values.imageTag }}" | ||
command: ["sysctl", "-w", "vm.max_map_count={{ .Values.sysctlVmMaxMapCount}}"] | ||
resources: | ||
{{ toYaml .Values.initResources | indent 10 }} | ||
- name: init-config | ||
securityContext: | ||
runAsUser: 0 | ||
privileged: true | ||
image: "{{ .Values.image }}:{{ .Values.imageTag }}" | ||
command: | ||
- /bin/bash | ||
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. Maybe add some comment here to state the purpose of the initContainer? |
||
- -c | ||
- |- | ||
shopt -s nullglob dotglob | ||
files=(/tmp/config/*) | ||
if [ ${#files[@]} -gt 0 ]; then | ||
cp -r /tmp/config/* /usr/share/elasticsearch/config/ | ||
fi | ||
|
||
HOSTNAME="$(hostname)" | ||
INDEX="${HOSTNAME##*-}" | ||
|
||
ENV_VAR_PREFIX=`echo {{ template "masterService" . }}-|awk '{print toupper($0)}'|sed 's/-/_/g'` | ||
HOSTVAR="${ENV_VAR_PREFIX}ANNOUNCE_${INDEX}_SERVICE_HOST" | ||
HOST="${!HOSTVAR}" | ||
|
||
if [ ! -f /usr/share/elasticsearch/config/elasticsearch.yml ]; then | ||
touch /usr/share/elasticsearch/config/elasticsearch.yml | ||
fi; | ||
echo "network.publish_host: ${HOST}" >> /usr/share/elasticsearch/config/elasticsearch.yml; | ||
volumeMounts: | ||
- name: config | ||
mountPath: /usr/share/elasticsearch/config | ||
{{- if .Values.esConfig }} | ||
- name: esconfig | ||
mountPath: /tmp/config | ||
{{- end }} | ||
resources: | ||
{{ toYaml .Values.initResources | indent 10 }} | ||
containers: | ||
- name: "{{ template "name" . }}" | ||
|
@@ -162,7 +199,7 @@ spec: | |
{{- end }} | ||
{{- end }} | ||
- name: discovery.zen.ping.unicast.hosts | ||
value: "{{ .Values.masterService }}-headless" | ||
value: "{{ template "masterService" . }}-headless" | ||
- name: cluster.name | ||
value: "{{ .Values.clusterName }}" | ||
- name: network.host | ||
|
@@ -187,7 +224,18 @@ spec: | |
{{- end }} | ||
{{- end }} | ||
{{- range $path, $config := .Values.esConfig }} | ||
- name: esconfig | ||
- name: config | ||
mountPath: /usr/share/elasticsearch/config/{{ $path }} | ||
subPath: {{ $path }} | ||
{{- end }} | ||
{{- if not (empty .Values.esConfig) }} | ||
{{- if not (hasKey .Values.esConfig "elasticsearch.yml") }} | ||
- name: config | ||
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml | ||
subPath: elasticsearch.yml | ||
{{- end -}} | ||
{{- else if (empty .Values.esConfig) }} | ||
- name: config | ||
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml | ||
subPath: elasticsearch.yml | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we really need this?
The headless service is used for service discovery and includes all members in the cluster even the unready ones
https://github.com/elastic/helm-charts/blob/master/elasticsearch/templates/service.yaml#L31