Skip to content

Commit

Permalink
Merge pull request #43 from stakater-charts/add-volume-mounts-persist…
Browse files Browse the repository at this point in the history
…ence

Add volume mounts persistence and fix labels
  • Loading branch information
kahootali authored Sep 8, 2020
2 parents 57230ea + 3af67a7 commit f3db1ff
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ To uninstall the chart:
| applicationName | Name of the application | `application` |
| labels.group | Label to define application group | `com.stakater.platform` |
| labels.team | Label to define team | `stakater` |
| deployment.strategy.type | Strategy for updating deployments |`RollingUpdate`|
| deployment.strategy.rollingUpdate | Rolling update configuration | rollingUpdate:<br>&nbsp;&nbsp;maxSurge: 25%<br>&nbsp;&nbsp;maxUnavailable: 25% |
| deployment.strategy | Strategy for updating deployments |`RollingUpdate`|
| deployment.reloadOnChange| Reload deployment if configMap/secret mounted are updated | `true` |
| deployment.nodeSelector | Select node to deploy this application | `{}` |
| deployment.initContainers | Init containers which runs before the app container | `[]` |
| deployment.additionalLabels | Additional labels for Deployment | `{}` |
| deployment.podLables | Additional label added on pod which is used in Service's Label Selector | `app: application-name` |
| deployment.podLables | Additional label added on pod which is used in Service's Label Selector | {} |
| deployment.annotations | Annotations on deployments | `{}` |
| deployment.additionalPodAnnotation | Additional Pod Annotations added on pod created by this Deployment | `{}` |
| deployment.fluentdConfigAnnotations | Annotations for fluentd Configurations | `{}` |
Expand Down Expand Up @@ -60,6 +59,8 @@ To uninstall the chart:
| deployment.additionalContainers | Add additional containers besides init and app containers | `[]` |
| deployment.securityContext | Security Context for the pod | `{}` |
| persistence.enabled | Enable persistence | `false` |
| persistence.mountPVC | Whether to mount the created PVC to the deployment | `false` |
| persistence.mountPath | If `persistence.mountPVC` is set, so where to mount the volume in the deployment | `/` |
| persistence.accessMode | Access mode for volume | `ReadWriteOnce` |
| persistence.storageClass | StorageClass of the volume | `-` |
| persistence.additionalLabels | Additional labels for persistent volume | `{}` |
Expand Down
6 changes: 3 additions & 3 deletions application/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ Define the name of the chart/application.

{{- define "application.labels.selector" -}}
app: {{ template "application.name" . }}
group: {{ .Values.labels.group }}
provider: stakater
team: {{ .Values.labels.team }}
{{- end -}}

{{- define "application.labels.stakater" -}}
Expand All @@ -19,6 +16,9 @@ appVersion: "{{ .Values.deployment.image.tag }}"
{{- end -}}

{{- define "application.labels.chart" -}}
group: {{ .Values.labels.group }}
provider: stakater
team: {{ .Values.labels.team }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
Expand Down
26 changes: 19 additions & 7 deletions application/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ spec:
template:
metadata:
labels:
{{ include "application.labels.stakater" . | indent 8 }}
{{ include "application.labels.chart" . | indent 8 }}
{{ include "application.labels.selector" . | indent 8 }}
{{- if .Values.deployment.podLabels }}
{{ toYaml .Values.deployment.podLabels | indent 8 }}
{{- end }}
Expand Down Expand Up @@ -113,10 +112,16 @@ spec:
httpGet:
path: {{ .Values.deployment.probes.readinessProbe.httpGet.path }}
port: {{ .Values.deployment.probes.readinessProbe.httpGet.port }}
{{- if .Values.deployment.volumeMounts }}
{{- if or (.Values.deployment.volumeMounts) (and (eq .Values.persistence.enabled true) (eq .Values.persistence.mountPVC true) )}}
volumeMounts:
{{ toYaml .Values.deployment.volumeMounts | indent 10 }}
{{- if (eq .Values.persistence.mountPVC true) }}
- mountPath: {{ .Values.persistence.mountPath }}
name: {{ template "application.name" . }}-data
{{- end }}
{{- if .Values.deployment.volumeMounts }}
{{ toYaml .Values.deployment.volumeMounts | indent 8 }}
{{- end }}
{{- end }}
resources:
limits:
memory: {{ .Values.deployment.resources.limits.memory }}
Expand All @@ -131,10 +136,17 @@ spec:
securityContext:
{{ toYaml .Values.deployment.securityContext | indent 8 }}
{{- end }}
{{- if .Values.deployment.volumes }}
{{- if or (.Values.deployment.volumes) (and (eq .Values.persistence.enabled true) (eq .Values.persistence.mountPVC true) )}}
volumes:
{{ toYaml .Values.deployment.volumes | indent 8 }}
{{- end }}
{{- if (eq .Values.persistence.mountPVC true) }}
- name: {{ template "application.name" . }}-data
persistentVolumeClaim:
claimName: {{ template "application.name" . }}-data
{{- end }}
{{- if .Values.deployment.volumes }}
{{ toYaml .Values.deployment.volumes | indent 6 }}
{{- end }}
{{- end }}
{{- if .Values.rbac.serviceAccount.name }}
serviceAccountName: {{ .Values.rbac.serviceAccount.name }}
{{- else }}
Expand Down
3 changes: 3 additions & 0 deletions application/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ metadata:
name: {{ template "application.name" . }}
spec:
selector:
{{ include "application.labels.selector" . | indent 4 }}
{{- if .Values.deployment.podLabels }}
{{ toYaml .Values.deployment.podLabels | indent 4 }}
{{- end }}
ports:
{{ toYaml .Values.service.ports | indent 4 }}
{{- end }}
10 changes: 6 additions & 4 deletions application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ deployment:
# You can change type to `Recreate` or can uncomment `rollingUpdate` specification and adjust them to your usage.
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
# rollingUpdate:
# maxSurge: 25%
# maxUnavailable: 25%

# Reload deployment if configMap/secret updates
reloadOnChange: true
Expand All @@ -36,7 +36,7 @@ deployment:

# Additional label added on pod which is used in Service's Label Selector
podLabels:
app: application-name
# env: prod

# Annotations on deployments
annotations:
Expand Down Expand Up @@ -149,6 +149,8 @@ deployment:
# Add Storage volumes to the pods
persistence:
enabled: false
mountPVC: false
mountPath: "/"
accessMode: ReadWriteOnce
## If defined, storageClass: <storageClass>
## If set to "-", storageClass: "", which disables dynamic provisioning
Expand Down

0 comments on commit f3db1ff

Please sign in to comment.