Class: KubernetesDeploy::DaemonSet

Inherits:
PodSetBase show all
Defined in:
lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb

Constant Summary collapse

TIMEOUT =
5.minutes

Constants inherited from KubernetesResource

KubernetesResource::DEBUG_RESOURCE_NOT_FOUND_MESSAGE, KubernetesResource::DISABLED_EVENT_INFO_MESSAGE, KubernetesResource::DISABLED_LOG_INFO_MESSAGE, KubernetesResource::DISABLE_FETCHING_EVENT_INFO, KubernetesResource::DISABLE_FETCHING_LOG_INFO, KubernetesResource::GLOBAL, KubernetesResource::KUBECTL_OUTPUT_IS_SENSITIVE, KubernetesResource::LAST_APPLIED_ANNOTATION, KubernetesResource::LOG_LINE_COUNT, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::TIMEOUT_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE

Instance Attribute Summary collapse

Attributes inherited from KubernetesResource

#context, #deploy_started_at, #name, #namespace, #type

Instance Method Summary collapse

Methods inherited from PodSetBase

#failure_message, #fetch_events, #timeout_message

Methods inherited from KubernetesResource

#<=>, #after_sync, build, class_for_kind, #current_generation, #debug_message, #deploy_method, #deploy_started?, #deploy_timed_out?, #disappeared?, #exists?, #failure_message, #fetch_events, #file_path, #global?, #id, #initialize, kind, #kubectl_output_is_sensitive?, #kubectl_resource_type, #observed_generation, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #sync_debug_info, #terminating?, timeout, #timeout, #timeout_message, #timeout_override, #to_kubeclient_resource, #validate_definition, #validation_error_msg, #validation_failed?

Constructor Details

This class inherits a constructor from KubernetesDeploy::KubernetesResource

Instance Attribute Details

#podsObject (readonly)

Returns the value of attribute pods.



6
7
8
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 6

def pods
  @pods
end

Instance Method Details

#deploy_failed?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 25

def deploy_failed?
  pods.present? && pods.any?(&:deploy_failed?) &&
  observed_generation == current_generation
end

#deploy_succeeded?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 18

def deploy_succeeded?
  return false unless exists?
  rollout_data["desiredNumberScheduled"].to_i == rollout_data["updatedNumberScheduled"].to_i &&
  rollout_data["desiredNumberScheduled"].to_i == rollout_data["numberReady"].to_i &&
  current_generation == observed_generation
end

#fetch_debug_logsObject



30
31
32
33
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 30

def fetch_debug_logs
  most_useful_pod = pods.find(&:deploy_failed?) || pods.find(&:deploy_timed_out?) || pods.first
  most_useful_pod.fetch_debug_logs
end

Returns:

  • (Boolean)


35
36
37
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 35

def print_debug_logs?
  pods.present? # the kubectl command times out if no pods exist
end

#statusObject



13
14
15
16
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 13

def status
  return super unless exists?
  rollout_data.map { |state_replicas, num| "#{num} #{state_replicas}" }.join(", ")
end

#sync(cache) ⇒ Object



8
9
10
11
# File 'lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb', line 8

def sync(cache)
  super
  @pods = exists? ? find_pods(cache) : []
end