A job component runs a provided container image as a Kubernetes Job workload .
You can use this to execute one-off tasks as part of app deployments and updates.
Note
Because they run Kubernetes job workloads, job components are currently only supported by Kubernetes sandboxes.
If you have a use case for using jobs with other types of sandboxes please get in touch .
Configuring a Job component
You can configure a job component to execute commands in a container image. Using variables
you can reference other component images, and configure environment variables for the job.
Using a Published Image
You can run any published Docker image.
image_url = " bitnami/kubectl "
args = [ " get " , " pods " , " -n " , " $NAMESPACE " ]
NAMESPACE = " {{.nuon.install.id}} "
resource "nuon_job_component" "list_pods" {
app_id = nuon_app .< your - app >. id
image_url = " bitnami/kubectl "
args = [ " get " , " pods " , " -n " , " $NAMESPACE]
value = " {{.nuon.install.id}} "
Using a Custom Image
You can use a custom image by referencing either a docker
build or container image using
variables .
dockerfile = " Dockerfile "
[components.connected_repo]
directory = " components/my-job-image "
repo = " <your-org>/<your-repo> "
image_url = " {{.nuon.components.my_job_image.image.repository.uri}} "
tag = " {{.nuon.components.my_job_image.image.tag}} "
args = [ " arguments " , " to " , " pass " , " to " , " my-command " ]
value = " value-for-my-command "
resource "nuon_docker_build_component" "my_job_image" {
app_id = nuon_app .< your - app >. id
repo = " <your-org>/<your-repo> "
directory = " components/my-job-image "
resource "nuon_job_component" "job" {
app_id = nuon_app .< your - app >. id
image_url = " {{.nuon.components.my_job_image.image.repository.uri}} "
tag = " {{.nuon.components.my_job_image.image.tag}} "
args = [ " arguments " , " to " , " pass " , " to " , " my-command " ]
value = " value-for-my-command "
Use cases
Job components are designed to be an escape hatch to allow you to run any operational commands needed.
Common use cases include:
running database imports to import data for a customer install.
running database migrations.
running operational debugging commands to inspect an install.
deploying or provisioning custom resources not supported by other components.
modifying kubernetes
resources, such as adding secrets.