Devops's Blog

CronJob в k8s

Будем запускать php скрипт каждый час , подсталяем свой nfs и образ

					    
---
apiVersion: batch/v1
kind: CronJob
metadata:
    name: form-checks-auto-cronjob
    namespace: wsp-form
spec:
  schedule: "0 */1 * * *"
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      backoffLimit: 0
      completions: 1
      template:
        metadata:
          labels:
            app: form-checks-auto-cronjob
        spec:
          restartPolicy: Never
          containers:
          - name: form-checks-auto-cronjob
            image: "wsp_form:php_7.3v4"
            imagePullPolicy: IfNotPresent
            command:
              - "php"
            args:
              - "/opt/web/cron/form_checks_auto.php"
            volumeMounts:
            - mountPath: /opt/web
              name: nfs-php
            resources:
              limits:
                cpu: 1024m
                memory: 2048Mi
              requests:
                cpu: 512m
                memory: 512Mi
          volumes:
          - name: nfs-php
            persistentVolumeClaim:
              claimName: nfs-php