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

Add cht-user-managment-worker and redis to cht-user-management helm charts #26

Merged
merged 3 commits into from
Oct 30, 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
4 changes: 2 additions & 2 deletions charts/base-single-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: Single app helm chart to simplify configuration
home: https://github.com/medic/helm-charts/tree/gh-pages
icon: https://avatars.githubusercontent.com/u/474424?s=200&v=4

type: library
type: application

version: 0.2.1
version: 0.2.2

appVersion: ""
4 changes: 4 additions & 0 deletions charts/base-single-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.service.enabled }}
- name: PORT
value: "{{ .Values.service.port }}"
{{- end }}
{{- range $key, $value := .Values.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
Expand All @@ -49,6 +51,7 @@ spec:
name: "{{ tpl (.secretName | toString) $ }}"
key: "{{ .secretKey | default .env }}"
{{- end }}
{{- if .Values.service.enabled }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand All @@ -61,6 +64,7 @@ spec:
httpGet:
path: /_healthz
port: http
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
Expand Down
2 changes: 2 additions & 0 deletions charts/base-single-app/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.service.enabled }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -13,3 +14,4 @@ spec:
name: http
selector:
{{- include "base-single-app.selectorLabels" . | nindent 4 }}
{{- end }}
14 changes: 10 additions & 4 deletions charts/cht-user-management/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
dependencies:
- name: base-single-app
repository: https://docs.communityhealthtoolkit.org/helm-charts
version: 0.2.0
digest: sha256:284a3dc5e9eb4c400a3abff6f49faa047ad11d2dbbc873e8adf8829cde321aae
generated: "2024-04-10T11:32:50.118338+02:00"
repository: file://../base-single-app
version: 0.2.2
- name: base-single-app
repository: file://../base-single-app
version: 0.2.2
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 16.13.2
digest: sha256:cd591bdfad18b05b5cc473ffd5796b630ac8e10248ae6e7ca4f0b716e78369a2
generated: "2024-10-29T16:04:11.007238-06:00"
17 changes: 14 additions & 3 deletions charts/cht-user-management/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ icon: https://avatars.githubusercontent.com/u/474424?s=200&v=4

type: application

version: 0.2.1
version: 0.2.2

dependencies:
- alias: cht-user-management
name: base-single-app
version: "0.2.0"
version: "0.2.2"
#repository: file://../base-single-app
repository: https://docs.communityhealthtoolkit.org/helm-charts
# repository: file://../base-single-app

- alias: cht-user-management-worker
name: base-single-app
version: "0.2.2"
repository: https://docs.communityhealthtoolkit.org/helm-charts
#repository: file://../base-single-app

- alias: redis
name: redis
version: "16.13.2"
Hareet marked this conversation as resolved.
Show resolved Hide resolved
repository: https://charts.bitnami.com/bitnami

appVersion: ""
11 changes: 10 additions & 1 deletion charts/cht-user-management/templates/_secret.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If release name contains chart name it will be used as a full name.
{{- end }}

{{/*
Looks if there is an existing secret and reuse its key. If not generate a new key and use it.
Looks if there is existing secrets and reuse their keys. If not generate new keys and use them.
*/}}
{{- define "chtUserManagement.COOKIE_PRIVATE_KEY" -}}
{{- $secret := (lookup "v1" "Secret" (.Release.Namespace) (include "chtUserManagement.fullname" .) ) }}
Expand All @@ -27,3 +27,12 @@ Looks if there is an existing secret and reuse its key. If not generate a new ke
{{- (randAlphaNum 45) | b64enc | quote }}
{{- end }}
{{- end }}

{{- define "chtUserManagement.WORKER_PRIVATE_KEY" -}}
{{- $secret := (lookup "v1" "Secret" (.Release.Namespace) (include "chtUserManagement.fullname" .) ) }}
{{- if $secret }}
{{- index $secret "data" "WORKER_PRIVATE_KEY" }}
{{- else }}
{{- (randAlphaNum 45) | b64enc | quote }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/cht-user-management/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ metadata:
type: Opaque
data:
COOKIE_PRIVATE_KEY: {{ include "chtUserManagement.COOKIE_PRIVATE_KEY" . }}
WORKER_PRIVATE_KEY: {{ include "chtUserManagement.WORKER_PRIVATE_KEY" . }}
70 changes: 63 additions & 7 deletions charts/cht-user-management/values.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the additions to this file seem bespoke to a dev install for Hareet in EKS. Is this correct? If yes, I'll do a deep dive on what looks wrong. If no, I'll wait 'til final revisions come in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've added some comments on what to change, and thought other environment variables were self-described. We can add more comments to clarify

Original file line number Diff line number Diff line change
@@ -1,19 +1,75 @@
cht-user-management:
replicaCount: 1

service:
port: 3000

enabled: true
image:
repository: public.ecr.aws/medic/cht-user-management
tag: "" # Set this to the version of the docker image
tag: "1.4.1" # Set this to the version of the docker image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could update the deploy steps to NOT depend on the deploy branch in CHT User Man repo:

Switch to the deploy branch and ensure the same values file from the prior step is in the values folder in deploy branch

Maybe that's for another PR though? Really - this is error prone and done manually for all prod pushes - a good recipe for a mistake to be made!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the deploy branch only contains the values yaml, and you want that moved to the main branch? Why is it in the deploy branch in the first place? Let's chat about it and put it in a different PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medic/cht-user-management#213

Here's the values file we want to use for users-chis-tg deploy.


# Environment variablues to set in the pod, for example:
# env:
# CONFIG_NAME: changeme
env: {}

# REDIS_HOST: {{ Release.Name }}-redis-master.{{ .Release.Namespace }}.svc.cluster.local
env:
NODE_ENV: dev
CHT_DEV_HTTP: false
CHT_DEV_URL_PORT: hareet-test.dev.medicmobile.org
CONFIG_NAME: chis-tg
REDIS_HOST: test-user-management-redis-master.hareet-test.svc.cluster.local
REDIS_PORT: 6379
envSecrets:
# COOKIE_PRIVATE_KEY will be automatically generated if it doesn't exist
# COOKIE/WORKER_PRIVATE_KEY will be automatically generated if it doesn't exist
- env: COOKIE_PRIVATE_KEY
secretName: '{{ include "chtUserManagement.fullname" . }}'
secretName: "{{ .Release.Name }}-cht-user-management"
- env: WORKER_PRIVATE_KEY
secretName: "{{ .Release.Name }}-cht-user-management"

ingress:
annotations:
alb.ingress.kubernetes.io/certificate-arn: arn:aws:iam::720541322708:server-certificate/2024-wildcard-dev-medicmobile-org-chain
alb.ingress.kubernetes.io/group.name: dev-cht-alb
alb.ingress.kubernetes.io/healthcheck-port: traffic-port
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/ssl-redirect: "443"
alb.ingress.kubernetes.io/tags: Environment=dev,Team=QA
alb.ingress.kubernetes.io/target-type: ip
className: alb
enabled: true
hosts:
- host: hareet-test-users.dev.medicmobile.org
paths:
- path: /
pathType: Prefix


cht-user-management-worker:
# Our worker does not need any ports exposed, services, healtchecks, so we toggle this to false
# to prevent single-base-app from templating and creating those resources
service:
enabled: false
replicaCount: 1
image:
repository: public.ecr.aws/medic/cht-user-management-worker
tag: "1.4.1"
env:
NODE_ENV: dev
REDIS_HOST: test-user-management-redis-master.hareet-test.svc.cluster.local
REDIS_PORT: 6379
envSecrets:
- env: WORKER_PRIVATE_KEY
secretName: "{{ .Release.Name }}-cht-user-management"


redis:
architecture: standalone
replica:
replicaCount: 1
persistence:
enabled: true
storageClass: ebs-gp2
size: 8Gi
auth:
enabled: false

Loading