diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-08-05 13:14:32 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-08-05 13:14:32 +0300 |
commit | 5f4eb3d5e5df0c5729e51bdd0236ce96d8d62000 (patch) | |
tree | c14cf6d946334795e6a826d33accc6a1f4ed3862 /app | |
parent | 0aecf01438fcf44594211197f9a6d39227a97956 (diff) | |
parent | cfe8024e70ed45517311f1700f9e69a2f15d395e (diff) |
Merge branch '60664-kubernetes-applications-uninstall-cert-manager' into 'master'
Resolve "Kubernetes > Applications > Uninstall Cert Manager"
See merge request gitlab-org/gitlab-ce!31166
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/cert_manager.rb | 36 |
2 files changed, 31 insertions, 7 deletions
diff --git a/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue b/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue index e067eb13c54..4f60e543666 100644 --- a/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue +++ b/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue @@ -12,7 +12,7 @@ const CUSTOM_APP_WARNING_TEXT = { 'ClusterIntegration|The associated load balancer and IP will be deleted and cannot be restored.', ), [CERT_MANAGER]: s__( - 'ClusterIntegration|The associated certifcate will be deleted and cannot be restored.', + 'ClusterIntegration|The associated private key will be deleted and cannot be restored.', ), [PROMETHEUS]: s__('ClusterIntegration|All data will be deleted and cannot be restored.'), [RUNNER]: s__('ClusterIntegration|Any running pipelines will be canceled.'), diff --git a/app/models/clusters/applications/cert_manager.rb b/app/models/clusters/applications/cert_manager.rb index 7d5a6dec519..2fc1b67dfd2 100644 --- a/app/models/clusters/applications/cert_manager.rb +++ b/app/models/clusters/applications/cert_manager.rb @@ -24,12 +24,6 @@ module Clusters 'stable/cert-manager' end - # We will implement this in future MRs. - # Need to reverse postinstall step - def allowed_to_uninstall? - false - end - def install_command Gitlab::Kubernetes::Helm::InstallCommand.new( name: 'certmanager', @@ -41,12 +35,42 @@ module Clusters ) end + def uninstall_command + Gitlab::Kubernetes::Helm::DeleteCommand.new( + name: 'certmanager', + rbac: cluster.platform_kubernetes_rbac?, + files: files, + postdelete: post_delete_script + ) + end + private def post_install_script ["kubectl create -f /data/helm/certmanager/config/cluster_issuer.yaml"] end + def post_delete_script + [ + delete_private_key, + delete_crd('certificates.certmanager.k8s.io'), + delete_crd('clusterissuers.certmanager.k8s.io'), + delete_crd('issuers.certmanager.k8s.io') + ].compact + end + + def private_key_name + @private_key_name ||= cluster_issuer_content.dig('spec', 'acme', 'privateKeySecretRef', 'name') + end + + def delete_private_key + "kubectl delete secret -n #{Gitlab::Kubernetes::Helm::NAMESPACE} #{private_key_name} --ignore-not-found" if private_key_name.present? + end + + def delete_crd(definition) + "kubectl delete crd #{definition} --ignore-not-found" + end + def cluster_issuer_file { 'cluster_issuer.yaml': cluster_issuer_yaml_content |