Class: KubernetesDeploy::Service

Inherits:
KubernetesResource show all
Defined in:
lib/kubernetes-deploy/kubernetes_resource/service.rb

Constant Summary collapse

TIMEOUT =
7.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::LOG_LINE_COUNT, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::TIMEOUT_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE

Instance Attribute Summary

Attributes inherited from KubernetesResource

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

Instance Method Summary collapse

Methods inherited from KubernetesResource

build, #debug_message, #deploy_method, #deploy_started?, #deploy_timed_out?, #failure_message, #fetch_events, #file_path, #id, #initialize, #kubectl, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #sync_debug_info, timeout, #timeout, #timeout_override, #validate_definition, #validation_error_msg, #validation_failed?

Constructor Details

This class inherits a constructor from KubernetesDeploy::KubernetesResource

Instance Method Details

#deploy_failed?Boolean

Returns:

  • (Boolean)


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

def deploy_failed?
  false
end

#deploy_succeeded?Boolean

Returns:

  • (Boolean)


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

def deploy_succeeded?
  return exists? unless requires_endpoints?
  # We can't use endpoints if we want the service to be able to fail fast when the pods are down
  exposes_zero_replica_deployment? || selects_some_pods?
end

#exists?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/kubernetes-deploy/kubernetes_resource/service.rb', line 39

def exists?
  @found
end

#statusObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kubernetes-deploy/kubernetes_resource/service.rb', line 13

def status
  if !requires_endpoints?
    "Doesn't require any endpoint"
  elsif @num_pods_selected.blank?
    "Failed to count related pods"
  elsif selects_some_pods?
    "Selects at least 1 pod"
  else
    "Selects 0 pods"
  end
end

#syncObject



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

def sync
  _, _err, st = kubectl.run("get", type, @name)
  @found = st.success?
  @related_deployment_replicas = fetch_related_replica_count
  @num_pods_selected = fetch_related_pod_count
end

#timeout_messageObject



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

def timeout_message
  "This service does not seem to select any pods. This means its spec.selector is probably incorrect."
end