Job components allow you to execute one time jobs in an install. Please refer to the Job Component reference for full configuration options.

Job components are currently only supported by aws-eks sandboxes.

If you have a use case for using jobs with an aws-ecs sandbox 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.

[[components]]
name = "kubectl_job"
type = "job"
image_url = "bitnami/kubectl"
tag = "latest"
cmd = ["kubectl"]
args = ["get", "pods", "-A"]
[[components.env_vars]]
name  = "NUON_APP_ID"
value = "{{.nuon.app.id}}"

Using a Custom Image

You can also use an image component.

[[components]]
name = "my_job_image"
type = "docker_build"
dockerfile = "Dockerfile"
[components.connected_repo]
directory = "my-repo/components/my-job-image"
repo = "my-repo"
branch = "master"

[[components]]
name = "my_job"
type = "job"
image_url = "{{.nuon.components.my_job_image.image.repository.uri}}"
tag = "{{.nuon.components.my_job_image.image.tag}}"
cmd = ["my-command"]
args = ["arguments", "to", "pass", "to", "my-command"]
[[components.env_vars]]
name  = "MY_ENV_VAR"
value = "value-for-my-command"

In order to use custom images with job components, you must specify either a docker build or container image as a dependency and use variables.

Configuration

You can use variables to configure both the environment and images in a job component.

Some common examples of using variables to configure job components:

// use a custom image
resource "nuon_job_component" "job" {
  name      = "job"
  app_id    = nuon_app.main.id

  image_url = "{{.nuon.components.custom_image.image.repository.uri}}"
  tag       = "{{.nuon.components.custom_image.image.tag}}"
  cmd       = ["kubectl"]
  args      = ["get", "pods", "-A"]
}

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.