Class: Kubecontrol::Resources::Deployment

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

Constant Summary collapse

RESOURCE_NAME =
'deployments'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, ready, up_to_date, available, age, namespace, client) ⇒ Deployment

Returns a new instance of Deployment.



8
9
10
11
12
13
14
15
16
# File 'lib/kubecontrol/resources/deployment.rb', line 8

def initialize(name, ready, up_to_date, available, age, namespace, client)
  @name = name
  @ready = ready
  @up_to_date = up_to_date
  @available = available
  @age = age
  @namespace = namespace
  @client = client
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def age
  @age
end

#availableObject (readonly)

Returns the value of attribute available.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def available
  @available
end

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def client
  @client
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def namespace
  @namespace
end

#readyObject (readonly)

Returns the value of attribute ready.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def ready
  @ready
end

#up_to_dateObject (readonly)

Returns the value of attribute up_to_date.



6
7
8
# File 'lib/kubecontrol/resources/deployment.rb', line 6

def up_to_date
  @up_to_date
end

Instance Method Details

#all_ready?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/kubecontrol/resources/deployment.rb', line 22

def all_ready?
  max_pods = @ready.split('/').last
  @ready == "#{max_pods}/#{max_pods}"
end

#available?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/kubecontrol/resources/deployment.rb', line 27

def available?
  @available.to_i > 1
end

#ready?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/kubecontrol/resources/deployment.rb', line 18

def ready?
  @ready.split('/').first != '0'
end

#scale(count) ⇒ Object



35
36
37
# File 'lib/kubecontrol/resources/deployment.rb', line 35

def scale(count)
  @client.kubectl_command("scale deployment #{@name} --replicas=#{count}")
end

#up_to_date?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/kubecontrol/resources/deployment.rb', line 31

def up_to_date?
  @up_to_date.to_i > 1
end