Managing Kubernetes Jobs
You can use Lens AppIQ to manage Jobs using a simple definition file.
Lens AppIQ automatically creates job-related objects required by Kubernetes to run your jobs.
Lens AppIQ 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 Lens AppIQ.
Run Jobs
Job can be deployed in the context of an environment.
Environment
You can deploy application to a target namespace in a cluster. To do this you should create an environment, for details see: Managing Environments
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
name: pi-job
type: Job
description: “This is Pi Job”
environment: cluster-abc-staging
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", "/"]
lapps job run pijob.yaml
Cron Job
Lens AppIQ supports running Kubernetes Cron Jobs.
name: pi-job
type: Job
description: “This is Pi Job”
environment: cluster-abc-staging
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:
lapps job run cronjob.yaml
List Cron Job
$ lapps 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
lapps 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
lapps 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
lapps job remove JOB_NAME
Updated 19 days ago