Class: Kubert::Deployment

Inherits:
Object
  • Object
show all
Defined in:
lib/kubert/deployment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(options, project_name= Kubert.configuration[:project_name])
  @project_name = project_name
  @deployments = []
  @options = options
end

Instance Attribute Details

#deploymentsObject (readonly)

Returns the value of attribute deployments.



11
12
13
# File 'lib/kubert/deployment.rb', line 11

def deployments
  @deployments
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/kubert/deployment.rb', line 11

def options
  @options
end

#project_nameObject (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(options)
  new(options).perform
end

.rollback(options) ⇒ Object



7
8
9
# File 'lib/kubert/deployment.rb', line 7

def self.rollback(options)
  new(options).rollback
end

Instance Method Details

#compilationObject



34
35
36
# File 'lib/kubert/deployment.rb', line 34

def compilation
  @compilation ||= KY::API.compile(options[:configmap_path], options[:secrets_path], options[:output_dir], options_with_defaults)
end

#performObject



26
27
28
29
30
31
32
# File 'lib/kubert/deployment.rb', line 26

def perform
  confirm "deploy" do
    compilation.deploy_generation.to_h.each do |deployment_file, _template_hash|
      `kubectl apply -f #{deployment_file}` unless excluded?(deployment_file)
    end
  end
end

#rollbackObject



18
19
20
21
22
23
24
# File 'lib/kubert/deployment.rb', line 18

def rollback
  confirm "rollback" do
    compilation.deploy_generation.proc_commands.keys.each do |deployment_name|
      `kubectl rollout status deployment/#{deployment_name} #{namespace_flag}` unless excluded?(deployment_name)
    end
  end
end