diff --git a/charts/interop-eks-cronjob-chart/README.md b/charts/interop-eks-cronjob-chart/README.md index 997cb53..ee302e2 100644 --- a/charts/interop-eks-cronjob-chart/README.md +++ b/charts/interop-eks-cronjob-chart/README.md @@ -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 @@ -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 diff --git a/charts/interop-eks-cronjob-chart/templates/_helpers.tpl b/charts/interop-eks-cronjob-chart/templates/_helpers.tpl index a04b716..e525fc3 100644 --- a/charts/interop-eks-cronjob-chart/templates/_helpers.tpl +++ b/charts/interop-eks-cronjob-chart/templates/_helpers.tpl @@ -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 }} @@ -120,4 +120,4 @@ Usage: {{- else }} {{- $value -}} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/interop-eks-cronjob-chart/templates/cronjob.yaml b/charts/interop-eks-cronjob-chart/templates/cronjob.yaml index 94276d0..fd7c3a4 100644 --- a/charts/interop-eks-cronjob-chart/templates/cronjob.yaml +++ b/charts/interop-eks-cronjob-chart/templates/cronjob.yaml @@ -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 @@ -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 }} @@ -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 }} @@ -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: @@ -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: @@ -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 }} diff --git a/charts/interop-eks-cronjob-chart/templates/serviceaccount.yaml b/charts/interop-eks-cronjob-chart/templates/serviceaccount.yaml index 2b76018..d0d3a4f 100644 --- a/charts/interop-eks-cronjob-chart/templates/serviceaccount.yaml +++ b/charts/interop-eks-cronjob-chart/templates/serviceaccount.yaml @@ -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 }} diff --git a/charts/interop-eks-cronjob-chart/values.schema.json b/charts/interop-eks-cronjob-chart/values.schema.json index 5e70da2..479e2a2 100644 --- a/charts/interop-eks-cronjob-chart/values.schema.json +++ b/charts/interop-eks-cronjob-chart/values.schema.json @@ -45,11 +45,6 @@ }, "type": "object" }, - "techStack": { - "description": "Technology used to develop the service", - "type": "string", - "enum": [ "nodejs" ] - }, "name": { "description": "Service name", "type": "string" @@ -67,7 +62,6 @@ "name", "namespace", "resources", - "techStack", "schedule" ], "title": "Values", diff --git a/charts/interop-eks-cronjob-chart/values.yaml b/charts/interop-eks-cronjob-chart/values.yaml index 4d8bbf1..3a99838 100644 --- a/charts/interop-eks-cronjob-chart/values.yaml +++ b/charts/interop-eks-cronjob-chart/values.yaml @@ -4,47 +4,48 @@ name: # -- Namespace hosting the service that will be deployed on K8s cluster namespace: -# -- (int) Number of desired replicas for the service being deployed -# @default -- 1 -replicas: -# -- (string) ServiceAccount roleARN used for eks.amazonaws.com/role-arn annotation -roleArn: -# -- (enum) Defines the technology used to develop the container. The following values are allowed: [ "nodejs" ] -techStack: -# -- [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. -# @default -- 1 -failedJobsHistoryLimit: 1 -# -- [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 -# @default -- 0 -successfulJobsHistoryLimit: 0 -# -- (boolean) [suspend](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-suspension) field allows to suspend execution of Jobs for a CronJob. -# @default -- false. -suspend: false -# -- (int) 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. -# @default -- 3600 -activeDeadlineSeconds: 3600 -# -- (string) 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. -schedule: - -# -- (string) [Time zone](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones) to use when calculating schedule -timeZone: - -# -- (string) [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. -# @default -- Allow -concurrencyPolicy: -restartPolicy: OnFailure - -image: - imagePullPolicy: Always - # -- (string) Image repository - repositoryPrefix: - # -- (string) Image tag - tag: - # -- (string) Image digest - digest: - -job: +serviceAccount: + # -- (string) ServiceAccount roleARN used for eks.amazonaws.com/role-arn annotation + roleArn: + +cronjob: + image: + imagePullPolicy: Always + # -- (string) Image repository + repositoryPrefix: + # -- (string) Image tag + tag: + # -- (string) Image digest + digest: + # -- K8s container resources requests and limits + resources: + requests: + cpu: + memory: + limits: + cpu: + memory: + # -- [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. + # @default -- 1 + failedJobsHistoryLimit: 1 + # -- [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 + # @default -- 0 + successfulJobsHistoryLimit: 0 + # -- (boolean) [suspend](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#schedule-suspension) field allows to suspend execution of Jobs for a CronJob. + # @default -- false. + suspend: false + # -- (int) 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. + # @default -- 3600 + activeDeadlineSeconds: 3600 + # -- (string) [Time zone](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones) to use when calculating schedule + timeZone: + # -- (string) 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. + schedule: + # -- (string) [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. + # @default -- Allow + concurrencyPolicy: + restartPolicy: OnFailure # -- (object) List of environment variables for a container, specifying a value directly for each named variable env: # -- (object) List of environment variables for a container, specifying a key from a Configmap for each named variable (k8s equivalent of envFrom.configMapRef) @@ -53,13 +54,3 @@ job: envFromSecrets: # -- (object) 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) envFromFieldRef: - -# -- K8s container resources requests and limits -resources: - requests: - cpu: - memory: - limits: - cpu: - memory: -