diff --git a/README.md b/README.md index c5ad6d6..dd21b37 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,7 @@ be the options passed via the `--set` flag of the `helm install` command. ## Missing features -1. Add Persistent Volume for the SQLite database -2. Support postgres, maria and mysql database directly as helm dependency if as +1. Support postgres, maria and mysql database directly as helm dependency if as `DATABASE_DRIVER` an other instead of `sqlite` has been selected. Alternatively can be passed a completely custom string to establish a database connection, when the database is running outside the cluster. diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 650f187..10ca185 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -38,7 +38,24 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources | nindent 12 }} - + {{- if eq (default "sqlite3" .Values.config.DRONE_DATABASE_DRIVER) "sqlite3" }} + volumeMounts: + - name: data + mountPath: {{ default "/data/database.sqlite" .Values.config.DRONE_DATABASE_DATASOURCE | dir }} + {{- end }} + {{- if and (eq (default "sqlite3" .Values.config.DRONE_DATABASE_DRIVER) "sqlite3") .Values.persistence.existingClaim }} + volumes: + - name: data + persistentVolumeClaim: + {{- with .Values.persistence.existingClaim }} + claimName: {{ tpl . $ }} + {{- end }} + {{- else if and (.Values.config.DRONE_DATABASE_DRIVER | default "sqlite3" | eq "sqlite3") (not .Values.persistence.existingClaim) }} + volumes: + - name: data + persistentVolumeClaim: + claimName: drone + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/templates/persistentVolumeClaim.yaml b/templates/persistentVolumeClaim.yaml new file mode 100644 index 0000000..012477e --- /dev/null +++ b/templates/persistentVolumeClaim.yaml @@ -0,0 +1,17 @@ +{{ if and (eq (default "sqlite3" .Values.config.DRONE_DATABASE_DRIVER) "sqlite3") (not .Values.persistence.existingClaim) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: drone +spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- if .Values.persistence.storageClass }} + storageClassName: {{ .Values.persistence.storageClass | quote }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 4399868..d65310d 100644 --- a/values.yaml +++ b/values.yaml @@ -27,7 +27,7 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 -config: +config: {} # DRONE_BITBUCKET_CLIENT_ID # String value. Configures the Bitbucket OAuth client id. This is used to # authorize access to Bitbucket on behalf of a Drone user. @@ -506,4 +506,15 @@ nodeSelector: {} tolerations: [] -affinity: {} \ No newline at end of file +affinity: {} + +# persistence is only required when config.DATABASE_DRIVER is not sqlite3 or +# undefined. +persistence: + # existingClaim: + size: 5Gi + accessModes: + - ReadWriteOnce + labels: {} + annotation: {} + # storageClass: \ No newline at end of file