everspader
everspader

Reputation: 1710

How to start/trigger a job when a new version of deployment is released (image updated) on Kubernetes?

I have two environments (clusters): Production and Staging with two independent databases. They are both deployed on Kubernetes and production doesn't have a fixed schedule for new deployments but it happens on a weekly basis (roughly).

I would like to sync the production database with the staging database every time that a new release is deployed to production (kubernetes deployment is updated with new image).

Is there a way that I can set a job/cronjob to be triggered everytime this even happen?

The deployments are done using ArgoCD to pull the changes in the deployment manifest from a github repository.

Upvotes: 0

Views: 3652

Answers (3)

Gyorgy Nadaban
Gyorgy Nadaban

Reputation: 35

This is exactly the case what Argo Events is for.

https://argoproj.github.io/argo-events/

There are many ways to implement this, but it depends on your exact situation how it’s best for you.

Eg. if you can use a Git tag event’s webhook you could go with an HTTP trigger to initiate a Job or Argo Workflow.

Upvotes: 0

SeB
SeB

Reputation: 21

I think you can also use a tool like Kyverno and write a policy to generate a K8s job upon any resource created in K8s.

Upvotes: 0

pkaramol
pkaramol

Reputation: 19402

I don't think this functionality is inherent to kubernetes; you are asking about something custom that can be implemented in a variety of ways (depending on your tool stack)

e.g.

if you are using helm to install to Production, you can use a post-install hook that triggers a Job that does what you want.

Perhaps ArgoCD has some post-install functionality that can also create a Job resource doing what you want.

Upvotes: 1

Related Questions