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

helm chart for cht sync #90

Merged
merged 22 commits into from
Jul 19, 2024
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
24 changes: 24 additions & 0 deletions deploy/cht_sync/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: cht_sync
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.0"
54 changes: 54 additions & 0 deletions deploy/cht_sync/templates/couch2pg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{- $couchdbs := .Values.couchdbs -}}
{{- range $index, $service := $couchdbs }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cht-sync-couch2pg--{{ $service.host | replace "." "-" }}
spec:
replicas: 1
selector:
matchLabels:
app: cht-sync
template:
metadata:
labels:
app: cht-sync
spec:
automountServiceAccountToken: false
containers:
- name: couch2pg
image: medicmobile/cht-sync-couch2pg:{{ $.Values.image_tag | default "latest" }}
resources:
limits:
cpu: {{ ($.Values.couch2pg).cpu_limit | default "500m" }}
memory: {{ ($.Values.couch2pg).memory_limit | default "1Gi" }}
env:
- name: POSTGRES_HOST
value: {{ $.Values.postgres.host | default "postgres" }}
- name: POSTGRES_USER
value: {{ $.Values.postgres.user }}
- name: POSTGRES_PORT
value: {{ $.Values.postgres.port | default "5432" | quote }}
- name: POSTGRES_PASSWORD
value: {{ $.Values.postgres.password }}
- name: POSTGRES_DB
value: {{ $.Values.postgres.db }}
- name: POSTGRES_TABLE
value: {{ $.Values.postgres.table }}
- name: POSTGRES_SCHEMA
value: {{ $.Values.postgres.schema }}
- name: COUCHDB_USER
value: {{ $service.user | default $.Values.couchdb.user }}
- name: COUCHDB_PASSWORD
value: {{ $service.password }}
- name: COUCHDB_HOST
value: {{ $service.host }}
- name: COUCHDB_DBS
value: {{ $service.dbs | default $.Values.couchdb.dbs }}
- name: COUCHDB_PORT
value: {{ ($service.port | default $.Values.couchdb.port) | quote }}
- name: COUCHDB_SECURE
value: {{ ($service.secure | default $.Values.couchdb.secure) | quote }}
{{- end }}

42 changes: 42 additions & 0 deletions deploy/cht_sync/templates/dbt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cht-sync-dbt
spec:
replicas: 1
selector:
matchLabels:
app: cht-sync
template:
metadata:
labels:
app: cht-sync
spec:

Check warning

Code scanning / SonarCloud

Service account tokens should not be mounted in pods Medium

Set automountServiceAccountToken to false for this specification of kind Deployment. See more on SonarCloud
automountServiceAccountToken: false
containers:
- name: dbt

Check warning

Code scanning / SonarCloud

CPU limits should be enforced Medium

Specify a CPU limit for this container. See more on SonarCloud

Check warning

Code scanning / SonarCloud

Memory limits should be enforced Medium

Specify a memory limit for this container. See more on SonarCloud
image: medicmobile/dataemon:{{ .Values.image_tag | default "latest" }}
resources:
limits:
cpu: {{ (.Values.dbt).cpu_limit | default "500m" }}
memory: {{ (.Values.dbt).memory_limit | default "1Gi" }}
env:
- name: POSTGRES_HOST
value: {{ .Values.postgres.host | default "postgres" }}
- name: POSTGRES_USER
value: {{ .Values.postgres.user }}
- name: POSTGRES_PORT
value: {{ .Values.postgres.port | default "5432" | quote }}
- name: POSTGRES_PASSWORD
value: {{ .Values.postgres.password }}
- name: POSTGRES_DB
value: {{ .Values.postgres.db }}
- name: POSTGRES_TABLE
value: {{ .Values.postgres.table }}
- name: POSTGRES_SCHEMA
value: {{ .Values.postgres.schema }}
- name: ROOT_POSTGRES_SCHEMA
value: {{ .Values.postgres.schema }}
- name: CHT_PIPELINE_BRANCH_URL
value: {{ .Values.cht_pipeline_branch_url }}

13 changes: 13 additions & 0 deletions deploy/cht_sync/templates/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.postgres.enabled }}
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
inner.service: postgres
ports:
- protocol: TCP
port: {{ .Values.postgres.port | default "5432" }}
targetPort: 5432
{{- end }}
47 changes: 47 additions & 0 deletions deploy/cht_sync/templates/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# templates/postgres.yaml

{{- if .Values.postgres.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cht-sync-postgres
spec:
serviceName: postgres
replicas: 1
selector:
matchLabels:
app: cht-sync
inner.service: postgres
template:
metadata:
labels:
app: cht-sync
inner.service: postgres
spec:
automountServiceAccountToken: false
containers:
- name: postgres-c
image: postgres:13
resources:
limits:
cpu: {{ (.Values.postgres).cpu_limit | default "1000m" }}
memory: {{ (.Values.postgres).memory_limit | default "2Gi" }}
env:
- name: POSTGRES_USER
value: {{ .Values.postgres.user }}
- name: POSTGRES_PASSWORD
value: {{ .Values.postgres.password }}
- name: POSTGRES_DB
value: {{ .Values.postgres.db }}
ports:
- containerPort: {{ .Values.postgres.port | default "5432" }}

volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.postgres.storageSize | default "1Gi" }}
{{- end }}
10 changes: 10 additions & 0 deletions deploy/cht_sync/templates/postgrest-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: postgrest
spec:
selector:
inner.service: postgrest
ports:
- protocol: TCP
port: 3000
35 changes: 35 additions & 0 deletions deploy/cht_sync/values.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

postgres:
enabled: true # if true a postgres service will not be created in this cluster
user: ""
password: ""
db: ""
schema: "v1"
table: "medic"
host: "postgres" # if postgres is outside the cluster
port: 5432 # if postgres is outside the cluster

cht_pipeline_branch_url: "https://github.com/medic/cht-pipeline.git#main"

# values shared by all couchdb instances
# can be omitted if couchdb instances do not share any values
couchdb:
user: ""
dbs: "medic" # space separated list of databases you want to sync e.g "medic medic-sentinel"
port: "5984"
witash marked this conversation as resolved.
Show resolved Hide resolved
secure: "true" # "true" if SSL is required

# values for each couchdb instance
# host and password are required
# other values can be omitted if they are common to all couchdb instances and specified above
couchdbs:
- host: "host1" # required for all couchdb instances
password: "" # required for all couchdb instances
- host: "host2"
password: ""
- host: "host3"
password: ""
user: "user2" # required if different than above
dbs: "medic medic_sentinel" # required if different than above
port: "5984" # required if different than above
secure: "true" # required if different than above