blob: d65374cc23b150648c44a2f09d9a137e5aa2349d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
module Gitlab
module Kubernetes
module Helm
class Api
def initialize(kubeclient)
@kubeclient = kubeclient
@namespace = Gitlab::Kubernetes::Namespace.new(Gitlab::Kubernetes::Helm::NAMESPACE, kubeclient)
end
def install(command)
namespace.ensure_exists!
create_config_map(command)
kubeclient.create_pod(command.pod_resource)
end
##
# Returns Pod phase
#
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
#
# values: "Pending", "Running", "Succeeded", "Failed", "Unknown"
#
def status(pod_name)
kubeclient.get_pod(pod_name, namespace.name).status.phase
end
def log(pod_name)
kubeclient.get_pod_log(pod_name, namespace.name).body
end
def delete_pod!(pod_name)
kubeclient.delete_pod(pod_name, namespace.name)
end
private
attr_reader :kubeclient, :namespace
def create_config_map(command)
command.config_map_resource.tap do |config_map_resource|
kubeclient.create_config_map(config_map_resource)
end
end
end
end
end
end
|