Skip to content
Open
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
4 changes: 2 additions & 2 deletions charts/base/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.52
version: 0.1.53

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.52"
appVersion: "0.1.53"
18 changes: 17 additions & 1 deletion charts/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,4 +462,20 @@ base:
app.kubernetes.io/name: base-fullname
maxSkew: 2
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
whenUnsatisfiable: ScheduleAnyway

### If you want create cronjob
jobs:
- name: events
schedule: "*/2 * * * *"
restartPolicy: OnFailure
serviceAccount:
create: false
image:
repository: dasmeta/events
tag: 0.1.18
env:
HOST: "0.0.0.0"
PORT: "1337"
SERVE_ADMIN_PANEL: "true"
NODE_ENV: "production"
2 changes: 2 additions & 0 deletions charts/base/templates/configmap.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{- if eq .Values.type "Deployment" -}}
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "base.fullname" . }}
data:
{{- toYaml .Values.config | nindent 2 }}
{{- end }}

---
{{- if .Values.extraContainer.configmap }}
Expand Down
82 changes: 82 additions & 0 deletions charts/base/templates/cronjob/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{- if eq .Values.type "CronJob" -}}
{{- range $job := .Values.jobs }}
{{- $tag := $job.image.tag }}
{{- $image := print $job.image.repository ":" $tag }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ $job.name | quote}}
spec:
schedule: {{ $job.schedule | quote}}
jobTemplate:
spec:
template:
spec:
serviceAccountName: {{ $job.serviceAccount.name }}
restartPolicy: {{ $job.restartPolicy }}
containers:
- name: {{ $job.name | quote }}
image: {{ $image | quote}}
imagePullPolicy: IfNotPresent
{{- if $job.command }}
command:
{{- range $cmd := $job.command }}
- {{ $cmd }}
{{- end }}
{{- end }}
{{- if $job.args }}
args:
{{- range $args := $job.args }}
- {{ $args }}
{{- end }}
{{- end }}
{{ if $job.resources }}
resources:
requests:
cpu: {{ $job.resources.requests.cpu }}
memory: {{ $job.resources.requests.memory }}
limits:
cpu: {{ $job.resources.limits.cpu }}
memory: {{ $job.resources.limits.memory }}
{{ end }}
env:
{{- range $key, $value := $job.env }}
- name: {{ $key | quote}}
value: {{ $value | quote }}
{{- end }}
{{- if $job.volumes }}
volumeMounts:
{{- range $index, $element := $job.volumes }}
- name: {{ coalesce $element.name (add $index 1) }}
mountPath: {{ $element.mountPath }}
readOnly: {{ $element.readOnly | default false }}
{{- end }}
{{- end }}
{{- with $job.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with $job.affinity }}
affinity:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with $job.tolerations }}
tolerations:
{{ toYaml . | indent 12 }}
{{- end }}
{{- if $job.volumes }}
volumes:
{{- range $index, $element := $job.volumes }}
- name: {{ coalesce $element.name (add $index 1) }}
{{- if $element.persistentVolumeClaim }}
persistentVolumeClaim:
{{- if $element.persistentVolumeClaim.claimName }}
claimName: {{ $element.persistentVolumeClaim.claimName }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
---
{{- end }}
37 changes: 37 additions & 0 deletions charts/base/templates/cronjob/cronjobstorage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if eq .Values.type "CronJob" -}}
{{- range $job := .Values.jobs }}
{{- if $job.storage -}}
{{ range $storage := $job.storages }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ $storage.persistentVolumeClaimName }}
labels:
{{/* {{- include "base.labels" . | nindent 4 }}*/}}
{{- if $storage.keepPvc }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
spec:
{{- with $storage }}
accessModes:
{{- toYaml .accessModes | nindent 4 }}
volumeMode: {{ .volumeMode | default "Filesystem" }}
resources:
requests:
storage: {{ .requestedSize }}
{{- if .className }}
storageClassName: {{ .className }}
{{- end }}
{{- end }}
{{ if $storage.enableDataSource}}
dataSource:
kind: PersistentVolumeClaim
name: {{ $storage.persistentVolumeClaimName }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
---
{{- end }}
2 changes: 2 additions & 0 deletions charts/base/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.type "Deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -249,3 +250,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/base/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.type "Deployment" -}}
{{- if .Values.service.enabled -}}
apiVersion: v1
kind: Service
Expand All @@ -19,3 +20,4 @@ spec:
selector:
{{- include "base.selectorLabels" . | nindent 4 }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/base/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.type "Deployment" -}}
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
Expand All @@ -10,3 +11,22 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}

---

{{- if eq .Values.type "CronJob" -}}
{{- range $job := .Values.jobs }}
{{- if $job.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ $job.serviceAccount.name }}
labels:
{{- with $job.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/base/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.type "Deployment" -}}
{{- if .Values.service.enabled -}}
apiVersion: v1
kind: Pod
Expand All @@ -15,3 +16,4 @@ spec:
args: ['{{ include "base.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: OnFailure
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions charts/base/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

type: Deployment

replicaCount: 1

image:
Expand Down Expand Up @@ -154,3 +156,41 @@ pdb:
enabled: false
minAvailable: 1
pdbName:

jobs: {}
# - name: cronjob1
# schedule: "0 * * * *"
# restartPolicy: OnFailure
# serviceAccount:
# create: true
# name: "sa-1"
# image:
# registry: docker.io
# repository: busybox
# pullPolicy: IfNotPresent
# tag: latest
# env:
# - name: key3
# value: value3
# - name: key4
# value: value4
# volumes: {}
# # - name: persistent-storage
# # mountPath: /path
# # persistentVolumeClaim:
# # claimName: claim
# storage: {}
# # persistentVolumeClaimName: claim
# # accessModes:
# # - ReadWriteMany
# # className: claim
# # requestedSize: 5Gi
# # enableDataSource: false

# resources: {}
# # request:
# # cpu: 500m
# # memory: 5Gi
# # limits:
# # cpu: 500m
# # memory: 5Gi