kuber_kit 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f98d973c015745f6a4ccf054e3b97edbd8302683f747842ad6c9c5b3e4e49087
|
4
|
+
data.tar.gz: f2e8eb96e320bc73c1c3b03c611d1990515bd55182a93f30b28966b63da0c591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d550a0a8738447c939b5f6085ef71c7b79898854ede9c6e526e07f73fd4cf6a660b5a18c4e9277f80b081dc41f21f3371aafa69099d6383c884e954b7d15d9ae
|
7
|
+
data.tar.gz: 8b8ae8685c357608a6db776443171a1ea34d387272fe72f4802164e3345c7b6bf37d558d7967e5315d8718dbcf2a6a902cad2c1e3e84bb4de0b5811b1d075574
|
data/Gemfile.lock
CHANGED
@@ -10,8 +10,10 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
10
10
|
:image_name,
|
11
11
|
:detached,
|
12
12
|
:command_name,
|
13
|
-
:
|
14
|
-
:delete_if_exists
|
13
|
+
:custom_args,
|
14
|
+
:delete_if_exists,
|
15
|
+
:volumes,
|
16
|
+
:networks,
|
15
17
|
]
|
16
18
|
|
17
19
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
@@ -24,7 +26,9 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
24
26
|
|
25
27
|
container_name = strategy_options.fetch(:container_name, service.uri)
|
26
28
|
command_name = strategy_options.fetch(:command_name, "bash")
|
27
|
-
|
29
|
+
custom_args = strategy_options.fetch(:custom_args, nil)
|
30
|
+
networks = strategy_options.fetch(:networks, [])
|
31
|
+
volumes = strategy_options.fetch(:volumes, [])
|
28
32
|
|
29
33
|
image_name = strategy_options.fetch(:image_name, nil)
|
30
34
|
if image_name.nil?
|
@@ -37,15 +41,23 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
37
41
|
docker_commands.delete_container(shell, container_name)
|
38
42
|
end
|
39
43
|
|
40
|
-
|
44
|
+
custom_args = Array(custom_args)
|
41
45
|
if container_name
|
42
|
-
|
46
|
+
custom_args << "--name #{container_name}"
|
47
|
+
end
|
48
|
+
networks.each do |network|
|
49
|
+
docker_commands.create_network(shell, network)
|
50
|
+
custom_args << "--network #{network}"
|
51
|
+
end
|
52
|
+
volumes.each do |volume|
|
53
|
+
docker_commands.create_volume(shell, volume)
|
54
|
+
custom_args << "--volume #{volume}"
|
43
55
|
end
|
44
56
|
|
45
57
|
docker_commands.run(
|
46
58
|
shell, image.remote_registry_url,
|
47
59
|
command: command_name,
|
48
|
-
args:
|
60
|
+
args: custom_args,
|
49
61
|
detached: !!strategy_options[:detached]
|
50
62
|
)
|
51
63
|
end
|
@@ -8,7 +8,7 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
8
8
|
STRATEGY_OPTIONS = [
|
9
9
|
:service_name,
|
10
10
|
:command_name,
|
11
|
-
:
|
11
|
+
:custom_args,
|
12
12
|
:detached
|
13
13
|
]
|
14
14
|
|
@@ -26,12 +26,12 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
26
26
|
|
27
27
|
service_name = strategy_options.fetch(:service_name, service.name.to_s)
|
28
28
|
command_name = strategy_options.fetch(:command_name, "bash")
|
29
|
-
|
29
|
+
custom_args = strategy_options.fetch(:custom_args, nil)
|
30
30
|
|
31
31
|
docker_compose_commands.run(shell, config_path,
|
32
32
|
service: service_name,
|
33
33
|
command: command_name,
|
34
|
-
args:
|
34
|
+
args: custom_args,
|
35
35
|
detached: !!strategy_options[:detached]
|
36
36
|
)
|
37
37
|
end
|
@@ -30,15 +30,11 @@ class KuberKit::Shell::Commands::DockerCommands
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def container_exists?(shell, container_name, status: nil)
|
33
|
-
result =
|
33
|
+
result = get_containers(shell, container_name, status: status)
|
34
34
|
result && result != ""
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
shell.exec!(%Q{docker rm -f #{container_name}})
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_container_id(shell, container_name, only_healthy: false, status: nil)
|
37
|
+
def get_containers(shell, container_name, only_healthy: false, status: nil)
|
42
38
|
command_parts = []
|
43
39
|
command_parts << "docker ps -a -q"
|
44
40
|
|
@@ -52,4 +48,48 @@ class KuberKit::Shell::Commands::DockerCommands
|
|
52
48
|
|
53
49
|
shell.exec!(command_parts.join(" "))
|
54
50
|
end
|
51
|
+
|
52
|
+
def delete_container(shell, container_name)
|
53
|
+
shell.exec!("docker rm -f #{container_name}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_network(shell, name)
|
57
|
+
unless network_exists?(shell, name)
|
58
|
+
shell.exec!("docker network create #{name}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def network_exists?(shell, network_name)
|
63
|
+
result = get_networks(shell, network_name)
|
64
|
+
result && result != ""
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_networks(shell, network_name)
|
68
|
+
command_parts = []
|
69
|
+
command_parts << "docker network ls"
|
70
|
+
command_parts << "--filter=\"name=#{network_name}\""
|
71
|
+
command_parts << "--format \"{{.Name}}\""
|
72
|
+
|
73
|
+
shell.exec!(command_parts.join(" "))
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_volume(shell, name)
|
77
|
+
unless volume_exists?(shell, name)
|
78
|
+
shell.exec!("docker volume create #{name}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def volume_exists?(shell, volume_name)
|
83
|
+
result = get_volumes(shell, volume_name)
|
84
|
+
result && result != ""
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_volumes(shell, volume_name)
|
88
|
+
command_parts = []
|
89
|
+
command_parts << "docker volume ls"
|
90
|
+
command_parts << "--filter=\"name=#{volume_name}\""
|
91
|
+
command_parts << "--format \"{{.Name}}\""
|
92
|
+
|
93
|
+
shell.exec!(command_parts.join(" "))
|
94
|
+
end
|
55
95
|
end
|
data/lib/kuber_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuber_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-01-13 00:00:00.000000000 Z
|
@@ -297,7 +297,7 @@ homepage: https://github.com/ArtStation/kuber_kit
|
|
297
297
|
licenses:
|
298
298
|
- MIT
|
299
299
|
metadata: {}
|
300
|
-
post_install_message:
|
300
|
+
post_install_message:
|
301
301
|
rdoc_options: []
|
302
302
|
require_paths:
|
303
303
|
- lib
|
@@ -312,8 +312,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
312
|
- !ruby/object:Gem::Version
|
313
313
|
version: '0'
|
314
314
|
requirements: []
|
315
|
-
rubygems_version: 3.0.
|
316
|
-
signing_key:
|
315
|
+
rubygems_version: 3.0.9
|
316
|
+
signing_key:
|
317
317
|
specification_version: 4
|
318
318
|
summary: Docker Containers Build & Deployment
|
319
319
|
test_files: []
|