Skip to content

Commit

Permalink
Split off the sync service
Browse files Browse the repository at this point in the history
  • Loading branch information
mkysel committed Dec 4, 2024
1 parent e3063b1 commit 5685092
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "xmtpd.fullname" . }}
name: {{ include "xmtpd.fullname" . }}-api
labels:
{{- include "xmtpd.labels" . | nindent 4 }}
spec:
Expand Down Expand Up @@ -37,10 +37,6 @@ spec:
env:
- name: XMTPD_REPLICATION_ENABLE
value: "true"
- name: XMTPD_SYNC_ENABLE
value: "true"
- name: XMTPD_INDEXER_ENABLE
value: "true"
{{- include "helpers.list-env-variables" . | indent 12 }}
ports:
- name: grpc
Expand Down
56 changes: 56 additions & 0 deletions helm/xmtpd/templates/sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "xmtpd.fullname" . }}-sync
labels:
{{- include "xmtpd.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "xmtpd.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "xmtpd.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "xmtpd.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: XMTPD_SYNC_ENABLE
value: "true"
- name: XMTPD_INDEXER_ENABLE
value: "true"
{{- include "helpers.list-env-variables" . | indent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
18 changes: 12 additions & 6 deletions test/testlib/xmtp_xmtpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,26 @@ func startXMTPDTemplate(t *testing.T, options *helm.Options, replicaCount int, n
return
}

xmtpdDeployment := helmChartReleaseName
xmtpdDeploymentSync := fmt.Sprintf("%s-sync", helmChartReleaseName)
xmtpdDeploymentApi := fmt.Sprintf("%s-api", helmChartReleaseName)

defer func() {
// collect some useful diagnostics
if t.Failed() {
// ignore any errors. This is already failed
_ = k8s.RunKubectlE(t, kubectlOptions, "describe", "deployment", xmtpdDeployment)
_ = k8s.RunKubectlE(t, kubectlOptions, "describe", "deployment", xmtpdDeploymentSync)
_ = k8s.RunKubectlE(t, kubectlOptions, "describe", "deployment", xmtpdDeploymentApi)
}
}()

AwaitNrReplicasScheduled(t, namespaceName, xmtpdDeployment, replicaCount)
AwaitNrReplicasScheduled(t, namespaceName, xmtpdDeploymentSync, replicaCount)
AwaitNrReplicasScheduled(t, namespaceName, xmtpdDeploymentApi, replicaCount)

pods := FindPodsFromChart(t, namespaceName, xmtpdDeployment)
podsSync := FindPodsFromChart(t, namespaceName, xmtpdDeploymentSync)
podsApi := FindPodsFromChart(t, namespaceName, xmtpdDeploymentApi)

for _, pod := range pods {
allPods := append(podsSync, podsApi...)
for _, pod := range allPods {
AddTeardown(TEARDOWN_XMTPD, func() {
if t.Failed() {
// dump diagnostic info to test logs
Expand All @@ -90,7 +95,8 @@ func startXMTPDTemplate(t *testing.T, options *helm.Options, replicaCount int, n
})
}

AwaitNrReplicasReady(t, namespaceName, xmtpdDeployment, replicaCount)
AwaitNrReplicasReady(t, namespaceName, xmtpdDeploymentSync, replicaCount)
AwaitNrReplicasReady(t, namespaceName, xmtpdDeploymentApi, replicaCount)

return
}
Expand Down

0 comments on commit 5685092

Please sign in to comment.