geerlingguy / 50k-k8s-jobs

50,000 Kubernetes Jobs for 50,000 Subscribers
https://www.youtube.com/watch?v=O1iEBzY7-ok
MIT License
45 stars 5 forks source link

Add check at the end to confirm total_count jobs were created #1

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

As the title says; add a task at the end, maybe using k8s_info, that grabs the total count of jobs in the default namespace, and verifies it is equal to total_count.

geerlingguy commented 4 years ago

Even better, I can wait until all the total_count jobs are 'successful':

    - name: Wait until there are {{ total_count }} completed jobs.
      community.kubernetes.k8s_info:
        api_version: batch/v1
        kind: Job
        namespace: default
        field_selectors:
          - status.successful=1
      register: job_list
      until: (job_list.resources | length) == total_count
      retries: 200
      delay: 3