2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Clusters
|
|
|
|
module Cleanup
|
2021-09-04 01:27:46 +05:30
|
|
|
class ServiceAccountService < ::Clusters::Cleanup::BaseService
|
2020-01-01 13:55:28 +05:30
|
|
|
def execute
|
|
|
|
delete_gitlab_service_account
|
|
|
|
|
|
|
|
log_event(:destroying_cluster)
|
|
|
|
|
|
|
|
cluster.destroy!
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def delete_gitlab_service_account
|
|
|
|
log_event(:deleting_gitlab_service_account)
|
|
|
|
|
|
|
|
cluster.kubeclient.delete_service_account(
|
|
|
|
::Clusters::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAME,
|
|
|
|
::Clusters::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAMESPACE
|
|
|
|
)
|
|
|
|
rescue Kubeclient::ResourceNotFoundError
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|