swarm_cluster_cli_ope 0.7.2.1 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Dockerfile +39 -0
- data/Gemfile.lock +8 -8
- data/README.md +3 -2
- data/lib/swarm_cluster_cli_ope/kubernetes/sync_configs/rsync.rb +10 -4
- data/lib/swarm_cluster_cli_ope/stack_sync_concern.rb +1 -0
- data/lib/swarm_cluster_cli_ope/sync_configs/mysql.rb +26 -3
- data/lib/swarm_cluster_cli_ope/version.rb +1 -1
- data/swarm_cluster_cli_ope.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b8ca6327409b45e532d4d3c2cce4dbde5bf8819fe909bafeb4690331391c233
|
4
|
+
data.tar.gz: 95cfc42f92f208e3c22febe63994cbec6a9af896131f967a2a97c9836ac4c677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c3c7904a3862d17359b57c052d54caee5eb109894f11685938175966211a389d8bf58ce557e02f9ddcb2af9dacd7d6f89e8addb1d46697a4bd0687a1e54b01
|
7
|
+
data.tar.gz: 340d0256ea1b3d1b396a316df8ae072914d4fda3a906efa67b138e4795370e1361dec2d2fc51aec97fd92881e37c338399c1701087a4d746570eefd0f03cb044
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.7.4
|
data/Dockerfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# syntax = docker/dockerfile:1.4
|
2
|
+
|
3
|
+
#imagine per fare la build della gemma
|
4
|
+
FROM ruby:2.7 as building
|
5
|
+
|
6
|
+
RUN mkdir /builder
|
7
|
+
WORKDIR /builder
|
8
|
+
COPY . .
|
9
|
+
RUN gem build swarm_cluster_cli_ope.gemspec -o swarm_cluster_cli_ope.gem
|
10
|
+
|
11
|
+
|
12
|
+
FROM ruby:2.7
|
13
|
+
LABEL authors="Marino Bonetti"
|
14
|
+
|
15
|
+
RUN apt update && apt install -y docker
|
16
|
+
|
17
|
+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
|
18
|
+
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
19
|
+
|
20
|
+
RUN wget https://github.com/digitalocean/doctl/releases/download/v1.94.0/doctl-1.94.0-linux-amd64.tar.gz && \
|
21
|
+
tar xf doctl-1.94.0-linux-amd64.tar.gz && \
|
22
|
+
mv doctl /usr/local/bin
|
23
|
+
|
24
|
+
RUN mkdir -p /home/nobody && chmod 777 /home/nobody
|
25
|
+
ENV HOME="/home/nobody"
|
26
|
+
ENV USER=nobody
|
27
|
+
|
28
|
+
#COPY --from=building /builder/swarm_cluster_cli_ope.gem .
|
29
|
+
#RUN gem install --user-install ./swarm_cluster_cli_ope.gem # swarm_cluster_cli_ope
|
30
|
+
RUN mkdir /builder && cd /builder
|
31
|
+
COPY . .
|
32
|
+
RUN bundle install && bundle exec rake install
|
33
|
+
RUN chmod -R ugo+rwt /usr/local/bundle
|
34
|
+
|
35
|
+
|
36
|
+
# qua andremo a montare la $PWD
|
37
|
+
WORKDIR /application
|
38
|
+
|
39
|
+
#ENTRYPOINT ["swarm_cli_ope"]
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
swarm_cluster_cli_ope (0.
|
4
|
+
swarm_cluster_cli_ope (0.8.1)
|
5
5
|
activesupport (< 7)
|
6
6
|
open4
|
7
7
|
thor (~> 1.0)
|
@@ -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.7)
|
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.
|
20
|
-
i18n (1.
|
19
|
+
concurrent-ruby (1.2.2)
|
20
|
+
i18n (1.12.0)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
|
-
minitest (5.
|
22
|
+
minitest (5.18.0)
|
23
23
|
open4 (1.3.4)
|
24
24
|
rake (12.3.3)
|
25
25
|
thor (1.2.1)
|
26
|
-
tzinfo (2.0.
|
26
|
+
tzinfo (2.0.6)
|
27
27
|
concurrent-ruby (~> 1.0)
|
28
|
-
zeitwerk (2.6.
|
28
|
+
zeitwerk (2.6.7)
|
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
|
-
2.
|
38
|
+
2.3.7
|
data/README.md
CHANGED
@@ -144,6 +144,7 @@ Possibili CFGS per tipologia:
|
|
144
144
|
- mysql_user: "root" -> valore in chiaro, in sostituzione della variabile ambiente, DEFAULT: root
|
145
145
|
- database_name_env: "MYSQL_DATABASE" -> variabile ambiente interna al servizio contenente NOME DB, DEFAULT: MYSQL_DATABASE
|
146
146
|
- database_name: "MYSQL_DATABASE" -> valore in chiaro, in sostituzione della variabile ambiente
|
147
|
+
- excluded_tables_data: [] -> elenco di tabelle di cui non scaricare i dati(solo lo schema), DEFAULT: []
|
147
148
|
- pg:
|
148
149
|
- local: -> hash di configurazioni per il DB locale
|
149
150
|
- service: "db" -> nome del servizio nel compose locale, DEFAULT: quello definito sopra
|
@@ -217,7 +218,7 @@ docker stack deploy -c test_folder/test_2/docker_compose.yml test2
|
|
217
218
|
Per simulare una sincronizzazione fra locale e remoto di un mysql, lanciamo lo stesso stack anche come compose, in modo
|
218
219
|
da trovarci sulla stessa macchina con tutte e due le situazioni
|
219
220
|
```shell script
|
220
|
-
docker
|
221
|
+
docker compose -f test_folder/test_1/docker-compose-local.yml up -d
|
221
222
|
```
|
222
223
|
|
223
224
|
|
@@ -227,7 +228,7 @@ lanciare quindi l'ambiente di test:
|
|
227
228
|
|
228
229
|
```shell script
|
229
230
|
kubectl apply -f test_folder/test_k8s/test.yaml
|
230
|
-
docker
|
231
|
+
docker compose -f test_folder/test_k8s/docker-compose-local.yml up -d
|
231
232
|
```
|
232
233
|
|
233
234
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module SwarmClusterCliOpe
|
2
4
|
module Kubernetes
|
3
5
|
module SyncConfigs
|
@@ -88,19 +90,22 @@ module SwarmClusterCliOpe
|
|
88
90
|
pid = p.pid
|
89
91
|
say "PID in execuzione port forward:#{pid}"
|
90
92
|
|
93
|
+
# directory temporanea dove salvare pa pwd
|
94
|
+
pwd_dir = Dir.mktmpdir
|
91
95
|
begin
|
92
96
|
|
93
97
|
sleep 1
|
94
98
|
|
95
|
-
#
|
96
|
-
|
97
|
-
|
99
|
+
# creo il file password temporaneo
|
100
|
+
tmp_file_path = File.join(pwd_dir,"password")
|
101
|
+
FileUtils.copy(configs_path("password"),tmp_file_path)
|
102
|
+
FileUtils.chmod(0600,tmp_file_path)
|
98
103
|
|
99
104
|
# lanciamo il comando quindi per far rsync
|
100
105
|
rsync_command = [
|
101
106
|
"rsync -az --no-o --no-g",
|
102
107
|
"--delete",
|
103
|
-
"--password-file=#{
|
108
|
+
"--password-file=#{tmp_file_path}"
|
104
109
|
]
|
105
110
|
|
106
111
|
if direction == :up
|
@@ -119,6 +124,7 @@ module SwarmClusterCliOpe
|
|
119
124
|
sleep 1
|
120
125
|
say "Stoppo porta forwarded"
|
121
126
|
Process.kill("INT", pid)
|
127
|
+
FileUtils.remove_entry pwd_dir
|
122
128
|
end
|
123
129
|
ensure
|
124
130
|
say "Tolgo il servizio di rsyn"
|
@@ -49,6 +49,7 @@ module SwarmClusterCliOpe
|
|
49
49
|
- mysql_user: "root" -> valore in chiaro, in sostituzione della variabile ambiente, DEFAULT: root
|
50
50
|
- database_name_env: "MYSQL_DATABASE" -> variabile ambiente interna al servizio contenente NOME DB, DEFAULT: MYSQL_DATABASE
|
51
51
|
- database_name: "MYSQL_DATABASE" -> valore in chiaro, in sostituzione della variabile ambiente
|
52
|
+
- excluded_tables_data: [] -> elenco di tabelle di cui non scaricare i dati(solo lo schema), DEFAULT: []
|
52
53
|
pg:
|
53
54
|
--local: -> hash di configurazioni per il DB locale
|
54
55
|
- service: "db" -> nome del servizio nel compose locale, DEFAULT: quello definito sopra
|
@@ -7,7 +7,23 @@ module SwarmClusterCliOpe
|
|
7
7
|
resume('pull')
|
8
8
|
if yes?("Confermare il comando?[y,yes]")
|
9
9
|
tmp_file = "/tmp/#{Time.now.to_i}.sql.gz"
|
10
|
-
|
10
|
+
|
11
|
+
#--ignore-table=bkw_ecospazio.gps_events
|
12
|
+
remote_authentication = "-u #{remote.username} --password=#{remote.password}"
|
13
|
+
dump_command = "mysqldump #{remote_authentication}"
|
14
|
+
remote.excluded_tables_data.each do |t|
|
15
|
+
dump_command << " --ignore-table=#{remote.database_name}.#{t}"
|
16
|
+
end
|
17
|
+
dump_command << " #{remote.database_name}"
|
18
|
+
dump_command << " > /tmp/export.sql"
|
19
|
+
# eseguiamo il backup dello schema per le tabelle elencate
|
20
|
+
remote.excluded_tables_data.each do |t|
|
21
|
+
dump_command << " &&"
|
22
|
+
dump_command << " mysqldump #{remote_authentication}"
|
23
|
+
dump_command << " --no-data #{remote.database_name} #{t} >> /tmp/export.sql"
|
24
|
+
end
|
25
|
+
|
26
|
+
container.exec("bash -c '#{dump_command} && cat /tmp/export.sql | gzip -c -f' > #{tmp_file}")
|
11
27
|
local_container.copy_in(tmp_file, tmp_file)
|
12
28
|
local_authentication = "-u #{local.username} --password=#{local.password}"
|
13
29
|
|
@@ -24,7 +40,7 @@ module SwarmClusterCliOpe
|
|
24
40
|
|
25
41
|
command << "'"
|
26
42
|
|
27
|
-
local_container.exec(command.join" ")
|
43
|
+
local_container.exec(command.join " ")
|
28
44
|
end
|
29
45
|
true
|
30
46
|
end
|
@@ -41,6 +57,12 @@ module SwarmClusterCliOpe
|
|
41
57
|
true
|
42
58
|
end
|
43
59
|
|
60
|
+
def resume(direction)
|
61
|
+
super
|
62
|
+
|
63
|
+
puts "excluded_tables: #{remote.excluded_tables_data.join(",")}"
|
64
|
+
end
|
65
|
+
|
44
66
|
##
|
45
67
|
# Classe interna che rappresenta le configurazioni del DB
|
46
68
|
class EnvConfigs < BaseDatabase::EnvConfigs
|
@@ -51,8 +73,9 @@ module SwarmClusterCliOpe
|
|
51
73
|
|
52
74
|
define_cfgs :database_version, default_env: "MYSQL_MAJOR", configuration_name: :mysql_version
|
53
75
|
|
54
|
-
|
76
|
+
define_cfgs :excluded_tables_data, default_value: [], configuration_name: :excluded_tables_data
|
55
77
|
|
78
|
+
end
|
56
79
|
|
57
80
|
end
|
58
81
|
end
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
25
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
26
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|test_folder)/}) }
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|test_folder|Dockerfile)/}) }
|
27
27
|
end
|
28
28
|
spec.bindir = "exe"
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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: 0.
|
4
|
+
version: 0.8.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: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- ".ruby-gemset"
|
82
82
|
- ".ruby-version"
|
83
83
|
- CHANGELOG.md
|
84
|
+
- Dockerfile
|
84
85
|
- Gemfile
|
85
86
|
- Gemfile.lock
|
86
87
|
- LICENSE.txt
|
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
161
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.3.5
|
162
163
|
signing_key:
|
163
164
|
specification_version: 4
|
164
165
|
summary: WIP Gemma per la gestione del cluster swarm
|