Skip to content

Kubernetes Job

Bases: Deployment

🚀 The Job class is responsible for managing Kubernetes Jobs. It extends the Deployment class and provides additional functionalities specific to Kubernetes Jobs.

CLI Usage

genius job sub-command Examples:

genius job create --name example-job --image example-image --command "echo hello" --cpu "100m" --memory "256Mi" --namespace geniusrise \
    --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev

```bash
genius job delete --name example-job --namespace geniusrise \
    --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
```

```bash
genius job status --name example-job --namespace geniusrise \
    --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
```

YAML Configuration:

    version: "1.0"
    jobs:
      - name: "example-job"
        image: "example-image"
        command: "example-command"
        env_vars:
          KEY: "value"
        cpu: "100m"
        memory: "256Mi"
        storage: "1Gi"
        gpu: "1"

Extended CLI Examples:

    genius job create \
      --k8s_kind job \
      --k8s_namespace geniusrise \
      --k8s_context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev \
      --k8s_name example-job \
      --k8s_image "genius-dev.dkr.ecr.ap-south-1.amazonaws.com/geniusrise" \
      --k8s_env_vars '{"AWS_DEFAULT_REGION": "ap-south-1", "AWS_SECRET_ACCESS_KEY": "", "AWS_ACCESS_KEY_ID": ""}' \
      --k8s_cpu "100m" \
      --k8s_memory "256Mi"
    genius job delete \
      example-job \
      --namespace geniusrise \
      --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev
    genius job status \
      example-job \
      --namespace geniusrise \
      --context_name arn:aws:eks:us-east-1:genius-dev:cluster/geniusrise-dev

__init__()

🚀 Initialize the Job class for managing Kubernetes Jobs.

create(name, image, command, env_vars={}, cpu=None, memory=None, storage=None, gpu=None, image_pull_secret_name=None, **kwargs)

🛠 Create a Kubernetes Job.

Parameters:

Name Type Description Default
name str

Name of the Job.

required
image str

Docker image for the Job.

required
command str

Command to run in the container.

required
env_vars dict

Environment variables for the Job.

{}

create_parser(parser)

🎛 Create a parser for CLI commands related to Job functionalities.

Parameters:

Name Type Description Default
parser ArgumentParser

The main parser.

required

Returns:

Name Type Description
ArgumentParser ArgumentParser

The parser with subparsers for each command.

delete(name)

🗑 Delete a Kubernetes Job.

Parameters:

Name Type Description Default
name str

Name of the Job to delete.

required

run(args)

🚀 Run the Job manager.

Parameters:

Name Type Description Default
args Namespace

The parsed command line arguments.

required

status(name)

📊 Get the status of a Kubernetes Job.

Parameters:

Name Type Description Default
name str

Name of the Job.

required

Returns:

Name Type Description
dict V1Job

Status of the Job.