diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..697ef93 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +No release is stable. Do not use in production. + +# Unreleased + +# 1.0.0 + +- Add volume mounts +- Latest major postgres/redis versions +- Rename preInstall to migrateJob \ No newline at end of file diff --git a/Chart.lock b/Chart.lock index 9e8d250..ce86807 100644 --- a/Chart.lock +++ b/Chart.lock @@ -1,9 +1,9 @@ dependencies: - name: postgresql repository: https://charts.bitnami.com/bitnami - version: 12.1.15 + version: 15.5.16 - name: redis repository: https://charts.bitnami.com/bitnami - version: 17.3.18 -digest: sha256:51da30e025c538b229b1cfaba062c53dea8bf3f520fca460c6afc294c58bdc76 -generated: "2023-02-22T20:26:38.305910383-05:00" + version: 19.6.1 +digest: sha256:5e21575062cdcef4e947b4f89741e95138d93207f91d5074d53397d9c414f0a1 +generated: "2024-07-15T13:58:06.767935373-04:00" diff --git a/Chart.yaml b/Chart.yaml index 776f8b2..db8c436 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -14,7 +14,7 @@ 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. -version: 0.3.1 +version: 1.0.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. @@ -22,10 +22,10 @@ appVersion: 1.0.0 dependencies: - name: postgresql - version: ~12.1.2 + version: ^15.5.16 repository: https://charts.bitnami.com/bitnami condition: postgresql.enabled - name: redis - version: ~17.3.11 + version: ^19.6.1 repository: https://charts.bitnami.com/bitnami condition: redis.enabled diff --git a/README.md b/README.md index ddeb046..910b0f8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Django Helm Chart -A generic Django (plus Celery) Helm chart. +A generic Django (plus Celery) Helm chart demonstration. Do not use directly in production. -Contributions are welcome as merge requests. Please only open issues that you'd like to implement yourself or fund. Do not open support or feature requests. This chart is **not** intended to cover every use case with Django and Helm. It's a personal project that you are welcome to view and fork. Breaking changes to your workflow may happen at any time and without warning. +Contributions may be accepted as merge requests. Be respectful of my time. I will not review if I do not have time. Fork the project instead. Please only open issues that you'd like to implement yourself or fund. Do not open support or feature requests. This chart is **not** intended to cover every use case with Django and Helm. It's a personal project that you are welcome to view and fork. Breaking changes to your workflow may happen at any time and without warning. # Preparing your Django app @@ -39,6 +39,8 @@ Remember that Kubernetes "args" are Docker's CMD (or command). Pretty confusing! # Usage +Use only for demonstration purposes. Fork the repo for production. + 1. Add our Helm chart repo `helm repo add django https://gitlab.com/api/v4/projects/26807467/packages/helm/stable` 2. Review our values.yaml. At a minimum you'll need to set env.secret.SECRET_KEY and env.secret.DATABASE_URL. 3. Install the chart `helm install your-app django/django -f your-values.yml` @@ -56,6 +58,7 @@ I suggest either - Keep them in a values.yml file in a private repo - Make use of --reuse-values and --set - Keep them in a non helm chart managed service +- Use the opentofu helm provider, with a secure state backend or encrypted state. ## Deploying in CI @@ -69,3 +72,5 @@ Maintaining this chart takes time. Considering supporting it by - Check out [GlitchTip](https://glitchtip.com) error tracking, which is where this project started Commercial support is available - email info@burkesoftware.com + +If you want the scope of this project to include more, such as better merge request review or stable releases. You should consider forking it, talk to me about being a maintainer, or fund it. diff --git a/charts/postgresql-12.1.15.tgz b/charts/postgresql-12.1.15.tgz deleted file mode 100644 index 27f3244..0000000 Binary files a/charts/postgresql-12.1.15.tgz and /dev/null differ diff --git a/charts/postgresql-15.5.16.tgz b/charts/postgresql-15.5.16.tgz new file mode 100644 index 0000000..3c4bc38 Binary files /dev/null and b/charts/postgresql-15.5.16.tgz differ diff --git a/charts/redis-17.3.18.tgz b/charts/redis-17.3.18.tgz deleted file mode 100644 index 9ead5b1..0000000 Binary files a/charts/redis-17.3.18.tgz and /dev/null differ diff --git a/charts/redis-19.6.1.tgz b/charts/redis-19.6.1.tgz new file mode 100644 index 0000000..f517dcf Binary files /dev/null and b/charts/redis-19.6.1.tgz differ diff --git a/templates/beat/deployment.yaml b/templates/beat/deployment.yaml index 75cce84..36c5098 100644 --- a/templates/beat/deployment.yaml +++ b/templates/beat/deployment.yaml @@ -62,6 +62,10 @@ spec: {{- end }} - configMapRef: name: {{ include "django.fullname" . }} + {{- with .Values.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 10 }} + {{- end }} {{- with .Values.beat.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -74,5 +78,9 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.extraVolumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- end }} {{- end }} {{- end }} diff --git a/templates/pre-install-job.yaml b/templates/migrate-job.yaml similarity index 66% rename from templates/pre-install-job.yaml rename to templates/migrate-job.yaml index 06b1b30..f86a918 100644 --- a/templates/pre-install-job.yaml +++ b/templates/migrate-job.yaml @@ -1,8 +1,8 @@ -{{- if .Values.preInstall.enabled -}} +{{- if .Values.migrationJob.enabled -}} apiVersion: batch/v1 kind: Job metadata: - name: {{ include "django.fullname" . }} + name: {{ include "django.fullname" . }}-migrate labels: {{- include "django.labels" . | nindent 4 }} annotations: @@ -13,8 +13,12 @@ metadata: checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} tag: "{{ .Values.image.tag }}" spec: - activeDeadlineSeconds: {{ default 900 .Values.preInstall.activeDeadlineSeconds }} + activeDeadlineSeconds: {{ default 900 .Values.migrationJob.activeDeadlineSeconds }} template: + metadata: + labels: + app.kubernetes.io/component: migrate-job + {{- include "django.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: @@ -25,15 +29,15 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - - name: pre-install-job + - name: migrate-job securityContext: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - {{- if .Values.preInstall.resources }} - resources: {{ toYaml .Values.preInstall.resources | nindent 12 }} + {{- if .Values.migrationJob.resources }} + resources: {{ toYaml .Values.migrationJob.resources | nindent 12 }} {{- end }} - command: ["./manage.py","migrate"] + command: {{ .Values.migrationJob.command | default (list "./manage.py" "migrate") | toJson }} env: - name: DEBUG value: "False" @@ -45,7 +49,7 @@ spec: - name: DATABASE_PASSWORD valueFrom: secretKeyRef: - name: {{ include "django.postgresql.fullname" . }} + name: {{ default (include "django.postgresql.fullname" .) .Values.postgresql.auth.existingSecret }} key: postgres-password {{- end }} - name: SECRET_KEY @@ -57,4 +61,12 @@ spec: envFrom: - configMapRef: name: {{ include "django.fullname" . }} + {{- with .Values.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.extraVolumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- end }} {{- end }} diff --git a/templates/web/deployment.yaml b/templates/web/deployment.yaml index 9a232bf..cc75ff7 100644 --- a/templates/web/deployment.yaml +++ b/templates/web/deployment.yaml @@ -83,6 +83,10 @@ spec: {{- end }} - configMapRef: name: {{ include "django.fullname" . }} + {{- with .Values.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 10 }} + {{- end }} {{- with .Values.web.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -95,3 +99,7 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.extraVolumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- end }} \ No newline at end of file diff --git a/templates/worker/deployment.yaml b/templates/worker/deployment.yaml index 35fe4d4..91503f1 100644 --- a/templates/worker/deployment.yaml +++ b/templates/worker/deployment.yaml @@ -66,6 +66,10 @@ spec: {{- end }} - configMapRef: name: {{ include "django.fullname" . }} + {{- with .Values.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 10 }} + {{- end }} {{- with .Values.worker.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -78,4 +82,8 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.extraVolumes }} + volumes: + {{- toYaml . | nindent 6 }} + {{- end }} {{- end }} diff --git a/values.yaml b/values.yaml index 4b49fe4..e39ffa7 100644 --- a/values.yaml +++ b/values.yaml @@ -11,14 +11,14 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" -preInstall: +migrationJob: enabled: true + command: [] # Default ./manage.py migrate activeDeadlineSeconds: 900 resources: limits: {} requests: {} - env: normal: {} secret: {} @@ -27,6 +27,8 @@ env: # REDIS_URL: existingSecret: "" +extraVolumeMounts: [] +extraVolumes: [] web: replicaCount: 2