Crontab ? Non, Cronjob !
Rédigé par dada / 15 février 2019 / Aucun commentaire
CronJob
Matomo et son CronJob
La configuration
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: matomo-archive
spec:
schedule: "*/30 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: matomo-cron
image: matomo:3.7
volumeMounts:
- name: pv-matomo
mountPath: /var/www/html
args:
- /bin/bash
- -c
- /usr/local/bin/php /var/www/html/console core:archive --url=https://url.de.mon.matomo/
restartPolicy: OnFailure
volumes:
- name: pv-matomo
flexVolume:
driver: ceph.rook.io/rook
fsType: ceph
options:
fsName: myfs
clusterNameSpace: rook-ceph
path: /matomo
Explications
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: matomo-archive
spec:
schedule: "*/30 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: matomo-cron
image: matomo:3.7
args:
- /bin/bash
- -c
- /usr/local/bin/php /var/www/html/console core:archive --url=https://url.de.mon.matomo/
volumes:
- name: pv-matomo
flexVolume:
driver: ceph.rook.io/rook
fsType: ceph
options:
fsName: myfs
clusterNameSpace: rook-ceph
path: /matomo
kubectl apply -f cronjob.yaml
Vérification
dada@k8smaster1:~/matomo$ k get cj
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
matomo-archive */30 * * * * False 0 21m 28d
dada@k8smaster1:~/matomo$ k get pods | grep archive
matomo-archive-1548606600-4cwsl 0/1 Completed 0 84m
matomo-archive-1548608400-7lxf8 0/1 Completed 0 54m
matomo-archive-1548610200-cwh6t 0/1 Completed 0 24m