gcloud scheduler create jobs when already exist - gcloud

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

Related

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

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.

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.

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.

AWS ecs scheduled task with cloudwatch

I am trying to create scheduled task with cloudwatch.
I am using this page
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html
The problem i see is when i run task normally then aws asks
vpc
subnets
Launchtype
BUT when i use cloudwatch target then it dont ask for vpc, subnets etc. why is that ?
CloudFormation has not been updated to accommodate some Fargate functionality yet. If you get an error while trying to deploy an ECS task from CloudFormation,
try using the command line interface (aws events put-target) instead, which allows you to add a target that contains the required ECS parameters for launch type and network config.
Here is an example of how I configured my ECS tasks to be deployed from the CLI instead of CloudFormation:
1. Add vpc/subnet config to a variable, NETWORK_CONFIGURATION:
NETWORK_CONFIGURATION='{"awsvpcConfiguration":{"AssignPublicIp":"ENABLED","SecurityGroups": \["'${AWS_NETWORKCONFIG_SECURITY_GROUP}'"],"Subnets":["'${AWS_NETWORKCONFIG_SUBNET}'"]}}'
Run the following command to deploy your task, which will take the vpc config from the variable declared above
aws events put-targets \
--rule events-rule--${TASK_NAME} \
--targets '{"Arn":"arn:aws:ecs:'${AWS_REGION}':'${AWS_ACCOUNT_ID}':cluster/ecs-cluster-1","EcsParameters":{"LaunchType":"FARGATE","NetworkConfiguration":'${NETWORK_CONFIGURATION}',"TaskCount": 1,"TaskDefinitionArn": "arn:aws:ecs:'${AWS_REGION}':'${AWS_ACCOUNT_ID}':task-definition/ecs-task-'${TASK_NAME}'"},"Id": "ecs-targets-'${TASK_NAME}'","RoleArn": "arn:aws:iam::'${AWS_ACCOUNT_ID}':role/ecsEventsRole"}' \
;