2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Kubernetes
|
|
|
|
module Helm
|
2020-06-23 00:09:42 +05:30
|
|
|
class ResetCommand < BaseCommand
|
2019-10-12 21:52:04 +05:30
|
|
|
include ClientCommand
|
|
|
|
|
|
|
|
def generate_script
|
|
|
|
super + [
|
|
|
|
reset_helm_command,
|
2019-12-21 20:55:43 +05:30
|
|
|
delete_tiller_replicaset,
|
|
|
|
delete_tiller_clusterrolebinding
|
2019-10-12 21:52:04 +05:30
|
|
|
].join("\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
def pod_name
|
|
|
|
"uninstall-#{name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# This method can be delete once we upgrade Helm to > 12.13.0
|
2019-12-04 20:38:33 +05:30
|
|
|
# https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/27096#note_159695900
|
2019-10-12 21:52:04 +05:30
|
|
|
#
|
|
|
|
# Tracking this method to be removed here:
|
2019-12-04 20:38:33 +05:30
|
|
|
# https://gitlab.com/gitlab-org/gitlab-foss/issues/52791#note_199374155
|
2019-10-12 21:52:04 +05:30
|
|
|
def delete_tiller_replicaset
|
|
|
|
delete_args = %w[replicaset -n gitlab-managed-apps -l name=tiller]
|
|
|
|
|
|
|
|
Gitlab::Kubernetes::KubectlCmd.delete(*delete_args)
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def delete_tiller_clusterrolebinding
|
|
|
|
delete_args = %w[clusterrolebinding tiller-admin]
|
|
|
|
|
|
|
|
Gitlab::Kubernetes::KubectlCmd.delete(*delete_args)
|
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
def reset_helm_command
|
|
|
|
command = %w[helm reset] + optional_tls_flags
|
|
|
|
|
|
|
|
command.shelljoin
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|