- name: Delete the POD
k8s:
api_version: v1
kind: Pod
namespace: "{{ k8s_namespace }}"
name: "{{ pod_name }}"
state: absent
另一种方法是重新定义“failure”以检查预期的结果字符串。
- name: Verify whether the POD is deleted
command: "{{ local_kubectl }} get pod {{ pod_name}}"
register: verify
failed_when: "'NotFound' not in verify.stderr"
- name: Delete pod
kubernetes.core.k8s:
state: absent
kind: Pod
name: "{{pod_name}}"
namespace: "{{test_ns}}"
kubeconfig: "{{ config }}"
wait: true
wait_condition:
status: False #wait for status to be false
wait_sleep: 2 #check every 2 secs
3条答案
按热度按时间5m1hhzi41#
您可以使用k8s模块直接指定此参数
另一种方法是重新定义“failure”以检查预期的结果字符串。
z0qdvdin2#
尝试k8s_facts
(not测试)
q5lcpyga3#
迟来的答复。希望对某人有帮助。https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html