Class: Kubert::Deployment
- Inherits:
-
Object
- Object
- Kubert::Deployment
- Defined in:
- lib/kubert/deployment.rb
Instance Attribute Summary collapse
-
#operation_statuses ⇒ Object
readonly
Returns the value of attribute operation_statuses.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
Class Method Summary collapse
Instance Method Summary collapse
- #compilation ⇒ Object
- #handle_env_deploy ⇒ Object
-
#initialize(options, project_name = Kubert.configuration[:project_name]) ⇒ Deployment
constructor
A new instance of Deployment.
- #perform ⇒ Object
- #rollback ⇒ Object
Constructor Details
#initialize(options, project_name = Kubert.configuration[:project_name]) ⇒ Deployment
Returns a new instance of Deployment.
12 13 14 15 16 |
# File 'lib/kubert/deployment.rb', line 12 def initialize(, project_name= Kubert.configuration[:project_name]) @project_name = project_name @options = Kubert.ky_configuration() # memoize options for FileAccess usage end |
Instance Attribute Details
#operation_statuses ⇒ Object (readonly)
Returns the value of attribute operation_statuses.
11 12 13 |
# File 'lib/kubert/deployment.rb', line 11 def operation_statuses @operation_statuses end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/kubert/deployment.rb', line 11 def @options end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
11 12 13 |
# File 'lib/kubert/deployment.rb', line 11 def project_name @project_name end |
Class Method Details
.perform(options) ⇒ Object
3 4 5 |
# File 'lib/kubert/deployment.rb', line 3 def self.perform() new().perform end |
.rollback(options) ⇒ Object
7 8 9 |
# File 'lib/kubert/deployment.rb', line 7 def self.rollback() new().rollback end |
Instance Method Details
#compilation ⇒ Object
50 51 52 |
# File 'lib/kubert/deployment.rb', line 50 def compilation @compilation ||= KY::API.compile([:configmap_path], [:secrets_path], [:output_dir], ) end |
#handle_env_deploy ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kubert/deployment.rb', line 38 def handle_env_deploy config_data = FileAccess.new(:config) config_data.write_local unless config_data.local? secret_data = FileAccess.new(:secret) secret_data.write_local unless secret_data.local? perform_with_status { `kubectl apply -f #{File.(output_dir)}/#{Kubert.config_file_name} --record` } perform_with_status { `kubectl apply -f #{File.(output_dir)}/#{Kubert.secret_file_name} --record` } yield secret_data.clean_local unless secret_data.local? config_data.clean_local unless config_data.local? end |
#perform ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kubert/deployment.rb', line 27 def perform confirm :deploy do handle_env_deploy do compilation.deploy_generation.to_h.each do |deployment_file, _template_hash| perform_with_status { `kubectl apply -f #{File.(deployment_file)} --record` unless excluded?(deployment_file) } end report_status(:deploy) end end end |
#rollback ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/kubert/deployment.rb', line 18 def rollback confirm :rollback do compilation.deploy_generation.proc_commands.keys.each do |deployment_name| perform_with_status { `kubectl rollout status deployment/#{deployment_name} #{namespace_flag}` } unless excluded?(deployment_name) end report_status(:rollback) end end |