Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions charts/frankenphp/templates/crons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ $cronName }}-{{ .name }}
labels:
{{- include "helm-frankenphp.labels" $ | nindent 4 }}
spec:
schedule: "{{ .schedule }}"
successfulJobsHistoryLimit: {{ (default .successfulJobsHistoryLimit 1) }}
Expand All @@ -17,28 +19,37 @@ spec:
backoffLimit: {{ (default .backoffLimit 0) }}
template:
spec:
{{- with $.Values.serviceAccount }}
serviceAccountName: {{ include "helm-frankenphp.serviceAccountName" . }}
{{- with $.Values.image.pullSecrets | default (list)}}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if $.Values.serviceAccount }}
serviceAccountName: {{ include "helm-frankenphp.serviceAccountName" $ }}
{{- end }}
restartPolicy: {{ (default .restartPolicy "Never") }}
containers:
- name: {{ $cronName | lower }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
imagePullPolicy: {{ (default .imagePullPolicy "IfNotPresent") }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ $.Values.image.pullPolicy | default "IfNotPresent" }}
command:
- "/bin/sh"
- "-c"
- {{ .command }};
{{- if $.Values.resources }}
{{- with $.Values.resources }}
resources:
{{- toYaml $.Values.resources | nindent 16 }}
{{- toYaml . | nindent 16 }}
{{- end }}
{{- with $.Values.env }}
env:
{{- toYaml . | nindent 16 }}
{{- end }}
{{- if or $.Values.volumeMounts }}
{{- if or $.Values.php.ini $.Values.volumeMounts }}
volumeMounts:
{{- if $.Values.php.ini }}
- name: php-ini
mountPath: /usr/local/etc/php/conf.d/99-custom.ini
subPath: php.ini
{{- end }}
{{- with $.Values.volumeMounts }}
{{- toYaml . | nindent 16 }}
{{- end }}
Expand All @@ -55,8 +66,15 @@ spec:
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.volumes }}
{{- if or $.Values.php.ini $.Values.volumes }}
volumes:
{{- if $.Values.php.ini }}
- name: php-ini
configMap:
name: {{ $.Release.Name }}-php-ini
{{- end }}
{{- with $.Values.volumes }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
8 changes: 5 additions & 3 deletions charts/frankenphp/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.serviceAccount }}
{{- if .Values.serviceAccount }}
serviceAccountName: {{ include "helm-frankenphp.serviceAccountName" . }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy | default "Always" }}
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
ports:
- name: http
containerPort: 80
Expand All @@ -42,8 +42,10 @@ spec:
- containerPort: 2019
protocol: TCP
name: metrics
{{- with .Values.resources }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.env }}
env:
{{- toYaml . | nindent 12 }}
Expand Down
9 changes: 7 additions & 2 deletions charts/frankenphp/templates/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,25 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $context.Values.serviceAccount }}
serviceAccountName: {{ include "helm-frankenphp.serviceAccountName" $context }}
{{- end }}
restartPolicy: {{ $job.restartPolicy | default "OnFailure" }}
containers:
- name: {{ $job.name | replace "_" "-" }}
image: "{{ $context.Values.image.repository }}:{{ $context.Values.image.tag | default $context.Chart.AppVersion }}"
imagePullPolicy: {{ $context.Values.image.pullPolicy | default "Always" }}
imagePullPolicy: {{ $context.Values.image.pullPolicy | default "IfNotPresent" }}
command: ["/bin/sh", "-c"]
args:
- {{ $job.command }}
{{- with $context.Values.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with ($job.resources | default $context.Values.resources) }}
resources:
{{- toYaml ($job.resources | default $context.Values.resources) | nindent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or $context.Values.php.ini $context.Values.volumeMounts }}
volumeMounts:
{{- if $context.Values.php.ini }}
Expand Down
18 changes: 13 additions & 5 deletions charts/frankenphp/templates/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $workerName }}
labels:
{{- include "helm-frankenphp.labels" $ | nindent 4 }}
spec:
{{- if not .autoscale }}
replicas: {{ .replicas | default 1 }}
Expand All @@ -23,13 +25,18 @@ spec:
labels:
app: {{ $workerName }}
spec:
{{- with $.Values.serviceAccount }}
serviceAccountName: {{ include "helm-frankenphp.serviceAccountName" . }}
{{- with $.Values.image.pullSecrets | default (list)}}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $.Values.serviceAccount }}
serviceAccountName: {{ include "helm-frankenphp.serviceAccountName" $ }}
{{- end }}
restartPolicy: Always
containers:
- name: {{ $workerName }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ $.Values.image.pullPolicy | default "IfNotPresent" }}
lifecycle:
preStop:
exec:
Expand All @@ -38,13 +45,14 @@ spec:
env:
{{- toYaml . | nindent 12 }}
{{- end }}

