Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update values definition #12

Merged
merged 3 commits into from
Nov 4, 2024
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
40 changes: 20 additions & 20 deletions charts/interop-eks-cronjob-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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


A Helm chart for PagoPa Interop CronJobs

## Values
Expand All @@ -11,28 +12,27 @@ The following table lists the configurable parameters of the Interop-eks-cronjob

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| activeDeadlineSeconds | int | 3600 | The activeDeadlineSeconds applies to the duration of the job, no matter how many Pods are created. Once a Job reaches activeDeadlineSeconds, all of its running Pods are terminated. |
| concurrencyPolicy | string | Allow | [concurrencyPolicy](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#concurrency-policy) field specifies how to treat concurrent executions of a Job that is created by this CronJob. |
| failedJobsHistoryLimit | int | 1 | [failedJobsHistoryLimit](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits) field specifies the number of failed finished jobs to keep. Setting this field to 0 will not keep any failed jobs. |
| image.digest | string | `nil` | Image digest |
| image.imagePullPolicy | string | `"Always"` | |
| image.repositoryPrefix | string | `nil` | Image repository |
| image.tag | string | `nil` | Image tag |
| job.env | object | `nil` | List of environment variables for a container, specifying a value directly for each named variable |
| job.envFromConfigmaps | object | `nil` | List of environment variables for a container, specifying a key from a Configmap for each named variable (k8s equivalent of envFrom.configMapRef) |
| job.envFromFieldRef | object | `nil` | List of pod fields used as values for environment variablesenvironment variables for a container, specifying a key from a Secret for each named variable (k8s equivalent of env.valueFrom.fieldRef.fieldPath) |
| job.envFromSecrets | object | `nil` | List of environment variables for a container, specifying a key from a Secret for each named variable (k8s equivalent of envFrom.secretRef) |
| cronjob.activeDeadlineSeconds | int | 3600 | The activeDeadlineSeconds applies to the duration of the job, no matter how many Pods are created. Once a Job reaches activeDeadlineSeconds, all of its running Pods are terminated. |
| cronjob.concurrencyPolicy | string | Allow | [concurrencyPolicy](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#concurrency-policy) field specifies how to treat concurrent executions of a Job that is created by this CronJob. |
| cronjob.env | object | `nil` | List of environment variables for a container, specifying a value directly for each named variable |
| cronjob.envFromConfigmaps | object | `nil` | List of environment variables for a container, specifying a key from a Configmap for each named variable (k8s equivalent of envFrom.configMapRef) |
| cronjob.envFromFieldRef | object | `nil` | List of pod fields used as values for environment variablesenvironment variables for a container, specifying a key from a Secret for each named variable (k8s equivalent of env.valueFrom.fieldRef.fieldPath) |
| cronjob.envFromSecrets | object | `nil` | List of environment variables for a container, specifying a key from a Secret for each named variable (k8s equivalent of envFrom.secretRef) |
| cronjob.failedJobsHistoryLimit | int | 1 | [failedJobsHistoryLimit](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits) field specifies the number of failed finished jobs to keep. Setting this field to 0 will not keep any failed jobs. |
| cronjob.image.digest | string | `nil` | Image digest |
| cronjob.image.imagePullPolicy | string | `"Always"` | |
| cronjob.image.repositoryPrefix | string | `nil` | Image repository |
| cronjob.image.tag | string | `nil` | Image tag |
| cronjob.resources | object | `{"limits":{"cpu":null,"memory":null},"requests":{"cpu":null,"memory":null}}` | K8s container resources requests and limits |
| cronjob.restartPolicy | string | `"OnFailure"` | |
| cronjob.timezone | string | `nil` | [Time zone](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones) to use when calculating schedule |
| cronjob.schedule | string | `nil` | The [schedule](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-syntax) field is required. The value of that field follows the [Cron](https://en.wikipedia.org/wiki/Cron) syntax. |
| cronjob.successfulJobsHistoryLimit | int | 0 | [successfulJobsHistoryLimit](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits) field specifies the number of successful finished jobs to keep. Setting this field to 0 will not keep any successful jobs |
| cronjob.suspend | boolean | `false` | [suspend](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-suspension) field allows to suspend execution of Jobs for a CronJob.  @default -- false. |
| name | string | `nil` | Name of the service that will be deployed on K8s cluster |
| namespace | string | `nil` | Namespace hosting the service that will be deployed on K8s cluster |
| replicas | int | 1 | Number of desired replicas for the service being deployed |
| resources | object | `{"limits":{"cpu":null,"memory":null},"requests":{"cpu":null,"memory":null}}` | K8s container resources requests and limits |
| restartPolicy | string | `"OnFailure"` | |
| roleArn | string | `nil` | ServiceAccount roleARN used for eks.amazonaws.com/role-arn annotation |
| schedule | string | `nil` | The [schedule](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-syntax) field is required. The value of that field follows the [Cron](https://en.wikipedia.org/wiki/Cron) syntax. |
| successfulJobsHistoryLimit | int | 0 | [successfulJobsHistoryLimit](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits) field specifies the number of successful finished jobs to keep. Setting this field to 0 will not keep any successful jobs |
| suspend | boolean | `false` | [suspend](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-suspension) field allows to suspend execution of Jobs for a CronJob.  @default -- false. |
| techStack | enum | `nil` | Defines the technology used to develop the container. The following values are allowed: [ "nodejs" ] |
| timeZone | string | `nil` | [Time zone](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones) to use when calculating schedule |
| serviceAccount.roleArn | string | `nil` | ServiceAccount roleARN used for eks.amazonaws.com/role-arn annotation |


## 1. Configurazione di Cronjob

Expand Down
10 changes: 5 additions & 5 deletions charts/interop-eks-cronjob-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ Common labels
app.kubernetes.io/name: {{ .Values.name }}
helm.sh/chart: {{ include "interop-eks-cronjob-chart.chart" . }}
{{ include "interop-eks-cronjob-chart.selectorLabels" . }}
{{- if .Values.image.tag }}
{{- if .Values.cronjob.image.tag }}
{{- $imageTag := "" }}
{{- $imageTag = (nospace .Values.image.tag) }}
{{- $imageTag = (nospace .Values.cronjob.image.tag) }}
app.kubernetes.io/version: {{ $imageTag }}
{{ else if .Values.image.digest }}
{{ else if .Values.cronjob.image.digest }}
{{- $digestSuffix := "" }}
{{- $digestSuffix = (nospace .Values.image.digest) }}
{{- $digestSuffix = (nospace .Values.cronjob.image.digest) }}
app.kubernetes.io/version: {{ $digestSuffix }}
{{ else if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
Expand Down Expand Up @@ -120,4 +120,4 @@ Usage:
{{- else }}
{{- $value -}}
{{- end -}}
{{- end -}}
{{- end -}}
68 changes: 36 additions & 32 deletions charts/interop-eks-cronjob-chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{ $root := . }}

{{- $digestSuffix := "" }}
{{- if and .Values.image .Values.image.digest }}
{{- $digestSuffix = (nospace (cat "@" .Values.image.digest)) }}
{{- if and .Values.cronjob.image .Values.cronjob.image.digest }}
{{- $digestSuffix = (nospace (cat "@" .Values.cronjob.image.digest)) }}
{{- end }}

{{- $imageTag := "" }}
{{- if .Values.image.tag }}
{{- $imageTag = (nospace (cat ":" .Values.image.tag)) }}
{{- if .Values.cronjob.image.tag }}
{{- $imageTag = (nospace (cat ":" .Values.cronjob.image.tag)) }}
{{- end }}

apiVersion: batch/v1
Expand All @@ -18,12 +18,12 @@ metadata:
labels:
{{- include "interop-eks-cronjob-chart.labels" . | nindent 4 }}
spec:
schedule: {{ .Values.schedule | quote }}
timeZone: {{ .Values.timeZone | quote }}
failedJobsHistoryLimit: {{ .Values.failedJobsHistoryLimit }} # K8s default is 1, , Chart default is 1
successfulJobsHistoryLimit: {{ .Values.successfulJobsHistoryLimit }} # K8s default is 3, Chart default is 0
{{- if .Values.concurrencyPolicy }} # K8s default is Allow
concurrencyPolicy: {{ .Values.concurrencyPolicy }}
schedule: {{ .Values.cronjob.schedule | quote }}
timeZone: {{ .Values.cronjob.timeZone | quote }}
failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }} # K8s default is 1, , Chart default is 1
successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }} # K8s default is 3, Chart default is 0
{{- if .Values.cronjob.concurrencyPolicy }} # K8s default is Allow
concurrencyPolicy: {{ .Values.cronjob.concurrencyPolicy }}
{{- end }}
{{- if .Values.suspend }} # K8s default il false
suspend: {{ .Values.suspend }}
Expand All @@ -33,25 +33,29 @@ spec:
labels:
{{- include "interop-eks-cronjob-chart.labels" . | nindent 8 }}
annotations:
digest: "{{ .Values.image.digest }}" # Used to force deployment on same image version but different content
digest: "{{ .Values.cronjob.image.digest }}" # Used to force deployment on same image version but different content
spec:
activeDeadlineSeconds: {{ .Values.activeDeadlineSeconds }} # Chart default 3600
activeDeadlineSeconds: {{ .Values.cronjob.activeDeadlineSeconds }} # Chart default 3600
template:
metadata:
labels:
{{- include "interop-eks-cronjob-chart.labels" . | nindent 12 }}
spec:
restartPolicy: {{ .Values.restartPolicy }}
restartPolicy: {{ .Values.cronjob.restartPolicy }}
serviceAccountName: {{ .Values.name | quote }}
containers:
- name: {{ .Values.name | quote }}
image: "{{ .Values.image.repositoryPrefix }}/{{ .Values.image.repositoryName | default .Values.name }}{{ $imageTag }}{{ $digestSuffix }}"
imagePullPolicy: {{ .Values.image.imagePullPolicy }}
{{- if and .Values.job .Values.job.command }}
command: {{ .Values.job.command }}
image: "{{ .Values.cronjob.image.repositoryPrefix }}/{{ .Values.cronjob.image.repositoryName | default .Values.name }}{{ $imageTag }}{{ $digestSuffix }}"
imagePullPolicy: {{ .Values.cronjob.image.imagePullPolicy }}
{{- if and .Values.cronjob .Values.cronjob.command }}
command: {{ .Values.cronjob.command }}
{{- end }}
{{- if and .Values.job .Values.job.args }}
args: {{ .Values.job.args }}
{{- if and .Values.cronjob .Values.cronjob.args }}
args: {{ .Values.cronjob.args }}
{{- end }}
{{- if .Values.cronjob.securityContext }}
securityContext:
{{- toYaml .Values.cronjob.securityContext | nindent 12 }}
{{- end }}
env:
{{- if .Values.configmap }}
Expand All @@ -63,23 +67,23 @@ spec:
key: {{ $key | quote }}
{{- end }}
{{- end }}
{{- if and .Values.job .Values.job.envFromFieldRef }}
{{- range $key, $val := .Values.job.envFromFieldRef }}
{{- if and .Values.cronjob .Values.cronjob.envFromFieldRef }}
{{- range $key, $val := .Values.cronjob.envFromFieldRef }}
- name: {{ $key | quote }}
valueFrom:
fieldRef:
fieldPath: {{ $val | quote }}
{{- end }}
{{- end }}
{{- if and .Values.job .Values.job.env }}
{{- range $key, $val := .Values.job.env }}
{{- if and .Values.cronjob .Values.cronjob.env }}
{{- range $key, $val := .Values.cronjob.env }}
{{- $preprocessedEnvValue := include "interop-eks-cronjob-chart.render-template" (dict "value" $val "context" $) }}
- name: {{ $key | quote }}
value: {{ $preprocessedEnvValue | quote }}
{{- end }}
{{- end }}
{{- if and .Values.job .Values.job.envFromConfigmaps }}
{{- range $key, $val := .Values.job.envFromConfigmaps -}}
{{- if and .Values.cronjob .Values.cronjob.envFromConfigmaps }}
{{- range $key, $val := .Values.cronjob.envFromConfigmaps -}}
{{ $configmapAddress := mustRegexSplit "\\." $val 2 }}
- name: {{ $key | quote }}
valueFrom:
Expand All @@ -88,8 +92,8 @@ spec:
key: {{ index $configmapAddress 1 | quote }}
{{- end }}
{{- end }}
{{- if and .Values.job .Values.job.envFromSecrets }}
{{- range $key, $val := .Values.job.envFromSecrets -}}
{{- if and .Values.cronjob .Values.cronjob.envFromSecrets }}
{{- range $key, $val := .Values.cronjob.envFromSecrets -}}
{{ $secretAddress := mustRegexSplit "\\." $val 2 }}
- name: {{ $key | quote }}
valueFrom:
Expand All @@ -99,12 +103,12 @@ spec:
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 16 }}
{{- if and .Values.job .Values.job.volumeMounts }}
{{- toYaml .Values.cronjob.resources | nindent 16 }}
{{- if and .Values.cronjob .Values.cronjob.volumeMounts }}
volumeMounts:
{{- toYaml .Values.job.volumeMounts | nindent 16 }}
{{- toYaml .Values.cronjob.volumeMounts | nindent 16 }}
{{- end }}
{{- if and .Values.job .Values.job.volumes }}
{{- if and .Values.cronjob .Values.cronjob.volumes }}
volumes:
{{- toYaml .Values.job.volumes | nindent 12 }}
{{- toYaml .Values.cronjob.volumes | nindent 12 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ metadata:
labels:
{{- include "interop-eks-cronjob-chart.labels" . | nindent 4 }}
annotations:
eks.amazonaws.com/role-arn: {{ .Values.roleArn | quote }}
eks.amazonaws.com/role-arn: {{ .Values.serviceAccount.roleArn | quote }}
6 changes: 0 additions & 6 deletions charts/interop-eks-cronjob-chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
},
"type": "object"
},
"techStack": {
"description": "Technology used to develop the service",
"type": "string",
"enum": [ "nodejs" ]
},
"name": {
"description": "Service name",
"type": "string"
Expand All @@ -67,7 +62,6 @@
"name",
"namespace",
"resources",
"techStack",
"schedule"
],
"title": "Values",
Expand Down
Loading
Loading