Skip to content

Commit

Permalink
Merge pull request #23 from colearendt/improve-generic-values
Browse files Browse the repository at this point in the history
add proper storage/volume support
  • Loading branch information
colearendt authored Jan 19, 2022
2 parents 536dd73 + 0bd203c commit fa7adbd
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 16 deletions.
2 changes: 1 addition & 1 deletion charts/generic/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: generic
description: A generic Helm chart for Kubernetes

type: application
version: 0.1.5
version: 0.2.0
appVersion: latest
maintainers:
- name: colearendt
Expand Down
9 changes: 9 additions & 0 deletions charts/generic/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 0.2.0

- BREAKING: move `podAnnotations` into `pod.annotations`
- BREAKING: move `podSecurityContext` into `pod.securityContext`
- Add proper mounting for `storage` (fixes a shortcoming in 0.1.3+)
- Add `storage.mountPath` value for customizing the mount path. Defaults to `/mnt/storage`
- Add values for arbitrary `pod.volumes` and `pod.volumeMounts`
- Add values for `pod.labels`

# 0.1.5

- Add values for `readinessProbe`, `livenessProbe` and `startupProbe`
Expand Down
10 changes: 7 additions & 3 deletions charts/generic/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generic

![Version: 0.1.5](https://img.shields.io/badge/Version-0.1.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)

A generic Helm chart for Kubernetes

Expand Down Expand Up @@ -33,10 +33,13 @@ A generic Helm chart for Kubernetes
| livenessProbe | object | `{}` | customize the primary container's livenessProbe. Default none |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| pod.annotations | object | `{}` | Additional annotations to add to the pods |
| pod.env | list | `[]` | |
| pod.labels | object | `{}` | Additional labels to add to the pods |
| pod.port | int | `80` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| pod.securityContext | object | `{}` | |
| pod.volumeMounts | list | `[]` | |
| pod.volumes | list | `[]` | |
| readinessProbe | object | `{"httpGet":{"path":"/","port":"http"}}` | customize the primary container's readinessProbe. Default is httpGet on the default `http` port |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
Expand All @@ -49,6 +52,7 @@ A generic Helm chart for Kubernetes
| startupProbe | object | `{}` | customize the primary container's startupProbe. Default none |
| storage.accessModes[0] | string | `"ReadWriteOnce"` | |
| storage.create | bool | `false` | |
| storage.mountPath | string | `"/mnt/storage"` | |
| storage.name | string | `""` | |
| storage.requests.storage | string | `"6Gi"` | |
| storage.storageClassName | string | `""` | |
Expand Down
12 changes: 7 additions & 5 deletions charts/generic/ci/all-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ pod:
env:
- name: "TEST_ENV"
value: "SOME_VALUE"
annotations:
three: four
five: six
labels:
one: two
securityContext: {}
# fsGroup: 2000

serviceAccount:
# -- Specifies whether a service account should be created
Expand All @@ -25,11 +32,6 @@ serviceAccount:
# -- If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
Expand Down
28 changes: 26 additions & 2 deletions charts/generic/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ spec:
{{- include "generic.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
{{- with .Values.pod.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "generic.selectorLabels" . | nindent 8 }}
{{- with .Values.pod.labels }}
{{- toYaml . | nindent 8}}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "generic.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.pod.securityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand All @@ -53,6 +56,16 @@ spec:
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.pod.volumeMounts .Values.storage.create }}
volumeMounts:
{{- if .Values.storage.create }}
- name: storage
mountPath: {{ .Values.storage.mountPath }}
{{- end }}
{{- with .Values.pod.volumeMounts }}
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -61,6 +74,17 @@ spec:
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.pod.volumes .Values.storage.create }}
volumes:
{{- if .Values.storage.create }}
- name: storage
persistentVolumeClaim:
claimName: {{ include "generic.fullname" . }}-storage
{{- end}}
{{- with .Values.pod.volumes }}
{{- . | toYaml | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
Expand Down
14 changes: 9 additions & 5 deletions charts/generic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ fullnameOverride: ""
pod:
port: 80
env: []
volumes: []
volumeMounts: []
# -- Additional annotations to add to the pods
annotations: {}
# -- Additional labels to add to the pods
labels: {}
securityContext: {}
# fsGroup: 2000

storage:
name: ''
Expand All @@ -22,6 +30,7 @@ storage:
storageClassName: ''
requests:
storage: 6Gi
mountPath: /mnt/storage

serviceAccount:
# -- Specifies whether a service account should be created
Expand All @@ -32,11 +41,6 @@ serviceAccount:
# -- If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
Expand Down

0 comments on commit fa7adbd

Please sign in to comment.