command: # todo: find a better way to handle this
- "/bin/sh"
- "-c"
- {{ .command | quote }}
{{- with $.Values.resources }}
resources:
{{- toYaml $.Values.resources | nindent 12 }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or $.Values.php.ini $.Values.volumeMounts }}
volumeMounts:
{{- if $.Values.php.ini }}
Expand Down
55 changes: 55 additions & 0 deletions charts/frankenphp/tests/cron_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ tests:
- equal:
path: spec.schedule
value: "*/5 * * * *"
- it: should have labels in metadata
documentIndex: 0
asserts:
- exists:
path: metadata.labels
- it: should have resources if set
documentIndex: 0
set:
Expand Down Expand Up @@ -62,3 +67,53 @@ tests:
asserts:
- notExists:
path: spec.jobTemplate.spec.template.spec.containers[0].resources
- it: should default imagePullPolicy to IfNotPresent
documentIndex: 0
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].imagePullPolicy
value: IfNotPresent
- it: should use global imagePullPolicy when set
documentIndex: 0
set:
image:
pullPolicy: Always
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].imagePullPolicy
value: Always
- it: should have imagePullSecrets if set
documentIndex: 0
set:
image:
pullSecrets:
- name: mySecret
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.imagePullSecrets[0].name
value: mySecret
- it: should mount php.ini in cron
documentIndex: 0
set:
php:
ini: "memory_limit = 512M"
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].volumeMounts[0].name
value: php-ini
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].volumeMounts[0].mountPath
value: /usr/local/etc/php/conf.d/99-custom.ini
- equal:
path: spec.jobTemplate.spec.template.spec.volumes[0].name
value: php-ini
- it: should set serviceAccountName when serviceAccount is configured
documentIndex: 0
set:
serviceAccount:
create: true
name: my-sa
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.serviceAccountName
value: my-sa
45 changes: 45 additions & 0 deletions charts/frankenphp/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,48 @@ tests:
- equal:
path: spec.template.spec.volumes[0].name
value: php-ini
- it: should default imagePullPolicy to IfNotPresent
asserts:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: IfNotPresent
- it: should use global imagePullPolicy when set
set:
image:
pullPolicy: Always
asserts:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: Always
- it: should have imagePullSecrets if set
set:
image:
pullSecrets:
- name: mySecret
asserts:
- equal:
path: spec.template.spec.imagePullSecrets[0].name
value: mySecret
- it: should not have resources if not set
asserts:
- notExists:
path: spec.template.spec.containers[0].resources
- it: should have resources if set
set:
resources:
requests:
cpu: "100m"
memory: "128Mi"
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: "100m"
- it: should set serviceAccountName when serviceAccount is configured
set:
serviceAccount:
create: true
name: my-sa
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: my-sa
75 changes: 75 additions & 0 deletions charts/frankenphp/tests/jobs_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,78 @@ tests:
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].name
value: php-ini
- it: should default imagePullPolicy to IfNotPresent
set:
jobs:
- name: test
command: "cmd"
asserts:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: IfNotPresent
- it: should use global imagePullPolicy when set
set:
jobs:
- name: test
command: "cmd"
image:
pullPolicy: Always
asserts:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: Always
- it: should set serviceAccountName when serviceAccount is configured
set:
jobs:
- name: test
command: "cmd"
serviceAccount:
create: true
name: my-sa
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: my-sa
- it: should not have serviceAccountName when serviceAccount is not set
set:
jobs:
- name: test
command: "cmd"
asserts:
- notExists:
path: spec.template.spec.serviceAccountName
- it: should not have resources if not set
set:
jobs:
- name: test
command: "cmd"
asserts:
- notExists:
path: spec.template.spec.containers[0].resources
- it: should use global resources when set
set:
jobs:
- name: test
command: "cmd"
resources:
requests:
cpu: "100m"
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: "100m"
- it: should use per-job resources override
set:
jobs:
- name: test
command: "cmd"
resources:
requests:
cpu: "500m"
resources:
requests:
cpu: "100m"
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: "500m"
Loading
Loading