From 00a46c56a3b22dd0a0f8aadd67d01147faccaeb3 Mon Sep 17 00:00:00 2001 From: haasad Date: Wed, 22 Jan 2025 17:20:00 +0100 Subject: [PATCH] Also deploy a cronjob that syncs the motd every 4 hours --- component/motd.libsonnet | 27 +++++++--- .../openshift4-config/03_motd.yaml | 52 +++++++++++++++++++ 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/component/motd.libsonnet b/component/motd.libsonnet index 5ec0b8f..3d69ef8 100644 --- a/component/motd.libsonnet +++ b/component/motd.libsonnet @@ -60,13 +60,7 @@ local motdRBAC = cluster_role_binding: cluster_role_binding, }; -local motdSync = kube.Job('sync-motd') + namespace { - metadata+: { - annotations+: { - 'argocd.argoproj.io/hook': 'PostSync', - 'argocd.argoproj.io/hook-delete-policy': 'BeforeHookCreation', - }, - }, +local jobSpec = { spec+: { template+: { spec+: { @@ -103,14 +97,31 @@ local motdSync = kube.Job('sync-motd') + namespace { }, }; +local motdSync = kube.Job('sync-motd') + namespace + jobSpec { + metadata+: { + annotations+: { + 'argocd.argoproj.io/hook': 'PostSync', + 'argocd.argoproj.io/hook-delete-policy': 'BeforeHookCreation', + }, + }, +}; + local motdScript = kube.ConfigMap('motd-gen') + namespace { data: { 'motd_gen.sh': (importstr 'scripts/motd_gen.sh'), }, }; +local motdCronJob = kube.CronJob('motd-sync') + namespace { + spec+: { + failedJobsHistoryLimit: 3, + schedule: '27 */4 * * *', + jobTemplate+: jobSpec, + }, +}; + if params.motd.include_console_notifications then - [ motdTemplate, motdSync, motdScript ] + std.objectValues(motdRBAC) + [ motdTemplate, motdSync, motdScript, motdCronJob ] + std.objectValues(motdRBAC) else if std.length(params.motd.messages) > 0 then [ motdCM ] diff --git a/tests/golden/motd/openshift4-config/openshift4-config/03_motd.yaml b/tests/golden/motd/openshift4-config/openshift4-config/03_motd.yaml index c669e9c..33c8b09 100644 --- a/tests/golden/motd/openshift4-config/openshift4-config/03_motd.yaml +++ b/tests/golden/motd/openshift4-config/openshift4-config/03_motd.yaml @@ -84,6 +84,58 @@ metadata: name: motd-gen namespace: openshift-config --- +apiVersion: batch/v1 +kind: CronJob +metadata: + annotations: {} + labels: + name: motd-sync + name: motd-sync + namespace: openshift-config +spec: + concurrencyPolicy: Forbid + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + completions: 1 + parallelism: 1 + template: + metadata: + labels: + name: motd-sync + spec: + containers: + - args: [] + command: + - /scripts/motd_gen.sh + env: [] + image: quay.io/appuio/oc:v4.16 + imagePullPolicy: IfNotPresent + name: syn-motd + ports: [] + stdin: false + tty: false + volumeMounts: + - mountPath: /export + name: export + - mountPath: /scripts + name: scripts + workingDir: /export + imagePullSecrets: [] + initContainers: [] + restartPolicy: OnFailure + serviceAccountName: motd-manager + terminationGracePeriodSeconds: 30 + volumes: + - emptyDir: {} + name: export + - configMap: + defaultMode: 360 + name: motd-gen + name: scripts + schedule: 27 */4 * * * + successfulJobsHistoryLimit: 10 +--- apiVersion: v1 kind: ServiceAccount metadata: