Bootstrap FreeKB - OpenShift - Delete Pods using Ansible
OpenShift - Delete Pods using Ansible

Updated:   |  OpenShift articles

This assumes you are already familiar with logging in and logging out of OpenShift using Ansible. If not, check out my article FreeKB - OpenShift - Log into OpenShift using Ansible community.okd.openshift_auth.

Here is an example of how to delete the pod named my_pod in the project/namespace my_project using Ansible kubernetes.core.k8s.

---
- hosts: localhost
  module_defaults:
    group/community.okd.okd:
      host: https://api.lab001.op.thrivent.com:6443
      validate_certs: False
  tasks:
  - block:

    - name: login
      community.okd.openshift_auth:
        username: john.doe
        password: itsasecret
      register: openshift_auth_results

    - name: delete the pod named 'my_pod' in project/namespace my_project
      kubernetes.core.k8s:
        kind: Pod
        namespace: my_project
        name: my_pod
        state: absent

    always:

    - name: logout
      community.okd.openshift_auth:
        state: absent
        api_key: "{{ openshift_auth_results.openshift_auth.api_key }}"
...

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a875b1 in the box below so that we can be sure you are a human.