<p>I am using ansible k8s module to do the pod deployment, but unfortunately, I did not find a way to use <code>wait</code> and <code>wait_condition</code> correctly.</p>
<p>so I tried use the <code>until</code> and <code>retry</code> to implement another waiting</p>
<p>each time after you run the playbook, after you use k8s module to do the deployment, until NewReplicaSetAvailable shows up in the deployment within 2 minutes(60 * 2s), otherwise the deployment failed.</p>
<p>In case you need to verify the deployment result, I write down here.</p>
<pre><code>    - name: Verify the deploy result
      shell: &quot;kubectl -n kube-system get deployment coredns --output=jsonpath='{.status.conditions[*].reason}'&quot;
      register: deploy_res
      until: &quot;'NewReplicaSetAvailable' in deploy_res.stdout&quot;
      retries: 60
      delay: 2
</code></pre>

Z.Liu
<p>the module <code>k8s</code> gives you not the status of the Deployment. For the status of a Deployment (or any other resource) you should use the module <code>k8s_info</code>. Then you can do your check on this task.</p>
<p>Example:</p>
<pre><code>---
- hosts: localhost
  tasks:
  - name: Create a Service object from an inline definition
    k8s:
      state: present
      definition:
        apiVersion: v1
        kind: Deployment
        metadata:
          name: example
          namespace: default
        spec:
          replicas: 3
          selector:
            matchLabels:
              app: example-nginx
          template:
            metadata:
              labels:
                app: example-nginx
            spec:
              containers:
              - image: nginx
                name: nginx
  - name: check if deployment is ready
    k8s_info:
      kind: Deployment
      label_selectors: 
        - app = example-nginx
    register: output_info
    until: output_info.resources | json_query('[*].status.conditions[?reason==`NewReplicaSetAvailable`][].status') | select ('match','True') | list | length == 1
    delay: 2
    retries: 5
</code></pre>
<p>For the <code>until</code> filter there are certainly better solutions, but I have solved it this way for a similar use case. The <code>until</code> filter checks if there is a condition with the reason <code>NewReplicaSetAvailable</code> and it must be <code>True</code>. If that happens, the length is equal to <code>1</code></p>
