Skip to content

Delete kubernetes cluster association and resources

What does this MR do?

Migrated from FOSS MR gitlab-foss!32559 (closed) for single codebase purpose.

Relates to the issue: #26815 (closed)

Creates workers to delete not only the cluster association, but also namespaces, gitlab-managed-apps, service-accounts and secrets.

Change clusters destroy endpoint to allow a cleanup: true parameter to indicate that everything should be removed, not only the cluster association in the database.

Codeflow (success)

  1. Clusters::ClustersController#destroy is called with params[:cleanup] == true
  2. Clusters::DestroyService is executed and, since the above param is true, it calls cluster.start_cleanup!
  3. cluster.start_cleanup! will trigger the cleanup_status state machine transition to :cleanup_uninstalling_applications
  4. The above transition hook will start a background job to uninstall all apps: Clusters::Cleanup::AppWorker.perform_async(cluster.id)
  5. Once completed, the above worker will call cluster.continue_cleanup! which moves the state machine to :cleanup_removing_project_namespaces
  6. The above transition hook will start a backround job to delete all project namespaces: Clusters::Cleanup::ProjectNamespaceWorker
  7. Once completed, the above worker will call cluster.continue_cleanup! which moves the state machine to :cleanup_removing_service_account
  8. The above transition hook will start a backround job to delete our service account: Clusters::Cleanup::ServiceAccountWorker
  9. Finally the cluster database association is deleted

Dependent MRs (Please merge this list first)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports