Class: Kitchen::Driver::K8s
- Inherits:
-
Base
- Object
- Base
- Kitchen::Driver::K8s
show all
- Includes:
- KitchenK8s::Helper, ShellOut
- Defined in:
- lib/kitchen/driver/k8s.rb
Overview
Instance Method Summary
collapse
#kube_options, #kubectl_command
Instance Method Details
#create(state) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/kitchen/driver/k8s.rb', line 60
def create(state)
return if state[:pod_id]
pod_id = config[:pod_name].downcase
state[:pod_id] = pod_id
state[:namespace] = config[:namespace]
client = kubectl_client
pod = render_pod_info(pod_id)
debug("Creating pod with YAML:\n#{pod}\n")
client.create_pod(render_pod_info(pod_id))
status = nil
start_time = Time.now
while status != 'Running'
if Time.now - start_time > 20
info("Waiting for pod #{pod_id} to be running, currently #{status}")
end
sleep(1)
status = client.get_pod(pod_id, config[:namespace]).status.phase
end
platform_dependencies.each do |cmd|
run_command(kubectl_command('exec', '--tty', '--container=default', pod_id, '--', *Shellwords.split(cmd)))
end
state[:pod_id] = pod_id
end
|
48
49
50
|
# File 'lib/kitchen/driver/k8s.rb', line 48
def default_platform
instance.platform.name.split('-').first
end
|
#destroy(state) ⇒ Object
87
88
89
90
91
|
# File 'lib/kitchen/driver/k8s.rb', line 87
def destroy(state)
return unless state[:pod_id]
client = kubectl_client
client.delete_pod(state[:pod_id], config[:namespace])
end
|
#finalize_config!(instance) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
53
54
55
56
57
|
# File 'lib/kitchen/driver/k8s.rb', line 53
def finalize_config!(instance)
super.tap do
instance.transport = Kitchen::Transport::K8s.new(config)
end
end
|