Skip to content
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

*: support scenarios where replica is 1 #11 #13

Merged
merged 2 commits into from
Mar 25, 2021
Merged
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
2 changes: 1 addition & 1 deletion charts/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
# {{- else }}
# mysql-root-password: {{ randAlphaNum 12 | b64enc | quote }}
# {{- end }}
{{- if and .Values.mysql.mysqlUser (and (ne .Values.mysql.mysqlUser "qc_repl") (ne .Values.mysql.mysqlUser "root"))}}
{{- if and .Values.mysql.mysqlUser (and (ne .Values.mysql.mysqlUser "qc_repl") (ne .Values.mysql.mysqlUser "root")) }}
{{- if .Values.mysql.mysqlPassword }}
mysql-password: {{ .Values.mysql.mysqlPassword | b64enc | quote }}
{{- else }}
Expand Down
2 changes: 2 additions & 0 deletions charts/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ spec:
app: {{ template "fullname" . }}
release: {{ .Release.Name | quote }}
role: master
{{- if lt 1 (.Values.replicaCount | int64) }}
---
# Client service for connecting to any MySQL instance for reads.
apiVersion: v1
Expand Down Expand Up @@ -79,6 +80,7 @@ spec:
app: {{ template "fullname" . }}
release: {{ .Release.Name | quote }}
role: slave
{{- end }}
{{ if .Values.metrics.enabled }}
---
apiVersion: v1
Expand Down
12 changes: 10 additions & 2 deletions charts/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ spec:
lifecycle:
postStart:
exec:
{{- if lt 1 (.Values.replicaCount | int64) }}
command: ['sh', '-c', 'until /krypton/kryptoncli xenon ping > /dev/null 2>&1; do sleep 2; done && /krypton/kryptoncli mysql stopmonitor && /krypton/kryptoncli cluster add "$(/bin/bash /create-peers.sh)"']
{{- else }}
command: ['sh', '-c', 'until /krypton/kryptoncli xenon ping > /dev/null 2>&1; do sleep 2; done && /krypton/kryptoncli mysql stopmonitor && /krypton/kryptoncli raft trytoleader']
{{- end }}
resources:
{{ toYaml .Values.krypton.resources | indent 10 }}
volumeMounts:
Expand All @@ -183,8 +187,12 @@ spec:
secretKeyRef:
name: {{ template "fullname" . }}
key: mysql-replication-password
- name: HOST_SUFFIX
value: {{ template "fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
- name: POD_HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: HOST
value: $(POD_HOSTNAME).{{ template "fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
- name: LEADER_START_CMD
value: "/bin/bash /leader-start.sh"
- name: LEADER_STOP_CMD
Expand Down
2 changes: 1 addition & 1 deletion charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mysql:

krypton:
image: zhyass/krypton
tag: beta0.1.1
tag: beta0.1.2
args: []

## A string to add extra environment variables
Expand Down
10 changes: 2 additions & 8 deletions dockerfile/krypton/krypton-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ file_env() {
unset "$fileVar"
}

host=$(hostname)

file_env 'HOST_SUFFIX' ''

if [ -n "$HOST_SUFFIX" ]; then
host=$host.$HOST_SUFFIX
fi
file_env 'HOST' $(hostname)

file_env 'MYSQL_REPL_PASSWORD' 'Repl_123'
file_env 'LEADER_START_CMD' ':'
Expand Down Expand Up @@ -70,7 +64,7 @@ printf '{
"purge-binlog-disabled": true,
"super-idle": false
}
}' "$host" "$MYSQL_REPL_PASSWORD" "$LEADER_START_CMD" "$LEADER_STOP_CMD" > /etc/krypton/krypton.json
}' "$HOST" "$MYSQL_REPL_PASSWORD" "$LEADER_START_CMD" "$LEADER_STOP_CMD" > /etc/krypton/krypton.json

chown -R mysql:mysql /etc/krypton/krypton.json

Expand Down