mastodon-bot as cron

This commit is contained in:
jem 2021-04-16 17:11:58 +02:00
parent 54cb0ac9e7
commit ab1621a0ec
4 changed files with 42 additions and 4 deletions

View file

@ -19,8 +19,10 @@
))
(defn generate-deployment []
(->
(yaml/from-string (yaml/load-resource "deployment.yaml"))))
(yaml/from-string (yaml/load-resource "deployment.yaml")))
(defn generate-cron []
(yaml/from-string (yaml/load-resource "cron.yaml")))
(defn-spec generate any?
[my-config string?
@ -28,4 +30,4 @@
(cs/join "\n"
[(yaml/to-string (generate-config my-config my-auth))
"---"
(yaml/to-string (generate-deployment))]))
(yaml/to-string (generate-cron))]))

View file

@ -6,11 +6,14 @@
(def config (rc/inline "config.yaml"))
(def cron (rc/inline "cron.yaml"))
(def deployment (rc/inline "deployment.yaml"))
(defn load-resource [resource-name]
(case resource-name
"config.yaml" config
"cron.yaml" cron
"deployment.yaml" deployment))
(defn from-string [input]

View file

@ -0,0 +1,34 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: mastodon-bot-cron
labels:
app.kubernetes.io/name: k8s-mastodon-bot
spec:
schedule: "* */10 * * *"
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 0
jobTemplate:
spec:
template:
spec:
volumes:
- name: config-volume
configMap:
name: mastodon-bot
containers:
- image: domaindrivenarchitecture/mastodon-bot
name: mastodon-bot
env:
- name: MASTODON_BOT_CREDENTIALS
value: /credentials.edn
volumeMounts:
- name: config-volume
mountPath: /config.edn
subPath: config.edn
readOnly: true
- name: config-volume
mountPath: /credentials.edn
subPath: credentials.edn
readOnly: true
restartPolicy: Never

View file

@ -23,7 +23,6 @@ spec:
env:
- name: MASTODON_BOT_CREDENTIALS
value: /credentials.edn
cmd:
volumeMounts:
- name: config-volume
mountPath: /config.edn