How to create an argo Workflow from a CronWorkflow, similar to how you can create a kubernetes Job from a CronJob? - argo-workflows

I can create a Job based on a CronJob like this:
kubectl create job --from=cronjob/name-of-my-cron-job name-of-the-manually-triggered-job
But how can I create a Workflow based on a CronWorkflow without using the argo cmldline program? I only have kubectl on the machine where I need to run this.

Related

gcloud scheduler create jobs when already exist

I create my gcloud scheduler in command line with
gcloud scheduler jobs create
but when I already deploy my gitlabCI, i got already exist error.
is it possible to overwrite if already exist directly in my gitlabCI ?
Suppose you create a Cloud Schedule job with the following attribute values
gcloud scheduler jobs create JOB --location=LOCATION
JOB
LOCATION
my-job
us-west1
gcloud scheduler jobs create my-job --location=us-west1
In order to verify if the job already exists you may use the gcloud schedule jobs describe JOB command using gcloud CLI .e.g https://cloud.google.com/sdk/gcloud/reference/scheduler/jobs/describe
gcloud scheduler jobs describe my-job --location=us-west1
If it indeed already exists, there is no direct way of "overwriting" the existing one, what you can do is to
either delete the previous job and re-create it from scratch e.g.
gcloud scheduler jobs delete my-job
gcloud scheduler jobs create my-job
or you can modify the existing job, for instance when you deploy a new version of a service to AppEngine, you can simply reflect this on your existing Cloud Scheduler job without the need to re-creating it entirely.
gcloud scheduler jobs update app-engine my-job --version=VERSION
For more information, please refer to the official documentation for Cloud SDK on Cloud Scheduler https://cloud.google.com/sdk/gcloud/reference/scheduler

Run kubectl command after CronJob is scheduled but before it runs

I have multiple CronJobs scheduled to run on some days. I deploy them with Helm charts, and I need to test them - therefore, I'm looking for a solution to run cronjob once right after it gets deployed with Helm.
I have already tried using Helm post-hooks to create a job from CronJob
kubectl create job --from=cronjob/mycronjobname mycronjob-run-0
but for this I have to create a separate container with kubectl docker image, which is not a good option for me. (Another time, it waited till CronJob is executed to run the Job, maybe it was my mistake of some sort)
I also tried creating a separate Job to execute this command, but Helm deploys Job and only then CronJob, so it's also not an option.
I also tried having a postStart lifecycle in the CronJob container, however it also waits for the CronJob to be executed according to it's schedule.
Is there any way to do this?

kubernetes schedule job after cron

I have Cron name "cronX" and a Job name "JobY"
how can I configure kubernetes to run "JobY" after "cronX" finished?
I know I can do it using API call from "cronX" to start "JobY" but I don't want to do that using an API call.
Is there any Kubernetes configuration to schedule this?
is it possible that this pod will contain 2 containers and one of them will run only after the second container finish?
Negative, more details here. If you only have 2 containers to run, you can place the first one under initContainers and another under containers and schedule the pod.
No built-in K8s configuration available to do workflow orchestration. You can try Argo workflow to do this.

Delete AKS deployment's running pod on regular basis (Job)

I have been struggling for some time to figure out how to accomplish the following:
I want to delete running pod on Azure Kubernetes Service cluster on scheduled basis, so that it respawns from deployment. This is required that application re-reads configuration files stored on shared storage and shared with other application.
I have found out that Kubernetes Jobs might be handy to accomplish this, but there is some but.
I cant figure how can I select corresponding pod related to my deployment as it adds random string to the deployment name, i.e
deployment-name-546fcbf44f-wckh4
Using selectors to get my pod doesnt succeed as there is not such operator like LIKE
kubectl get pods --field-selector metadata.name=deployment-name
No resources found
Looking at the official docs one way of doing this would be like so:
pods=$(kubectl get pods --selector=job-name=pi --output=jsonpath='{.items[*].metadata.name}')
echo $pods
you'd need to modify job-name to match your job name
https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#running-an-example-job

How to create a Cronjob in spinnaker

I created a cronJob using kubectl. I would like to manage this job using spinnaker but i cant find my created job in spinnaker.
I created the file running "kubectl create -f https://k8s.io/examples/application/job/cronjob.yaml"
This cronjob looks like this: https://k8s.io/examples/application/job/cronjob.yaml
There was an issue open on Github and based on recent comment on How do I deploy a CronJob? #2863
...
At this time, there is no support for showing CronJobs on the cluster screen, which is intended to focus more on "server-like" resources rather than jobs.
...
As for deploying CronJobs in Spinnaker:
... was not possible prior to Spinnaker 1.8. It has been possible to deploy cron jobs since Spinnaker 1.8
Like #Amityo mentioned you can show deployed CronJobs using kubectl get cronjob, and if you like to list jobs scheduled by this CronJob you can use kubectl get jobs.
This is really well explained in official Kubernetes Documentation Running Automated Tasks with a CronJob.