2017-12-22 12:23:43 -05:00
|
|
|
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!
|
2018-03-01 18:46:02 -05:00
|
|
|
create_config_map(command) if command.config_map?
|
|
|
|
@kubeclient.create_pod(command.pod_resource)
|
2017-12-22 12:23:43 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Returns Pod phase
|
|
|
|
#
|
|
|
|
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
|
|
|
|
#
|
|
|
|
# values: "Pending", "Running", "Succeeded", "Failed", "Unknown"
|
|
|
|
#
|
|
|
|
def installation_status(pod_name)
|
|
|
|
@kubeclient.get_pod(pod_name, @namespace.name).status.phase
|
|
|
|
end
|
|
|
|
|
|
|
|
def installation_log(pod_name)
|
|
|
|
@kubeclient.get_pod_log(pod_name, @namespace.name).body
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_installation_pod!(pod_name)
|
|
|
|
@kubeclient.delete_pod(pod_name, @namespace.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-03-01 18:46:02 -05:00
|
|
|
def create_config_map(command)
|
|
|
|
command.config_map_resource.tap do |config_map_resource|
|
|
|
|
@kubeclient.create_config_map(config_map_resource)
|
|
|
|
end
|
2017-12-22 12:23:43 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|