Managing Kubernetes Jobs
You can use Shipa to manage Jobs using a simple definition file.
Shipa automatically creates job-related objects required by Kubernetes to run your jobs.
Shipa reduces the learning curve associated with Kubernetes adoption, simplifies the deployment process, and gives you a job context view post-deployment.
The sections below describe how you can manage your job's lifecycle on Kubernetes using Shipa.
Run Jobs
Job can be deployed in the context of a framework. See Framework Management for details about managing Framework.
# Create a team dev
shipa team create dev
# Create framework
shipa framework add framework1 --team dev
Deploy a job using a definition file.
Below is a sample job YAML file for job pi-job that executes a pi function in a container in framework
name: pi-job
type: Job
Description: “This is Pi Job”
framework: framework1
team: dev
parallelism: 1
completions: 1 # Optional, default 1. Required only with parallelism
suspend: true # Optional, default false - only available with k8s >=1.21
backOffLimit: 2 # Optional, default 6
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] # Required
policy: # Optional
restartPolicy: Never
containers:
- name: pi
image: perl:5.34
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
- name: rootdir
image: ubuntu
command: ["ls", "/"]
shipa job run pijob.yaml
Cron Job
Shipa supports running Kubernetes Cron Jobs.
name: pi-job
type: Job
Description: “This is Pi Job”
framework: framework1
team: dev
parallelism: 1
completions: 1 # Optional, default 1. Required only with parallelism
suspend: false # Optional, default false - only available with k8s >=1.21
backOffLimit: 2 # Optional, default 6
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] # Required
policy: # Optional
restartPolicy: Never
concurrencyPolicy: Allow
sechdule: "* * * * *"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
containers:
- name: pi
image: perl:5.34
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
- name: rootdir
image: ubuntu
command: ["ls", "/"]
Run cron job:
shipa job run cronjob.yaml
List Cron Job
$ shipa job list
+--------+--------------------------+-----------------------------------+---------+------------+-------------+------------------+----------------+---------------+------------------------------------+----------+
| Job | ID | Created At | Version | Framework | Description | Teams | Owner | Cluster | Status | Schedule |
+--------+--------------------------+-----------------------------------+---------+------------+-------------+------------------+----------------+---------------+------------------------------------+----------+
| pi-job | 62d0a3be8b75b700011f371d | 2022-07-14 23:16:14.926 +0000 UTC | | framework1 | | shipa-admin-team | [email protected] | shipa-cluster | 1 Running / 0 Succeeded / 0 Failed | |
+--------+--------------------------+-----------------------------------+---------+------------+-------------+------------------+----------------+---------------+------------------------------------+----------+
List Job
shipa job list
+--------+--------------------------+-----------------------------------+---------+-----------+-------------+------------------+------------------------+---------------+
| Job | ID | Created At | Version | Framework | Description | Teams | Owner | Cluster |
+--------+--------------------------+-----------------------------------+---------+-----------+-------------+------------------+------------------------+---------------+
| pi-job | 61f44f23a66d43000196c32d | 2022-01-28 20:16:35.485 +0000 UTC | | framework1| | dev | [email protected] | shipa-cluster |
+--------+--------------------------+-----------------------------------+---------+-----------+-------------+------------------+------------------------+---------------+
Job Info
shipa job info pi-job
Name: pi-job
ID: 61f44f23a66d43000196c32d
Version:
Framework: framework1
Description:
Created: 2022-01-28 20:16:35.485 +0000 UTC
Teams: dev
Owner: [email protected]
Cluster: shipa-cluster
Commands:
+---------+--------+-----------------+
| Name | Image | Commands |
+---------+--------+-----------------+
| pi | perl | perl |
| | | -Mbignum=bpi |
| | | -wle |
| | | print bpi(2000) |
+---------+--------+-----------------+
| rootdir | ubuntu | ls |
| | | / |
+---------+--------+-----------------+
Remove Job
shipa job remove JOB_NAME
Updated 9 months ago