Await Kubernetes Job Completion

Action ID: kube:job:wait
NPM Package:

@devangelista/backstage-scaffolder-kubernetes

Description

Waits for a specified Kubernetes job to complete within a given namespace and timeout period.

Input Schema

PropertyTypeDescriptionRequired
tokenstringAn optional OIDC token that will be used to authenticate to the Kubernetes cluster
labelsany-
namespacestringThe namespace of the resource to wait on, e.g. default
clusterNamestringThe name of the Kubernetes cluster to use (from app-config)
timeoutSecondsnumberThe timeout in seconds to wait for the job to complete

Output Schema

No output schema defined for this action.

Usage Examples

Wait for a migration job in the default namespace

Use this to block the workflow until a Kubernetes Job with specific labels completes. This example waits up to 15 minutes for a migration job in the default namespace after fetching your template with fetch:template.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: ./skeleton

  - id: wait-migration-job
    action: kube:job:wait
    input:
      labels:
        app: billing
        job: migration
      namespace: default
      timeoutSeconds: 900

Wait for a Helm post-upgrade job on a specific cluster

Use this when a Helm release triggers a Job and you need to wait for it to finish on a target cluster. After fetch:template and publish:github, this waits for a Helm managed job in the prod namespace on the gke-prod cluster.

Copy
steps:
  - id: fetch-chart
    action: fetch:template
    input:
      url: ./helm-chart

  - id: publish-repo
    action: publish:github
    input:
      repoUrl: github.com?owner=acme&type=repository&repo=billing-service

  - id: wait-helm-job
    action: kube:job:wait
    input:
      labels:
        "app.kubernetes.io/managed-by": Helm
        "app.kubernetes.io/name": schema-migrate
        "app.kubernetes.io/instance": ${{ parameters.releaseName }}
      namespace: prod
      clusterName: gke-prod
      timeoutSeconds: 1200

Wait with an OIDC token on a restricted cluster

Use this when the cluster requires an explicit OIDC token for authentication. This waits for a seeding job in a parameterized namespace on the aks-staging cluster.

Copy
steps:
  - id: fetch-app
    action: fetch:template
    input:
      url: ./service-template

  - id: wait-seed-job
    action: kube:job:wait
    input:
      labels:
        app: reporting-api
        purpose: seed
      namespace: ${{ parameters.namespace }}
      clusterName: aks-staging
      timeoutSeconds: 600
      token: ${{ parameters.k8sOidcToken }}

Wait for a tenant specific backfill job

Use this for multi tenant systems where a backfill job runs per tenant after registration. After catalog:register, this waits for a worker job labeled for the tenant in a tenant scoped namespace.

Copy
steps:
  - id: fetch-templates
    action: fetch:template
    input:
      url: ./tenant-service

  - id: register-catalog
    action: catalog:register
    input:
      repoContentsUrl: ${{ steps['fetch-templates'].output.repoContentsUrl }}

  - id: wait-backfill
    action: kube:job:wait
    input:
      labels:
        tenant: ${{ parameters.tenantId }}
        component: worker
        operation: backfill
      namespace: tenant-${{ parameters.tenantId }}
      timeoutSeconds: 1800

Wait for a data migration job with dynamic labels

Use this when your pipeline sets labels that include environment and release identifiers. This waits for a migration job in the target environment with cluster selection and a strict timeout.

Copy
steps:
  - id: fetch
    action: fetch:template
    input:
      url: ./migration-kit

  - id: wait-data-migration
    action: kube:job:wait
    input:
      labels:
        app: data-service
        environment: ${{ parameters.env }}
        release: ${{ parameters.releaseId }}
      namespace: ${{ parameters.env }}
      clusterName: eks-dev
      timeoutSeconds: 1500