Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a finalizer to make sure web hooks are removed when operator is uninstalled #1092

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 18 additions & 40 deletions operator/roles/forkliftcontroller/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,46 +142,10 @@
state: present
definition: "{{ lookup('template', 'api/deployment-forklift-api.yml.j2') }}"

- name: "Delete aggregated validation webhook configurations"
k8s:
state: absent
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-forklift-api.yml.j2') }}"

- name: "Setup secrets validating webhook configuration"
k8s:
state: present
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-secrets.yml.j2') }}"

- name: "Setup plans validating webhook configuration"
k8s:
state: present
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-plans.yml.j2') }}"

- name: "Setup providers validating webhook configuration"
k8s:
state: present
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-providers.yml.j2') }}"

- name: "Delete aggregated mutating webhook configurations"
k8s:
state: absent
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-forklift-api.yml.j2') }}"

- name: "Setup secrets mutating webhook configuration"
k8s:
state: present
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-secrets.yml.j2') }}"

- name: "Setup plans mutating webhook configuration"
k8s:
state: present
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-plans.yml.j2') }}"


- name: "Setup providers mutating webhook configuration"
k8s:
state: present
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-providers.yml.j2') }}"
- name: "Setup webhook configuration"
include_tasks: webhooks.yml
vars:
webhook_state: "present"

- name: "Setup default provider"
k8s:
Expand Down Expand Up @@ -276,3 +240,17 @@
namespace: "{{ app_namespace }}"
name: forklift-must-gather-api
state: absent
when: finalize is not defined

- block:
- name: "Remove webhook configuration"
jonner marked this conversation as resolved.
Show resolved Hide resolved
include_tasks: webhooks.yml
vars:
webhook_state: "absent"

- name: "Remove console plugin"
k8s:
state: absent
definition: "{{ lookup('template', 'ui-plugin/console-plugin.yml.j2') }}"

when: finalize is defined
42 changes: 42 additions & 0 deletions operator/roles/forkliftcontroller/tasks/webhooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
- block:
- name: "Delete aggregated validation webhook configurations"
k8s:
state: absent
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-forklift-api.yml.j2') }}"

- name: "Setup secrets validating webhook configuration"
k8s:
state: "{{ webhook_state }}"
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-secrets.yml.j2') }}"

- name: "Setup plans validating webhook configuration"
k8s:
state: "{{ webhook_state }}"
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-plans.yml.j2') }}"

- name: "Setup providers validating webhook configuration"
k8s:
state: "{{ webhook_state }}"
definition: "{{ lookup('template', 'api/validatingwebhookconfiguration-providers.yml.j2') }}"

- name: "Delete aggregated mutating webhook configurations"
k8s:
state: absent
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-forklift-api.yml.j2') }}"

- name: "Setup secrets mutating webhook configuration"
k8s:
state: "{{ webhook_state }}"
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-secrets.yml.j2') }}"

- name: "Setup plans mutating webhook configuration"
k8s:
state: "{{ webhook_state }}"
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-plans.yml.j2') }}"

- name: "Setup providers mutating webhook configuration"
k8s:
state: "{{ webhook_state }}"
definition: "{{ lookup('template', 'api/mutatingwebhookconfiguration-providers.yml.j2') }}"

4 changes: 4 additions & 0 deletions operator/watches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
kind: ForkliftController
role: forkliftcontroller
#+kubebuilder:scaffold:watch
finalizer:
name: forklift.konveyor.io/finalizer
vars:
finalize: true
Loading