Class: Krane::Service

Inherits:
KubernetesResource show all
Defined in:
lib/krane/kubernetes_resource/service.rb

Constant Summary collapse

TIMEOUT =
7.minutes
SYNC_DEPENDENCIES =
%w(Pod Deployment StatefulSet)

Constants inherited from KubernetesResource

KubernetesResource::ALLOWED_DEPLOY_METHOD_OVERRIDES, KubernetesResource::DEBUG_RESOURCE_NOT_FOUND_MESSAGE, KubernetesResource::DEPLOY_METHOD_OVERRIDE_ANNOTATION, KubernetesResource::DISABLED_EVENT_INFO_MESSAGE, KubernetesResource::DISABLED_LOG_INFO_MESSAGE, KubernetesResource::DISABLE_FETCHING_EVENT_INFO, KubernetesResource::DISABLE_FETCHING_LOG_INFO, KubernetesResource::GLOBAL, KubernetesResource::LAST_APPLIED_ANNOTATION, KubernetesResource::LOG_LINE_COUNT, KubernetesResource::SENSITIVE_TEMPLATE_CONTENT, KubernetesResource::SERVER_DRY_RUNNABLE, KubernetesResource::SERVER_DRY_RUN_DISABLED_ERROR, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::TIMEOUT_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE

Instance Attribute Summary

Attributes inherited from KubernetesResource

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

Instance Method Summary collapse

Methods inherited from KubernetesResource

#<=>, #after_sync, build, class_for_kind, #current_generation, #debug_message, #deploy_method, #deploy_method_override, #deploy_started?, #deploy_timed_out?, #disappeared?, #exists?, #failure_message, #fetch_events, #file_path, #global?, #group, #id, #initialize, kind, #kubectl_resource_type, #observed_generation, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #selected?, #sensitive_template_content?, #server_dry_run_validated?, #server_dry_runnable_resource?, #sync_debug_info, #terminating?, timeout, #timeout, #timeout_override, #to_kubeclient_resource, #use_generated_name, #uses_generate_name?, #validate_definition, #validation_error_msg, #validation_failed?, #version

Constructor Details

This class inherits a constructor from Krane::KubernetesResource

Instance Method Details

#deploy_failed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/krane/kubernetes_resource/service.rb', line 37

def deploy_failed?
  false
end

#deploy_succeeded?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/krane/kubernetes_resource/service.rb', line 29

def deploy_succeeded?
  return false unless exists?
  return published? if requires_publishing?
  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_workload? || selects_some_pods?
end

#statusObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/krane/kubernetes_resource/service.rb', line 15

def status
  if !exists?
    "Not found"
  elsif requires_publishing? && !published?
    "LoadBalancer IP address is not provisioned yet"
  elsif !requires_endpoints?
    "Doesn't require any endpoints"
  elsif selects_some_pods?
    "Selects at least 1 pod"
  else
    "Selects 0 pods"
  end
end

#sync(cache) ⇒ Object



9
10
11
12
13
# File 'lib/krane/kubernetes_resource/service.rb', line 9

def sync(cache)
  super
  @related_pods = cache.get_all(Pod.kind, selector)
  @related_workloads = fetch_related_workloads(cache)
end

#timeout_messageObject



41
42
43
44
# File 'lib/krane/kubernetes_resource/service.rb', line 41

def timeout_message
  "This service does not seem to select any pods and this is likely invalid. "\
  "Please confirm the spec.selector is correct and the targeted workload is healthy."
end