update
This commit is contained in:
parent
6e42f3144e
commit
321911b09b
|
@ -1,7 +1,12 @@
|
|||
image:
|
||||
name: alpine/helm:3.2.4
|
||||
name: alpine/helm:3.5.4
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
script:
|
||||
- helm lint
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
script:
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 GlitchTip
|
||||
Copyright (c) 2021 Burke Software and Consulting LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
54
README.md
54
README.md
|
@ -1,10 +1,58 @@
|
|||
# Django Helm Chart
|
||||
|
||||
We use this chart internally. However it's not fully documented yet nor tested in a wide range of scenarios.
|
||||
If you are a helm and kubernetes expert - feel free to use this and help contribute to this repo.
|
||||
A generic Django (plus Celery) Helm chart.
|
||||
|
||||
# Preparing your Django app
|
||||
|
||||
This chart supports a web plus optional celery and beat deployments. Be prepared to extend it as necessary.
|
||||
|
||||
Django settings will be managed by environment variables. `os.getenv` is fine. `django-environ` is nice as well. This chart expects SECRET_KEY and DATABASE_URL variables.
|
||||
|
||||
Kubernetes works best when it is able to determine application health. You Django app should have a `/_health/` view such as
|
||||
|
||||
```
|
||||
def health(request):
|
||||
return HttpResponse("ok", content_type="text/plain")
|
||||
|
||||
urlpatterns = [
|
||||
path("_health/", health),
|
||||
...
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
1. Add our Helm chart repo `helm repo add glitchtip https://glitchtip.gitlab.io/glitchtip-helm-chart/`
|
||||
2. Review our values.yaml. At a minimum you'll need to set DATABASE_URL and SECRET_KEY.
|
||||
2. Review our values.yaml. At a minimum you'll need to set SECRET_KEY.
|
||||
3. Install the chart `helm install glitchtip/glitchtip --set databaseURL=your_db --set secretKey=random_string`
|
||||
|
||||
# Tips
|
||||
|
||||
- Do you really need kubernetes? It's very complex.
|
||||
- Don't use helm without [helm diff](https://github.com/databus23/helm-diff). One typo will wipe your app without warning otherwise.
|
||||
- While supported, I don't suggest running stateful services like PostgreSQL in kubernetes. Upgrades will likely involve downtime or extensive and arcane knowledge.
|
||||
- It's fine to use this chart as a reference for your own chart instead of directly using it.
|
||||
|
||||
## Managing environment variables and secrets
|
||||
|
||||
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
|
||||
|
||||
## Deploying in CI
|
||||
|
||||
I use lwolf/helm-kubectl-docker with Gitlab CI. [Example](https://gitlab.com/glitchtip/glitchtip-frontend/-/blob/master/.gitlab-ci.yml).
|
||||
|
||||
# Support development
|
||||
|
||||
Maintaining this chart takes time. Considering supporting it by
|
||||
|
||||
- [Donating on liberapay](https://liberapay.com/burke-software/)
|
||||
- Check out [GlitchTip](https://glitchtip.com) error tracking, which is where this project started
|
||||
|
||||
Commercial support is available - email info@burkesoftware.com
|
||||
|
||||
# Contributing
|
||||
|
||||
Contributions are welcome. Report bugs on gitlab issues. Please only open feature requests that you'd like to implement yourself or pay for.
|
|
@ -1,3 +1,4 @@
|
|||
{{- if .Values.worker.enabled -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
|
@ -48,3 +49,4 @@ spec:
|
|||
name: {{ include "django.fullname" . }}
|
||||
- configMapRef:
|
||||
name: {{ include "django.fullname" . }}
|
||||
{{- end }}
|
|
@ -1,7 +1,14 @@
|
|||
{{- if .Values.web.ingress.enabled -}}
|
||||
{{- $fullName := include "django.fullname" . -}}
|
||||
{{- $svcPort := .Values.web.service.port -}}
|
||||
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
{{- if and .Values.web.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
|
||||
{{- if not (hasKey .Values.web.ingress.annotations "kubernetes.io/ingress.class") }}
|
||||
{{- $_ := set .Values.web.ingress.annotations "kubernetes.io/ingress.class" .Values.web.ingress.className}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
{{- else -}}
|
||||
apiVersion: extensions/v1beta1
|
||||
|
@ -16,6 +23,9 @@ metadata:
|
|||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.web.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
|
||||
ingressClassName: {{ .Values.web.ingress.className }}
|
||||
{{- end }}
|
||||
{{- if .Values.web.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.web.ingress.tls }}
|
||||
|
@ -33,9 +43,19 @@ spec:
|
|||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
|
||||
pathType: {{ .pathType }}
|
||||
{{- end }}
|
||||
backend:
|
||||
serviceName: {{ $fullName }}-web
|
||||
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
|
||||
service:
|
||||
name: {{ $fullName }}
|
||||
port:
|
||||
number: {{ $svcPort }}
|
||||
{{- else }}
|
||||
serviceName: {{ $fullName }}
|
||||
servicePort: {{ $svcPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{- if .Values.worker.enabled -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
|
@ -55,3 +56,4 @@ spec:
|
|||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
15
values.yaml
15
values.yaml
|
@ -12,8 +12,8 @@ nameOverride: ""
|
|||
fullnameOverride: ""
|
||||
|
||||
env:
|
||||
normal: []
|
||||
secrets: []
|
||||
normal: {}
|
||||
secret: {}
|
||||
# SECRET_KEY:
|
||||
# DATABASE_URL:
|
||||
# REDIS_URL:
|
||||
|
@ -38,7 +38,7 @@ web:
|
|||
memory: 128Mi
|
||||
nodeSelector: {}
|
||||
tolerations: []
|
||||
affinity: []
|
||||
affinity: {}
|
||||
# podAntiAffinity:
|
||||
# preferredDuringSchedulingIgnoredDuringExecution:
|
||||
# - weight: 100
|
||||
|
@ -64,19 +64,22 @@ web:
|
|||
|
||||
ingress:
|
||||
enabled: false
|
||||
annotations:
|
||||
{}
|
||||
className: ""
|
||||
annotations: {}
|
||||
# kubernetes.io/ingress.class: nginx
|
||||
# kubernetes.io/tls-acme: "true"
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths: []
|
||||
paths:
|
||||
- path: /
|
||||
pathType: ImplementationSpecific
|
||||
tls: []
|
||||
# - secretName: chart-example-tls
|
||||
# hosts:
|
||||
# - chart-example.local
|
||||
|
||||
worker:
|
||||
enabled: true
|
||||
replicaCount: 1
|
||||
autoscaling:
|
||||
enabled: false
|
||||
|
|
Loading…
Reference in a new issue