Class: KubernetesDeploy::Service

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

Constant Summary collapse

TIMEOUT =
5.minutes

Constants inherited from KubernetesResource

KubernetesResource::DEBUG_RESOURCE_NOT_FOUND_MESSAGE, KubernetesResource::LOG_LINE_COUNT, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::UNUSUAL_FAILURE_MESSAGE

Instance Attribute Summary

Attributes inherited from KubernetesResource

#context, #deploy_started, #name, #namespace, #type

Instance Method Summary collapse

Methods inherited from KubernetesResource

build, #debug_message, #deploy_finished?, #deploy_method, #deploy_timed_out?, #failure_message, #fetch_events, #file_path, #id, #initialize, #kubectl, #pretty_status, #status, timeout, #timeout, #tpr?

Constructor Details

This class inherits a constructor from KubernetesDeploy::KubernetesResource

Instance Method Details

#deploy_failed?Boolean

Returns:

  • (Boolean)


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

def deploy_failed?
  false
end

#deploy_succeeded?Boolean

Returns:

  • (Boolean)


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

def deploy_succeeded?
  if exposes_zero_replica_deployment?
    @num_endpoints == 0
  else
    @num_endpoints > 0
  end
end

#exists?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/kubernetes-deploy/kubernetes_resource/service.rb', line 37

def exists?
  @found
end

#syncObject



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

def sync
  _, _err, st = kubectl.run("get", type, @name)
  @found = st.success?
  if @found
    endpoints, _err, st = kubectl.run("get", "endpoints", @name, "--output=jsonpath={.subsets[*].addresses[*].ip}")
    @num_endpoints = (st.success? ? endpoints.split.length : 0)
  else
    @num_endpoints = 0
  end
  @status = "#{@num_endpoints} endpoints"
end

#timeout_messageObject



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

def timeout_message
  <<-MSG.strip_heredoc.strip
    This service does not have any endpoints. If the related pods are failing, fixing them will solve this as well.
    If the related pods are up, this service's selector is probably incorrect.
  MSG
end