Skip to content

Commit

Permalink
Changes: separate frontend, worker, matching, history deployments. Co…
Browse files Browse the repository at this point in the history
…nfigmap added. Parameterized.
  • Loading branch information
nikitab7 committed Sep 13, 2024
1 parent 70673ef commit a56fb3d
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 361 deletions.
Binary file modified cadencechart/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions cadencechart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ version: 0.1.0
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

69 changes: 10 additions & 59 deletions cadencechart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,62 +1,13 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cadencechart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/* vim: set filetype=mustache: */}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "cadencechart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{- define "cadence.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cadencechart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "cadence.fullname" -}}
{{- printf "%s-%s" .Release.Name (include "cadence.name" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "cadencechart.labels" -}}
helm.sh/chart: {{ include "cadencechart.chart" . }}
{{ include "cadencechart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "cadencechart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cadencechart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "cadencechart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cadencechart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{- define "cadence.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
110 changes: 0 additions & 110 deletions cadencechart/templates/cadence-deployment.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion cadencechart/templates/cadence-web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
- containerPort: 8088
env:
- name: CADENCE_TCHANNEL_PEERS
value: cadence-service.{{ .Release.Namespace }}.svc.cluster.local:7933
value: cadence-frontend-service.{{ .Release.Namespace }}.svc.cluster.local:7933

---
apiVersion: v1
Expand Down
2 changes: 1 addition & 1 deletion cadencechart/templates/cassandra-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
spec:
containers:
- name: cassandra
image: cassandra:4.1.1
image: {{ .Values.cassandra.image.repository }}:{{ .Values.cassandra.image.tag }}
ports:
- containerPort: 9042
env:
Expand Down
58 changes: 58 additions & 0 deletions cadencechart/templates/schema-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: batch/v1
kind: Job
metadata:
name: cadence-schema-setup
spec:
backoffLimit: 4
template:
metadata:
name: cadence-schema-setup
spec:
restartPolicy: "OnFailure"
initContainers:
# Check Cassandra DNS resolution using busybox
- name: check-cassandra-dns
image: busybox
command: ['sh', '-c', '
until nslookup {{ $.Values.cassandra.seeds }}; do
echo "Waiting for Cassandra service DNS resolution...";
sleep 5;
done;
echo "Cassandra service DNS resolved.";
']
# Check Cassandra readiness using cqlsh
- name: check-cassandra-ready
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
command: ['sh', '-c', '
until cqlsh {{ $.Values.cassandra.seeds }} 9042 -e "SHOW VERSION"; do
echo "Waiting for Cassandra to start...";
sleep 30;
done;
echo "Cassandra is up and running.";
']
containers:
- name: schema-setup
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: IfNotPresent
env:
- name: CASSANDRA_SEEDS
value: {{ $.Values.cassandra.seeds }}
- name: KEYSPACE
value: cadence
- name: VISIBILITY_KEYSPACE
value: cadence_visibility
- name: RF
value: "1"
- name: CADENCE_HOME
value: /etc/cadence
args: ['sh', '-c', '
SCHEMA_DIR=$CADENCE_HOME/schema/cassandra/cadence/versioned;
cadence-cassandra-tool --ep $CASSANDRA_SEEDS create -k $KEYSPACE --rf $RF;
cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $KEYSPACE setup-schema -v 0.0;
cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $KEYSPACE update-schema -d $SCHEMA_DIR;

VISIBILITY_SCHEMA_DIR=$CADENCE_HOME/schema/cassandra/visibility/versioned;
cadence-cassandra-tool --ep $CASSANDRA_SEEDS create -k $VISIBILITY_KEYSPACE --rf $RF;
cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $VISIBILITY_KEYSPACE setup-schema -v 0.0;
cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $VISIBILITY_KEYSPACE update-schema -d $VISIBILITY_SCHEMA_DIR;
']
14 changes: 14 additions & 0 deletions cadencechart/templates/server-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "cadence.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "cadence.name" . }}
helm.sh/chart: {{ include "cadence.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" }}
app.kubernetes.io/part-of: {{ .Chart.Name }}
data:
dynamic_config.yaml: |-
{{- toYaml .Values.dynamicConfig.values | nindent 12 }}
99 changes: 99 additions & 0 deletions cadencechart/templates/server-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{{- range $service := (list "frontend" "history" "matching" "worker") }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: cadence-{{ $service }}
labels:
app: cadence
component: {{ $service }}
spec:
replicas: {{ $.Values.deployment.replicaCount }}
selector:
matchLabels:
app: cadence
component: {{ $service }}
template:
metadata:
labels:
app: cadence
component: {{ $service }}
spec:
initContainers:
- name: wait-for-schema
image: {{ $.Values.image.repository }}:{{ $.Values.image.tag }}
command: ["sh", "-c", "
until cqlsh {{ $.Values.cassandra.seeds }} 9042 -e \"
USE cadence;
SELECT curr_version FROM schema_version WHERE keyspace_name = 'cadence';\" | grep -q 0.37 &&
cqlsh {{ $.Values.cassandra.seeds }} 9042 -e \"
USE cadence_visibility;
SELECT curr_version FROM schema_version WHERE keyspace_name = 'cadence_visibility';\" | grep -q 0.9;
do
echo waiting for both cadence and cadence_visibility schema setup;
sleep 10;
done"]
containers:
- name: cadence-{{ $service }}
image: {{ $.Values.image.repository }}:{{ $.Values.image.tag }}
ports:
- name: port-8000
containerPort: 8000
protocol: TCP
- name: port-8001
containerPort: 8001
protocol: TCP
- name: port-8002
containerPort: 8002
protocol: TCP
- name: port-8003
containerPort: 8003
protocol: TCP
- name: port-7933
containerPort: {{ if eq $service "frontend" }}7933{{ else if eq $service "history" }}7934{{ else if eq $service "matching" }}7935{{ else }}7939{{ end }}
protocol: TCP
- name: port-7833
containerPort: 7833
protocol: TCP
volumeMounts:
- name: config
mountPath: /etc/cadence/config/dynamicconfig/config.yaml
subPath: dynamic_config.yaml
env:
- name: CASSANDRA_SEEDS
value: {{ $.Values.cassandra.seeds }}
- name: PROMETHEUS_ENDPOINT_0
value: 0.0.0.0:8000
- name: PROMETHEUS_ENDPOINT_1
value: 0.0.0.0:8001
- name: PROMETHEUS_ENDPOINT_2
value: 0.0.0.0:8002
- name: PROMETHEUS_ENDPOINT_3
value: 0.0.0.0:8003
- name: DYNAMIC_CONFIG_FILE_PATH
value: {{ $.Values.deployment.configPath }}
- name: PRIMARY_FRONTEND_SERVICE
value: cadence-frontend-service.{{ $.Release.Namespace }}.svc.cluster.local
- name: BIND_ON_IP
value: "0.0.0.0"
- name: LOG_LEVEL
value: {{ $.Values.log.level }}
- name: LOG_STDOUT
value: {{ $.Values.log.stdout | quote }}
- name: ENABLE_ES
value: {{ $.Values.deployment.enableES | quote }}
- name: SKIP_SCHEMA_SETUP
value: {{ $.Values.deployment.skipSchemaSetup | quote }}

resources:
limits:
cpu: {{ $.Values.deployment.cpu.limit }}
memory: {{ $.Values.deployment.memory.limit }}
requests:
cpu: {{ $.Values.deployment.cpu.request }}
memory: {{ $.Values.deployment.memory.request }}
volumes:
- name: config
configMap:
name: {{ include "cadence.fullname" $ }}
---
{{- end }}
Loading

0 comments on commit a56fb3d

Please sign in to comment.