diff options
author | Amit Rathi <amit@hypertrack.io> | 2018-11-13 14:33:45 +0300 |
---|---|---|
committer | Amit Rathi <amit@hypertrack.io> | 2018-11-13 14:33:45 +0300 |
commit | 27ce6140433afa5b758272af204820599cf4fac4 (patch) | |
tree | f022371675f7fdc7eb03497ef5259962c760fd87 /app/models/clusters/applications/cert_manager.rb | |
parent | 0e8e75581b1e62502174a45742834f4000c0b335 (diff) |
Cert manager migration, cluster_issuer etc.
Diffstat (limited to 'app/models/clusters/applications/cert_manager.rb')
-rw-r--r-- | app/models/clusters/applications/cert_manager.rb | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/app/models/clusters/applications/cert_manager.rb b/app/models/clusters/applications/cert_manager.rb new file mode 100644 index 00000000000..0f6acca1fbc --- /dev/null +++ b/app/models/clusters/applications/cert_manager.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +module Clusters + module Applications + class CertManager < ActiveRecord::Base + VERSION = 'v0.5.0'.freeze + + self.table_name = 'clusters_applications_cert_managers' + + include ::Clusters::Concerns::ApplicationCore + include ::Clusters::Concerns::ApplicationStatus + include ::Clusters::Concerns::ApplicationVersion + include ::Clusters::Concerns::ApplicationData + + default_value_for :version, VERSION + + def ready_status + [:installed] + end + + def ready? + ready_status.include?(status_name) + end + + def chart + 'stable/cert-manager' + end + + def install_command + Gitlab::AppLogger.info '----- INSTALLING CLUSTER ISSUER-v2 ----' + begin + Gitlab::Kubernetes::Helm::InstallCommand.new( + name: 'certmanager', + version: VERSION, + rbac: cluster.platform_kubernetes_rbac?, + chart: chart, + files: files.merge!(cluster_issuer_file), + postinstall: post_install_script + ) + #res = YAML.load_file(Rails.root.join('config', 'cert_manager', 'cluster_issuer.yaml')) + #Gitlab::AppLogger.info(res) + #Gitlab::Kubernetes::ClusterIssuer(res).generate() + rescue StandardError => e + Gitlab::AppLogger.info('install_command_eror------------------------------------------------') + Gitlab::AppLogger.error(e) + Gitlab::AppLogger.error(e.backtrace.join("\n")) + rescue Exception => e + Gitlab::AppLogger.info('install_command_exception--------------------------------------------------') + Gitlab::AppLogger.error(e) + Gitlab::AppLogger.error(e.backtrace.join("\n")) + end + end + + def cluster_issuer_resource_definition + YAML.load_file(Rails.root.join('config', 'cert_manager', 'cluster_issuer.yaml')) + end + + private + + def post_install_script + ["/usr/bin/kubectl create -f /data/helm/certmanager/config/cluster_issuer.yaml"] + end + + def cluster_issuer_file + { + 'cluster_issuer.yaml': File.read(cluster_issuer_file_path) + } + end + + def cluster_issuer_file_path + "#{Rails.root}/vendor/cert_manager/cluster_issuer.yaml" + end + end + end + end +
\ No newline at end of file |