Skip to content

Commit

Permalink
[monochart] make persistence optional, fix SS labels (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru authored Aug 17, 2020
1 parent c97b64a commit 8c7bf99
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
4 changes: 2 additions & 2 deletions incubator/monochart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
description: A declarative helm chart for deploying common types of services on Kubernetes
name: monochart
version: 0.23.1
appVersion: 0.23.1
version: 0.23.2
appVersion: 0.23.2
home: https://github.com/cloudposse/charts/tree/master/incubator/monochart
icon: https://raw.githubusercontent.com/cloudposse/charts/master/incubator/monochart/logo.png
maintainers:
Expand Down
8 changes: 5 additions & 3 deletions incubator/monochart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ spec:
{{- end }}
{{- end }}
volumeMounts:
{{- if .Values.persistence.enabled }}
- mountPath: {{ .Values.persistence.mountPath | quote }}
name: storage
{{ include "monochart.files.volumeMounts" . | indent 8 }}
{{- end }}
{{- include "monochart.files.volumeMounts" . | nindent 8 }}
{{- with .Values.probes }}
{{ toYaml . | indent 8 }}
{{- end }}
Expand All @@ -121,14 +123,14 @@ spec:
{{- end }}
{{- end }}
volumes:
{{- if .Values.persistence.enabled }}
- name: storage
{{- if .Values.persistence }}
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "common.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{ include "monochart.files.volumes" . | indent 6 }}
{{- include "monochart.files.volumes" . | nindent 6 }}
{{- end -}}
38 changes: 34 additions & 4 deletions incubator/monochart/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,48 @@ spec:
template:
metadata:
name: {{ include "common.fullname" . }}
{{- with .Values.statefulset.pod.annotations }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.statefulset.pod.annotations }}
{{ toYaml . | indent 8 }}
{{- end }}
labels:
app: {{ include "common.name" . }}
release: {{ .Release.Name | quote }}
serve: "true"
{{- with .Values.statefulset.pod.labels }}
{{ toYaml . | indent 4 }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
{{- if index .Values "serviceAccountName" }}
serviceAccountName: {{ .Values.serviceAccountName }}
{{- end }}
terminationGracePeriodSeconds: 0
terminationGracePeriodSeconds: {{ .Values.statefulset.terminationGracePeriodSeconds }}
{{- if .Values.statefulset.affinity }}
affinity:
{{- if or .Values.statefulset.affinity.podAntiAffinity (eq .Values.statefulset.affinity.affinityRule "ShouldBeOnDifferentNode") }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
{{- if .Values.statefulset.affinity.podAntiAffinity }}
{{- if .Values.statefulset.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution }}
{{- with .Values.statefulset.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution }}
{{ toYaml . | indent 10 }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq .Values.statefulset.affinity.affinityRule "ShouldBeOnDifferentNode" }}
{{- include "monochart.affinityRule.ShouldBeOnDifferentNode" . | nindent 10 }}
{{- end }}
{{- end }}
{{- if .Values.statefulset.affinity.podAffinity }}
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
{{- with .Values.statefulset.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution }}
{{ toYaml . | indent 10 }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: {{ .Release.Name }}
image: {{ required "image.repository is required!" .Values.image.repository }}:{{ required "image.tag is required!" .Values.image.tag }}
Expand All @@ -70,9 +96,11 @@ spec:
{{- end }}
{{- end }}
volumeMounts:
{{- if .Values.statefulset.persistence.enabled }}
- mountPath: {{ .Values.statefulset.persistence.mountPath | quote }}
name: {{ include "common.fullname" . }}
{{ include "monochart.files.volumeMounts" . | indent 8 }}
{{- end }}
{{- include "monochart.files.volumeMounts" . | nindent 8 }}
{{- with .Values.probes }}
{{ toYaml . | indent 8 }}
{{- end }}
Expand All @@ -95,6 +123,7 @@ spec:
{{- end }}
volumes:
{{ include "monochart.files.volumes" . | indent 6 }}
{{- if .Values.statefulset.persistence.enabled }}
{{- if not .Values.statefulset.persistence.useVolumeClaimTemplates }}
- name: {{ (include "common.fullname" . ) }}
persistentVolumeClaim:
Expand Down Expand Up @@ -127,5 +156,6 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
2 changes: 2 additions & 0 deletions incubator/monochart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ statefulset:
## ref: https://v1-10.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#statefulsetupdatestrategy-v1-apps
# strategy: {}
revisionHistoryLimit: 10
terminationGracePeriodSeconds: 10
# annotations:
# name: value
# labels:
Expand All @@ -116,6 +117,7 @@ statefulset:
# args:
## Configure volumeClaimTemplate block
persistence:
enabled: true
useVolumeClaimTemplates: true
accessMode: ReadWriteOnce
size: 8Gi
Expand Down

0 comments on commit 8c7bf99

Please sign in to comment.