You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Creating workloads
Creating CronJobs
Copy page
Download PDF
Creating CronJobs
A CronJob is a one-off task that runs at a specified time or a task that runs periodically. It corresponds to the CronJob in Kubernetes. You can create a CronJob in a cluster by using an image.​
Prerequisites​
A container image has been created. You can directly use an image from a third-party container registry, or upload an image to the Container Registry (CR) service. To upload an image to CR, see Pushing and pulling images.​
Creating DaemonSets on the console​
  1. Log in to the VKE console.​
  1. In the left navigation bar, click Cluster.​
  1. Click Workload > CronJob in the left navigation bar. On the page that appears, click Create CronJob.​
  1. Configure CronJob information. For parameter details, see Workload configurations.​
  1. Click Confirm in the lower-right corner of the page.​
Creating CronJobs by using kubectl​
tip​
Before you start creating a CronJob by using kubectl, make sure that the following conditions are met:​
  1. Create the YAML file of the workload. The code of the cronjob-demo.yaml sample file is as follows:​
  • ​
    apiVersion: batch/v1beta1​
    kind: CronJob​
    metadata:​
    name: cronjob-demo # The CronJob name.​
    namespace: default # The namespace to which the CronJob belongs.​
    spec:​
    schedule: "*/1 * * * *" # The execution time of the CronJob.​
    jobTemplate:​
    spec:​
    template:​
    spec:​
    containers:​
    - name: hello # The name of the container in the CronJob.​
    image: busybox # The container image.​
    command: # The command executed in the container.​
    - /bin/sh​
    - -c​
    - date; echo Hello from the Kubernetes cluster​
    resources:​
    requests: # Specify CPU and memory requests for the container.​
    cpu: "500m" ​
    memory: "1024Mi"​
    limits: # The resource quotas, such as the CPU limit, memory limit, and number of RDMA cards.​
    cpu: "1" ​
    memory: "2Gi"​
    vke.volcengine.com/rdma: 2​
    restartPolicy: OnFailure # The restart policy when the Job fails in the container. Valid values: Never and OnFailure.​
    ​
  1. Run the following command to create the workload.​
  • ​
    kubectl apply -f cronjob-demo.yaml​
    ​
Operation result​
After you create the CronJob, you can view the status of the workload on the Workload > CronJob page. You can click the button in the Actions column to manage the created CronJob. For more operations, see Managing workloads.​
​
Last updated: 2026.10.23 10:41:06