swarm_cluster_cli_ope 0.6 → 0.7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +9 -9
- data/README.md +6 -3
- data/lib/swarm_cluster_cli_ope/kubernetes/pod.rb +3 -2
- data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/rsync.rb +16 -14
- data/lib/swarm_cluster_cli_ope/models/compose_container.rb +8 -1
- data/lib/swarm_cluster_cli_ope/stack_sync_concern.rb +13 -1
- data/lib/swarm_cluster_cli_ope/version.rb +1 -1
- data/swarm_cluster_cli_ope.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2b1b531caf2e5ae14fa47befec029b67c8c5b414bdf9d7378597a69254a7fcd6
|
|
4
|
+
data.tar.gz: 6b0903a0694ce1601a604c1efc0ab5cbb80d496c2758c257935dd4386fd125e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 477f99d4021367e7200fe425dd00887faaefa2fe708f73c3ce175996410917daee50e38a1209cf5f80186cc97c9f0ac16d45a9531da9b6e2ce039752b3df647b
|
|
7
|
+
data.tar.gz: 86caa366eba35e60fcda660f1f2fd55ffe81bd357e2d9f1df8bd52ecc95ae4a845cb56ec357c51711a02473432fa9e79b72458f0e51359048c1831f6e54825d8
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
swarm_cluster_cli_ope (0.
|
|
5
|
-
activesupport
|
|
4
|
+
swarm_cluster_cli_ope (0.7.2.1)
|
|
5
|
+
activesupport (< 7)
|
|
6
6
|
open4
|
|
7
7
|
thor (~> 1.0)
|
|
8
8
|
zeitwerk (~> 2.3)
|
|
@@ -10,22 +10,22 @@ PATH
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
activesupport (6.1.
|
|
13
|
+
activesupport (6.1.6)
|
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
15
15
|
i18n (>= 1.6, < 2)
|
|
16
16
|
minitest (>= 5.1)
|
|
17
17
|
tzinfo (~> 2.0)
|
|
18
18
|
zeitwerk (~> 2.3)
|
|
19
|
-
concurrent-ruby (1.1.
|
|
20
|
-
i18n (1.
|
|
19
|
+
concurrent-ruby (1.1.10)
|
|
20
|
+
i18n (1.10.0)
|
|
21
21
|
concurrent-ruby (~> 1.0)
|
|
22
|
-
minitest (5.
|
|
22
|
+
minitest (5.16.1)
|
|
23
23
|
open4 (1.3.4)
|
|
24
24
|
rake (12.3.3)
|
|
25
|
-
thor (1.1
|
|
25
|
+
thor (1.2.1)
|
|
26
26
|
tzinfo (2.0.4)
|
|
27
27
|
concurrent-ruby (~> 1.0)
|
|
28
|
-
zeitwerk (2.
|
|
28
|
+
zeitwerk (2.6.0)
|
|
29
29
|
|
|
30
30
|
PLATFORMS
|
|
31
31
|
ruby
|
|
@@ -35,4 +35,4 @@ DEPENDENCIES
|
|
|
35
35
|
swarm_cluster_cli_ope!
|
|
36
36
|
|
|
37
37
|
BUNDLED WITH
|
|
38
|
-
1.
|
|
38
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -231,9 +231,12 @@ docker-compose -f test_folder/test_k8s/docker-compose-local.yml up -d
|
|
|
231
231
|
```
|
|
232
232
|
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
## Release
|
|
235
|
+
|
|
236
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
237
|
+
|
|
238
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
|
239
|
+
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
237
240
|
|
|
238
241
|
|
|
239
242
|
## License
|
|
@@ -31,8 +31,9 @@ module SwarmClusterCliOpe
|
|
|
31
31
|
|
|
32
32
|
# @param [String,Array<String>] cmd -> comando da passare a kubectl exec -- CMD
|
|
33
33
|
# @return [SwarmClusterCliOpe::ShellCommandResponse]
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
# @param [FalseClass] allow_failure -> parametro per lasciar fallire o meno il comando senza bloccarsi e poi gestirlo
|
|
35
|
+
def exec(cmd, allow_failure: false)
|
|
36
|
+
base_cmd(["exec", name, "--", cmd].flatten).execute(allow_failure: allow_failure)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
##
|
|
@@ -45,22 +45,24 @@ module SwarmClusterCliOpe
|
|
|
45
45
|
|
|
46
46
|
# controllo presenza comandi necessari
|
|
47
47
|
command_installed = false
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
install_rsync = false
|
|
49
|
+
install_psmisc = false
|
|
50
|
+
if container.exec(['sh -c "command -v apt"'], allow_failure: true).success?
|
|
51
|
+
puts "Container Ubuntu"
|
|
52
|
+
install_rsync = container.exec(['sh -c "command -v rsync || apt update && apt install -yq rsync "'], allow_failure: true).success?
|
|
53
|
+
install_psmisc = container.exec(['sh -c "command -v killall || apt update && apt install -yq psmisc"'], allow_failure: true).success?
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
if container.exec(['sh -c "command -v apk"'], allow_failure: true).success?
|
|
57
|
+
puts "Container Alpine"
|
|
58
|
+
install_rsync = container.exec(['sh -c "command -v rsync || apk add rsync"'], allow_failure: true).success?
|
|
59
|
+
install_psmisc = true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if install_rsync and install_psmisc
|
|
63
|
+
command_installed = true
|
|
64
|
+
else
|
|
65
|
+
puts "Problemi nell'installazione di rsync nel pod"
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
if command_installed
|
|
@@ -4,7 +4,14 @@ module SwarmClusterCliOpe
|
|
|
4
4
|
|
|
5
5
|
# @return [SwarmClusterCliOpe::Models::ComposeContainer]
|
|
6
6
|
def self.find_by_service_name(service_name, stack_name: '')
|
|
7
|
-
|
|
7
|
+
# prima controlliamo se siamo con il vecchio sistema di docker-compose dove i nomi dei servizi venivano
|
|
8
|
+
# costruiti con _ oppure se siamo nella nuova versione di docker compose dove c'è il - che fà da spaziatore
|
|
9
|
+
res = nil
|
|
10
|
+
["_", "-"].each do |separatore|
|
|
11
|
+
res = ShellCommandExecution.new("docker inspect #{[stack_name, service_name, "1"].compact.join(separatore)}").execute(allow_failure: true)
|
|
12
|
+
break unless res.failed?
|
|
13
|
+
end
|
|
14
|
+
raise "Non siamo riusciti ad identificare il servizio in locale" if res.failed?
|
|
8
15
|
self.new(JSON.parse(res.raw_result[:stdout]).first)
|
|
9
16
|
end
|
|
10
17
|
|
|
@@ -66,7 +66,19 @@ module SwarmClusterCliOpe
|
|
|
66
66
|
- pg_user: "postgres" -> valore in chiaro, in sostituzione della variabile ambiente, DEFAULT: postgres
|
|
67
67
|
- database_name_env: "POSTGRES_DB" -> variabile ambiente interna al servizio contenente NOME DB, DEFAULT: POSTGRES_DB
|
|
68
68
|
- database_name: "nome_db" -> valore in chiaro, in sostituzione della variabile ambiente
|
|
69
|
-
|
|
69
|
+
mongo:
|
|
70
|
+
-- local: -> hash di configurazioni per il DB locale
|
|
71
|
+
- service: "db" -> nome del servizio nel compose locale, DEFAULT: quello definito sopra
|
|
72
|
+
- password: "" -> password per DB
|
|
73
|
+
- username: "" -> username per DB
|
|
74
|
+
- database_name: "nome_db" -> nome del DB
|
|
75
|
+
- exclude_from_sync: "coll1,coll2" -> elenco di collections di cui non eseguire il dump quando facciamo PUSH, DEFAULT: ''
|
|
76
|
+
-- remote: -> hash di configurazioni per il DB remoto
|
|
77
|
+
- service: "db" -> nome del servizio nel compose locale, DEFAULT: quello definito sopra
|
|
78
|
+
- password: "" -> password per DB
|
|
79
|
+
- username: "" -> username per DB
|
|
80
|
+
- database_name: "nome_db" -> nome del DB
|
|
81
|
+
- exclude_from_sync: "coll1,coll2" -> elenco di collections di cui non eseguire il dump quando facciamo PULL, DEFAULT: ''
|
|
70
82
|
|
|
71
83
|
EXAMPLE:
|
|
72
84
|
Esempio di sincronizzazione di un file sqlite3 e una cartella
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swarm_cluster_cli_ope
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.7.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marino Bonetti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-06-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -56,16 +56,16 @@ dependencies:
|
|
|
56
56
|
name: activesupport
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - "<"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '7'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - "<"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '7'
|
|
69
69
|
description: |-
|
|
70
70
|
Gestione di varie operazioni come sincronia con le cartelle bindate dei container (rsync) up o
|
|
71
71
|
down e possibilità di scaricare/caricare i file direttamente all'interno del cluster, in
|
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
159
|
version: '0'
|
|
160
160
|
requirements: []
|
|
161
|
-
rubygems_version: 3.
|
|
161
|
+
rubygems_version: 3.1.4
|
|
162
162
|
signing_key:
|
|
163
163
|
specification_version: 4
|
|
164
164
|
summary: WIP Gemma per la gestione del cluster swarm
|