Skip to content

Commit

Permalink
chore: added iot-manager CronJobs
Browse files Browse the repository at this point in the history
Hosted only feature for IoT Manager Cronjobs

Ticket: MC-7433

Signed-off-by: Roberto Giovanardi <[email protected]>
  • Loading branch information
oldgiova committed May 24, 2024
1 parent d865b93 commit 9c8f717
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,9 @@ The following table lists the parameters for the `iot-manager` component and the
| `iot_manager.probesOverrides.successThreshold` | Override the `successThreshold` for every Readiness and Liveness probes. | `nil` |
| `iot_manager.probesOverrides.timeoutSeconds` | Override the `timeoutSeconds` for every Readiness and Liveness probes. | `nil` |
| `iot_manager.probesOverrides.failureThreshold` | Override the `failureThreshold` for every Readiness and Liveness probes. | `nil` |
| `iot_manager.cronjobs.syncDevices.enabled` | Creates the Sync Devices cronjob (Hosted only) | `false` |
| `iot_manager.cronjobs.syncDevices.schedule` | Set a schedule for the Sync Devices cronjob (Hosted only) | `0 7 * * *` |
| `iot_manager.cronjobs.syncDevices.resouces` | Set the resources for the Sync Devices cronjob (Hosted only) | `nil` |

### Parameters: deviceconnect

Expand Down
1 change: 1 addition & 0 deletions mender/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 5.7.1
* Added tenantadm CronJobs (Hosted only feature)
* Added iot-manager CronJobs (Hosted only feature)

## Version 5.7.0
* `generate_delta_worker`: don't enforce tags for the image.
Expand Down
14 changes: 11 additions & 3 deletions mender/templates/iot-manager/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ spec:
restartPolicy: {{ quote . }}
{{- end }}
containers:
- name: {{ ternary "iot-manager" "iot-manager-migration" (empty .migration) | quote }}
{{- if .migration }}
- name: "iot-manager-migration"
{{- else if .cronjob }}
- name: "iot-manager-{{- .cronjob }}"
{{- else }}
- name: "iot-manager"
{{- end }}
image: {{ .dot.Values.iot_manager.image.registry }}/{{ .dot.Values.iot_manager.image.repository }}:{{ .dot.Values.iot_manager.image.tag | default .dot.Values.global.image.tag }}
imagePullPolicy: {{ .dot.Values.iot_manager.image.imagePullPolicy }}
{{- if .dot.Values.iot_manager.containerSecurityContext.enabled }}
Expand All @@ -33,7 +39,9 @@ spec:
resources: {{- nindent 6 . }}
{{- end }}

{{- if (not .migration) }}
{{- if .args }}
args: {{- toYaml .args | nindent 6 }}
{{- else if (not .migration) }}
{{- if .dot.Values.iot_manager.automigrate }}
args: ["server", "--automigrate"]
{{- else }}
Expand All @@ -44,7 +52,7 @@ spec:
{{- end }}


{{- if (not .migration) }}
{{- if and (not .migration) (not .cronjob) }}
# Readiness/liveness probes
readinessProbe:
httpGet:
Expand Down
27 changes: 27 additions & 0 deletions mender/templates/iot-manager/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if and (.Values.iot_manager.enabled) (.Values.global.hosted) (.Values.iot_manager.cronjobs.syncDevices.enabled) }}
---
# Suspend tenants: maintenance suspend-expired-tenants

{{- $context := (dict "dot" . "component" "iot-manager" "cronjob" "sync-devices" "args" (list "sync-devices" "--batch-size" "100") "extraResources" .Values.iot_manager.cronjobs.syncDevices.resources "restartPolicy" "Never") }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "mender.fullname" . }}-iot-manager-sync-devices
namespace: {{ .Release.Namespace }}
labels:
{{- include "mender.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ include "mender.fullname" . }}-iot-manager-sync-devices
app.kubernetes.io/component: iot-manager
spec:
schedule: {{ .Values.iot_manager.cronjobs.syncDevices.schedule }}
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1

jobTemplate:
spec:
template:
{{- include "mender.iotmanagerPodTemplate" $context | nindent 8 }}

{{- end }}

12 changes: 12 additions & 0 deletions mender/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,18 @@ iot_manager:
# successThreshold: 2
# failureThreshold: 6

cronjobs:
# sync devices cronjob
syncDevices:
enabled: false
schedule: "42 0 * * *"
# resources:
# limits:
# cpu: 150m
# requests:
# cpu: 150m
# memory: 64M

deviceconnect:
enabled: true
podAnnotations: {}
Expand Down

0 comments on commit 9c8f717

Please sign in to comment.