Skip to content

Commit

Permalink
Also deploy a cronjob that syncs the motd every 4 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
haasad committed Jan 22, 2025
1 parent f52d3a6 commit 00a46c5
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
27 changes: 19 additions & 8 deletions component/motd.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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+: {
Expand Down Expand Up @@ -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 ]
Expand Down
52 changes: 52 additions & 0 deletions tests/golden/motd/openshift4-config/openshift4-config/03_motd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 00a46c5

Please sign in to comment.