Commit c90c5da6 authored by Evili del Rio's avatar Evili del Rio

Add proper PVC for Django

parent 1cd908c7
Pipeline #1765 passed with stage
in 14 seconds
......@@ -2,3 +2,4 @@
*.lock
charts
*.*gz
\#*\#
......@@ -16,6 +16,7 @@
*.tmp
*.orig
*~
\#*\#
# Various IDEs
.project
.idea/
......
......@@ -61,3 +61,56 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Return Django Secret Key
*/}}
{{- define "django.secret_key" -}}
{{- if .Values.global.django.secretKey }}
{{- .Values.global.django.secretKey -}}
{{- else -}}
{{- randAlphaNum 72 -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Storage Class
*/}}
{{- define "django.storageClass" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
*/}}
{{- if .Values.global -}}
{{- if .Values.global.storageClass -}}
{{- if (eq "-" .Values.global.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.global.storageClass -}}
{{- end -}}
{{- else -}}
{{- if .Values.persistence.storageClass -}}
{{- if (eq "-" .Values.persistence.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- if .Values.persistence.storageClass -}}
{{- if (eq "-" .Values.persistence.storageClass) -}}
{{- printf "storageClassName: \"\"" -}}
{{- else }}
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Return Django Files ClaimName
*/}}
{{- define "django.claimName" -}}
{{ .Values.persistence.claimName | default (printf "%s-django-files" .Release.Name) }}
{{- end -}}
......@@ -27,15 +27,19 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgresql
key: postgresql-password
envFrom:
- configMapRef:
name: django-config
name: {{ .Release.Name }}-django-config
- configMapRef:
name: postgres-config
name: {{ .Release.Name }}-postgres-config
- secretRef:
name: postgres-password
- secretRef:
name: django-secret-key
name: {{ .Release.Name }}-django-secret-key
ports:
- name: gunicorn
containerPort: 5000
......@@ -50,14 +54,14 @@ spec:
livenessProbe:
httpGet:
path: /health_checks
port: http
port: gunicorn
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /health_checks
port: http
port: gunicorn
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
......@@ -65,8 +69,12 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: django-files
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: django-files
claimName: {{ include "django.claimName" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
......
apiVersion: v1
kind: ConfigMap
metadata:
name: django-config
name: {{ .Release.Name }}-django-config
data:
DJANGO_DEBUG: "0"
{{- range $key, $value := .Values.django.config }}
{{ $key }}: {{ $value }}
{{ $key }}: {{ $value | quote }}
{{- end }}
......@@ -2,6 +2,6 @@ apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: django-secret-key
name: {{ .Release.Name }}-django-secret-key
data:
DJANGO_SECRET_KEY: {{ .Values.django.secret_key | default (randAlphaNum 72) }}
DJANGO_SECRET_KEY: {{ include "django.secret_key" . | b64enc | quote }}
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
name: {{ .Release.Name }}-postgres-config
data:
POSTGRES_DATABASE: {{ .Values.global.postgresql.postgresqlDatabase }}
POSTGRES_USER: {{ .Values.global.postgresql.postgresqlUsername }}
......
......@@ -15,7 +15,7 @@ image:
#
django:
config:
DJANGO_ALLOWED_HOSTS: "['*']"
DJANGO_ALLOWED_HOSTS: ['*']
# DJANGO_DEBUG: info
# DJANGO_SUPERUSER_USERNAME: admin
# DJANGO_SUPERUSER_EMAIL: admin@example.com
......@@ -63,6 +63,22 @@ ingress:
# hosts:
# - chart-example.local
## Django files Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
persistence:
enabled: true
# claimName:
# storageClass: "-"
accessModes:
- ReadWriteOnce
size: 2Gi
annotations: {}
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
......@@ -82,6 +98,8 @@ tolerations: []
affinity: {}
global:
django:
secretKey:
postgresql:
postgresqlHost:
postgresqlUsername: django
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment