0

I am running an API Platform backend which deploys using Helm. The chart for the PHP server deployment is here:

https://github.com/api-platform/api-platform/blob/main/helm/api-platform/templates/deployment.yaml

I am hoping to run a Kubernetes CronJob that creates a full instance/pod of that service so that I can run some queries and send some notification emails based off of this on a regular time-scheduled basis, using the database, mailer & template service that is part of my main PHP server setup.

All of the tutorials for CronJob in Kubernetes do not seem to reference using a Deployment, but refer to a job template. Worst case scenario is that I need to recreate the entire Deployment template as a job template (it's quite large, as you can see from above), and maintaining two versions of the same thing is impractical long term.

Completely open to the idea that I am approaching this incorrectly and there's a better appraoch.

Currently I have the example CronJob working fine:

spec:
  concurrencyPolicy: Allow
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - command:
            - echo
            - hello world
            image: bash
            imagePullPolicy: Always
            name: hello
          restartPolicy: Never
          terminationGracePeriodSeconds: 30
  schedule: '*/5 * * * *'
  successfulJobsHistoryLimit: 3
  suspend: false

but need to run a command for the server (in my case, bin/console notifications:dailydigest). I have the actual PHP server in a container on AWS in their ECR, which is what is used for our deployments. I see that we have an image listed here, but it isn't clear to me how I could use that vs. the deployment yaml file I'm using with all of the CLI variables that are pushed when we run helm upgrade --set [all the variables]

Brettins
  • 862
  • 11
  • 24
  • Would you consider using another pod which will create a deployment? Also it's not clear if you need to create a static deployment or you want to deploy it by `helm` in specific schedule? If `helm` should be used, what version do you use? – moonkotte Sep 22 '21 at 15:51
  • I'm open to any version that solves the problem and follows best practices. While I am using helm, I don't want to have to run a helm command every 24 hours or have an external machine cron job, I want this to be managed so handles it whenever someone deploys the cluster using the helm chart. I'm not sure how to tell what helm version I'm using, sorry - I have a Github Action running helm so it will pull whatever it needs to. – Brettins Sep 22 '21 at 16:41
  • So this is not enough for answer, here some ideas how you can approach it: have a cronjob with `kubectl` / `helm` image which will run your deployment. All data/manifest can be supplied to it using `configmap`. I'm not familiar how Github Action runs all this stuff so at this point I cannot suggest anything. – moonkotte Sep 29 '21 at 13:11

0 Answers0