hetzner-k3s 0.4.8 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +121 -0
- data/.ruby-version +1 -0
- data/Dockerfile +5 -2
- data/Gemfile +5 -3
- data/Gemfile.lock +28 -53
- data/README.md +24 -5
- data/Rakefile +5 -3
- data/bin/build.sh +3 -3
- data/bin/{console → console.sh} +3 -3
- data/bin/{setup → setup.sh} +0 -0
- data/hetzner-k3s.gemspec +25 -21
- data/lib/hetzner/infra/client.rb +17 -15
- data/lib/hetzner/infra/firewall.rb +92 -90
- data/lib/hetzner/infra/load_balancer.rb +62 -59
- data/lib/hetzner/infra/network.rb +31 -30
- data/lib/hetzner/infra/placement_group.rb +25 -21
- data/lib/hetzner/infra/server.rb +37 -31
- data/lib/hetzner/infra/ssh_key.rb +34 -35
- data/lib/hetzner/infra.rb +5 -1
- data/lib/hetzner/k3s/cli.rb +268 -289
- data/lib/hetzner/k3s/cluster.rb +428 -509
- data/lib/hetzner/k3s/version.rb +3 -1
- data/lib/hetzner/utils.rb +103 -0
- data/lib/hetzner.rb +2 -0
- metadata +33 -16
- data/lib/hetzner/k3s/client_patch.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45de69f63ea8c675489cc385a2860c798923f42af6e9fa4af791042ae57aa7dd
|
4
|
+
data.tar.gz: 778c30870784ee1d0f9bcb4b102639bc8f295faa60eca8bb9d0ef7ff56905c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 301590287388f2c512e66504558d88fe7e31237c0525a37f96ca5f090190421a2841c66a59f1be2b5a45c632f5ad6799ecab4894058335387fbdce6927b3c7a3
|
7
|
+
data.tar.gz: 3715433adfe0f43889f33962844d54d30017b1a85c5c9ff0a6c21b70980e3b01dbdb431020441404654845d46044643725b8558dc6c0fff49992ab6297ebed71
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
Gemspec/DateAssignment: # new in 1.10
|
2
|
+
Enabled: true
|
3
|
+
Gemspec/RequireMFA: # new in 1.23
|
4
|
+
Enabled: true
|
5
|
+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
|
6
|
+
Enabled: true
|
7
|
+
Layout/SpaceBeforeBrackets: # new in 1.7
|
8
|
+
Enabled: true
|
9
|
+
Lint/AmbiguousAssignment: # new in 1.7
|
10
|
+
Enabled: true
|
11
|
+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
12
|
+
Enabled: true
|
13
|
+
Lint/AmbiguousRange: # new in 1.19
|
14
|
+
Enabled: true
|
15
|
+
Lint/DeprecatedConstants: # new in 1.8
|
16
|
+
Enabled: true
|
17
|
+
Lint/DuplicateBranch: # new in 1.3
|
18
|
+
Enabled: true
|
19
|
+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
|
20
|
+
Enabled: true
|
21
|
+
Lint/EmptyBlock: # new in 1.1
|
22
|
+
Enabled: true
|
23
|
+
Lint/EmptyClass: # new in 1.3
|
24
|
+
Enabled: true
|
25
|
+
Lint/EmptyInPattern: # new in 1.16
|
26
|
+
Enabled: true
|
27
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
28
|
+
Enabled: true
|
29
|
+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
|
30
|
+
Enabled: true
|
31
|
+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
|
32
|
+
Enabled: true
|
33
|
+
Lint/NumberedParameterAssignment: # new in 1.9
|
34
|
+
Enabled: true
|
35
|
+
Lint/OrAssignmentToConstant: # new in 1.9
|
36
|
+
Enabled: true
|
37
|
+
Lint/RedundantDirGlobSort: # new in 1.8
|
38
|
+
Enabled: true
|
39
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
40
|
+
Enabled: true
|
41
|
+
Lint/SymbolConversion: # new in 1.9
|
42
|
+
Enabled: true
|
43
|
+
Lint/ToEnumArguments: # new in 1.1
|
44
|
+
Enabled: true
|
45
|
+
Lint/TripleQuotes: # new in 1.9
|
46
|
+
Enabled: true
|
47
|
+
Lint/UnexpectedBlockArity: # new in 1.5
|
48
|
+
Enabled: true
|
49
|
+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
|
50
|
+
Enabled: true
|
51
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
52
|
+
Enabled: true
|
53
|
+
Naming/BlockForwarding: # new in 1.24
|
54
|
+
Enabled: true
|
55
|
+
Security/IoMethods: # new in 1.22
|
56
|
+
Enabled: true
|
57
|
+
Style/ArgumentsForwarding: # new in 1.1
|
58
|
+
Enabled: true
|
59
|
+
Style/CollectionCompact: # new in 1.2
|
60
|
+
Enabled: true
|
61
|
+
Style/DocumentDynamicEvalDefinition: # new in 1.1
|
62
|
+
Enabled: true
|
63
|
+
Style/EndlessMethod: # new in 1.8
|
64
|
+
Enabled: true
|
65
|
+
Style/FileRead: # new in 1.24
|
66
|
+
Enabled: true
|
67
|
+
Style/FileWrite: # new in 1.24
|
68
|
+
Enabled: true
|
69
|
+
Style/HashConversion: # new in 1.10
|
70
|
+
Enabled: true
|
71
|
+
Style/HashExcept: # new in 1.7
|
72
|
+
Enabled: true
|
73
|
+
Style/IfWithBooleanLiteralBranches: # new in 1.9
|
74
|
+
Enabled: true
|
75
|
+
Style/InPatternThen: # new in 1.16
|
76
|
+
Enabled: true
|
77
|
+
Style/MapToHash: # new in 1.24
|
78
|
+
Enabled: true
|
79
|
+
Style/MultilineInPatternThen: # new in 1.16
|
80
|
+
Enabled: true
|
81
|
+
Style/NegatedIfElseCondition: # new in 1.2
|
82
|
+
Enabled: true
|
83
|
+
Style/NilLambda: # new in 1.3
|
84
|
+
Enabled: true
|
85
|
+
Style/NumberedParameters: # new in 1.22
|
86
|
+
Enabled: true
|
87
|
+
Style/NumberedParametersLimit: # new in 1.22
|
88
|
+
Enabled: true
|
89
|
+
Style/OpenStructUse: # new in 1.23
|
90
|
+
Enabled: true
|
91
|
+
Style/QuotedSymbols: # new in 1.16
|
92
|
+
Enabled: true
|
93
|
+
Style/RedundantArgument: # new in 1.4
|
94
|
+
Enabled: true
|
95
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
96
|
+
Enabled: true
|
97
|
+
Style/SelectByRegexp: # new in 1.22
|
98
|
+
Enabled: true
|
99
|
+
Style/StringChars: # new in 1.12
|
100
|
+
Enabled: true
|
101
|
+
Style/SwapValues: # new in 1.1
|
102
|
+
Enabled: true
|
103
|
+
Style/Documentation:
|
104
|
+
Enabled: false
|
105
|
+
Metrics/MethodLength:
|
106
|
+
Enabled: false
|
107
|
+
Metrics/AbcSize:
|
108
|
+
Enabled: false
|
109
|
+
Metrics/CyclomaticComplexity:
|
110
|
+
Enabled: false
|
111
|
+
Metrics/ClassLength:
|
112
|
+
Enabled: false
|
113
|
+
Layout/LineLength:
|
114
|
+
Enabled: false
|
115
|
+
Metrics/PerceivedComplexity:
|
116
|
+
Enabled: false
|
117
|
+
Metrics/ParameterLists:
|
118
|
+
Max: 10
|
119
|
+
Style/FrozenStringLiteralComment:
|
120
|
+
Exclude:
|
121
|
+
- exe/hetzner-k3s
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.0
|
data/Dockerfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
FROM ruby:
|
1
|
+
FROM ruby:3.1.0-alpine
|
2
2
|
|
3
3
|
RUN apk update --no-cache \
|
4
|
-
&& apk add build-base git openssh-client
|
4
|
+
&& apk add build-base git openssh-client curl bash
|
5
|
+
|
6
|
+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
|
7
|
+
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
5
8
|
|
6
9
|
COPY . .
|
7
10
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hetzner-k3s (0.
|
4
|
+
hetzner-k3s (0.5.0)
|
5
5
|
bcrypt_pbkdf
|
6
6
|
ed25519
|
7
7
|
http
|
8
|
-
k8s-ruby
|
9
8
|
net-ssh
|
10
9
|
sshkey
|
10
|
+
subprocess
|
11
11
|
thor
|
12
12
|
|
13
13
|
GEM
|
@@ -15,44 +15,16 @@ GEM
|
|
15
15
|
specs:
|
16
16
|
addressable (2.8.0)
|
17
17
|
public_suffix (>= 2.0.2, < 5.0)
|
18
|
+
ast (2.4.2)
|
18
19
|
bcrypt_pbkdf (1.1.0)
|
19
|
-
concurrent-ruby (1.1.9)
|
20
20
|
diff-lcs (1.4.4)
|
21
21
|
domain_name (0.5.20190701)
|
22
22
|
unf (>= 0.0.5, < 1.0.0)
|
23
|
-
|
24
|
-
|
25
|
-
dry-core (~> 0.6)
|
26
|
-
dry-container (0.9.0)
|
27
|
-
concurrent-ruby (~> 1.0)
|
28
|
-
dry-configurable (~> 0.13, >= 0.13.0)
|
29
|
-
dry-core (0.7.1)
|
30
|
-
concurrent-ruby (~> 1.0)
|
31
|
-
dry-equalizer (0.3.0)
|
32
|
-
dry-inflector (0.2.1)
|
33
|
-
dry-logic (0.6.1)
|
34
|
-
concurrent-ruby (~> 1.0)
|
35
|
-
dry-core (~> 0.2)
|
36
|
-
dry-equalizer (~> 0.2)
|
37
|
-
dry-struct (0.5.1)
|
38
|
-
dry-core (~> 0.4, >= 0.4.3)
|
39
|
-
dry-equalizer (~> 0.2)
|
40
|
-
dry-types (~> 0.13)
|
41
|
-
ice_nine (~> 0.11)
|
42
|
-
dry-types (0.13.4)
|
43
|
-
concurrent-ruby (~> 1.0)
|
44
|
-
dry-container (~> 0.3)
|
45
|
-
dry-core (~> 0.4, >= 0.4.4)
|
46
|
-
dry-equalizer (~> 0.2)
|
47
|
-
dry-inflector (~> 0.1, >= 0.1.2)
|
48
|
-
dry-logic (~> 0.4, >= 0.4.2)
|
49
|
-
ed25519 (1.2.4)
|
50
|
-
excon (0.88.0)
|
51
|
-
ffi (1.15.4)
|
23
|
+
ed25519 (1.3.0)
|
24
|
+
ffi (1.15.5)
|
52
25
|
ffi-compiler (1.0.1)
|
53
26
|
ffi (>= 1.0.0)
|
54
27
|
rake
|
55
|
-
hashdiff (1.0.1)
|
56
28
|
http (4.4.1)
|
57
29
|
addressable (~> 2.3)
|
58
30
|
http-cookie (~> 1.0)
|
@@ -63,24 +35,15 @@ GEM
|
|
63
35
|
http-form_data (2.3.0)
|
64
36
|
http-parser (1.2.3)
|
65
37
|
ffi-compiler (>= 1.0, < 2.0)
|
66
|
-
ice_nine (0.11.2)
|
67
|
-
jsonpath (0.9.9)
|
68
|
-
multi_json
|
69
|
-
to_regexp (~> 0.2.1)
|
70
|
-
k8s-ruby (0.10.5)
|
71
|
-
dry-struct (~> 0.5.0)
|
72
|
-
dry-types (~> 0.13.0)
|
73
|
-
excon (~> 0.71)
|
74
|
-
hashdiff (~> 1.0.0)
|
75
|
-
jsonpath (~> 0.9.5)
|
76
|
-
recursive-open-struct (~> 1.1.0)
|
77
|
-
yajl-ruby (~> 1.4.0)
|
78
|
-
yaml-safe_load_stream (~> 0.1)
|
79
|
-
multi_json (1.15.0)
|
80
38
|
net-ssh (6.1.0)
|
39
|
+
parallel (1.21.0)
|
40
|
+
parser (3.1.0.0)
|
41
|
+
ast (~> 2.4.1)
|
81
42
|
public_suffix (4.0.6)
|
43
|
+
rainbow (3.1.1)
|
82
44
|
rake (12.3.3)
|
83
|
-
|
45
|
+
regexp_parser (2.2.0)
|
46
|
+
rexml (3.2.5)
|
84
47
|
rspec (3.10.0)
|
85
48
|
rspec-core (~> 3.10.0)
|
86
49
|
rspec-expectations (~> 3.10.0)
|
@@ -94,14 +57,25 @@ GEM
|
|
94
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
95
58
|
rspec-support (~> 3.10.0)
|
96
59
|
rspec-support (3.10.2)
|
60
|
+
rubocop (1.25.1)
|
61
|
+
parallel (~> 1.10)
|
62
|
+
parser (>= 3.1.0.0)
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
64
|
+
regexp_parser (>= 1.8, < 3.0)
|
65
|
+
rexml
|
66
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
69
|
+
rubocop-ast (1.15.1)
|
70
|
+
parser (>= 3.0.1.1)
|
71
|
+
ruby-progressbar (1.11.0)
|
97
72
|
sshkey (2.0.0)
|
98
|
-
|
99
|
-
|
73
|
+
subprocess (1.5.5)
|
74
|
+
thor (1.2.1)
|
100
75
|
unf (0.1.4)
|
101
76
|
unf_ext
|
102
77
|
unf_ext (0.0.8)
|
103
|
-
|
104
|
-
yaml-safe_load_stream (0.1.1)
|
78
|
+
unicode-display_width (2.1.0)
|
105
79
|
|
106
80
|
PLATFORMS
|
107
81
|
ruby
|
@@ -110,6 +84,7 @@ DEPENDENCIES
|
|
110
84
|
hetzner-k3s!
|
111
85
|
rake (~> 12.0)
|
112
86
|
rspec (~> 3.0)
|
87
|
+
rubocop
|
113
88
|
|
114
89
|
BUNDLED WITH
|
115
|
-
2.
|
90
|
+
2.3.4
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ All that is needed to use this tool is
|
|
25
25
|
|
26
26
|
## Installation
|
27
27
|
|
28
|
-
Once you have the Ruby runtime up and running (
|
28
|
+
Once you have the Ruby runtime up and running (3.1.0 or newer), you just need to install the gem:
|
29
29
|
|
30
30
|
```bash
|
31
31
|
gem install hetzner-k3s
|
@@ -38,7 +38,7 @@ This will install the `hetzner-k3s` executable in your PATH.
|
|
38
38
|
Alternatively, if you don't want to set up a Ruby runtime but have Docker installed, you can use a container. Run the following from inside the directory where you have the config file for the cluster (described in the next section):
|
39
39
|
|
40
40
|
```bash
|
41
|
-
docker run --rm -it -v ${PWD}:/cluster -v ${HOME}/.ssh:/tmp/.ssh vitobotta/hetzner-k3s:v0.
|
41
|
+
docker run --rm -it -v ${PWD}:/cluster -v ${HOME}/.ssh:/tmp/.ssh vitobotta/hetzner-k3s:v0.5.1 create-cluster --config-file /cluster/test.yaml
|
42
42
|
```
|
43
43
|
|
44
44
|
Replace `test.yaml` with the name of your config file.
|
@@ -70,11 +70,14 @@ worker_node_pools:
|
|
70
70
|
- name: big
|
71
71
|
instance_type: cpx31
|
72
72
|
instance_count: 2
|
73
|
+
additional_packages:
|
74
|
+
- somepackage
|
75
|
+
enable_ipsec_encryption: true
|
73
76
|
```
|
74
77
|
|
75
78
|
It should hopefully be self explanatory; you can run `hetzner-k3s releases` to see a list of the available releases from the most recent to the oldest available.
|
76
79
|
|
77
|
-
If you are using Docker, then set `kubeconfig_path` to `/cluster/kubeconfig` so that the kubeconfig is created in the same directory where your config file is.
|
80
|
+
If you are using Docker, then set `kubeconfig_path` to `/cluster/kubeconfig` so that the kubeconfig is created in the same directory where your config file is. Also set the config file path to `/cluster/<filename>`.
|
78
81
|
|
79
82
|
If you don't want to specify the Hetzner token in the config file (for example if you want to use the tool with CI), then you can use the `HCLOUD_TOKEN` environment variable instead, which has predecence.
|
80
83
|
|
@@ -108,7 +111,7 @@ curl \
|
|
108
111
|
'https://api.hetzner.cloud/v1/images'
|
109
112
|
```
|
110
113
|
|
111
|
-
Note that if you use a custom image, the creation of the servers may take longer than when using the default image.
|
114
|
+
Note that if you use a custom image, the creation of the servers may take longer than when using the default image.
|
112
115
|
|
113
116
|
Also note: the option `verify_host_key` is by default set to `false` to disable host key verification. This is because sometimes when creating new servers, Hetzner may assign IP addresses that were previously used by other servers you owned in the past. Therefore the host key verification would fail. If you set this option to `true` and this happens, the tool won't be able to continue creating the cluster until you resolve the issue with one of the suggestions it will give you.
|
114
117
|
|
@@ -211,7 +214,7 @@ kubectl label node <master1> <master2> <master2> plan.upgrade.cattle.io/k3s-serv
|
|
211
214
|
To delete a cluster, running
|
212
215
|
|
213
216
|
```bash
|
214
|
-
hetzner-k3s delete-cluster --config-file cluster_config.
|
217
|
+
hetzner-k3s delete-cluster --config-file cluster_config.yaml
|
215
218
|
```
|
216
219
|
|
217
220
|
This will delete all the resources in the Hetzner Cloud project for the cluster being deleted.
|
@@ -254,6 +257,22 @@ I recommend that you create a separate Hetzner project for each cluster, because
|
|
254
257
|
|
255
258
|
## changelog
|
256
259
|
|
260
|
+
- 0.5.2
|
261
|
+
- Ensure that in a HA cluster the nodes connect to the load balancer for the API server, instead of the first master
|
262
|
+
|
263
|
+
- 0.5.1
|
264
|
+
- Each node pool gets its own placement group. This is to minimize issues due to the max 10 nodes limitation for a single node group. A validation has also been added to limit pools to 10 nodes each because of this.
|
265
|
+
|
266
|
+
- 0.5.0
|
267
|
+
- Allow installing additional packages when creating the servers
|
268
|
+
- Allow enabling ipsec encryption
|
269
|
+
|
270
|
+
- 0.4.9
|
271
|
+
- Ensure the program always exits with exit code 1 if the config file fails validation
|
272
|
+
- Upgrade System Upgrade Controller to 0.8.1
|
273
|
+
- Remove dependency on unmaintained gem k8s-ruby
|
274
|
+
- Make the gem compatible with Ruby 3.1.0
|
275
|
+
|
257
276
|
- 0.4.8
|
258
277
|
- Increase timeout with API requests to 30 seconds
|
259
278
|
- Limit number of retries for API requests to 3
|
data/Rakefile
CHANGED
data/bin/build.sh
CHANGED
@@ -6,9 +6,9 @@ set -e
|
|
6
6
|
|
7
7
|
IMAGE="vitobotta/hetzner-k3s"
|
8
8
|
|
9
|
-
docker build -t ${IMAGE}:v0.
|
9
|
+
docker build -t ${IMAGE}:v0.5.2 \
|
10
10
|
--platform=linux/amd64 \
|
11
|
-
--cache-from ${IMAGE}:v0.
|
11
|
+
--cache-from ${IMAGE}:v0.5.1 \
|
12
12
|
--build-arg BUILDKIT_INLINE_CACHE=1 .
|
13
13
|
|
14
|
-
docker push vitobotta/hetzner-k3s:v0.
|
14
|
+
docker push vitobotta/hetzner-k3s:v0.5.2
|
data/bin/{console → console.sh}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'k3s'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "k3s"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/bin/{setup → setup.sh}
RENAMED
File without changes
|
data/hetzner-k3s.gemspec
CHANGED
@@ -1,37 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/hetzner/k3s/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
6
|
+
spec.name = 'hetzner-k3s'
|
5
7
|
spec.version = Hetzner::K3s::VERSION
|
6
|
-
spec.authors = [
|
7
|
-
spec.email = [
|
8
|
+
spec.authors = ['Vito Botta']
|
9
|
+
spec.email = ['vito@botta.me']
|
8
10
|
|
9
|
-
spec.summary =
|
10
|
-
spec.description =
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = 'A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.'
|
12
|
+
spec.description = 'A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.'
|
13
|
+
spec.homepage = 'https://github.com/vitobotta/hetzner-k3s'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
|
14
16
|
|
15
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
18
|
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
19
|
-
spec.metadata[
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/vitobotta/hetzner-k3s'
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/vitobotta/hetzner-k3s'
|
20
22
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
23
|
+
spec.add_dependency 'bcrypt_pbkdf'
|
24
|
+
spec.add_dependency 'ed25519'
|
25
|
+
spec.add_dependency 'http'
|
26
|
+
spec.add_dependency 'net-ssh'
|
27
|
+
spec.add_dependency 'sshkey'
|
28
|
+
spec.add_dependency 'subprocess'
|
29
|
+
spec.add_dependency 'thor'
|
30
|
+
spec.add_development_dependency 'rubocop'
|
28
31
|
|
29
32
|
# Specify which files should be added to the gem when it is released.
|
30
33
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
-
spec.files
|
34
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
32
35
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
36
|
end
|
34
|
-
spec.bindir =
|
37
|
+
spec.bindir = 'exe'
|
35
38
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = [
|
39
|
+
spec.require_paths = ['lib']
|
40
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
37
41
|
end
|
data/lib/hetzner/infra/client.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hetzner
|
2
4
|
class Client
|
3
|
-
BASE_URI =
|
5
|
+
BASE_URI = 'https://api.hetzner.cloud/v1'
|
4
6
|
|
5
7
|
attr_reader :token
|
6
8
|
|
@@ -22,27 +24,27 @@ module Hetzner
|
|
22
24
|
|
23
25
|
def delete(path, id)
|
24
26
|
make_request do
|
25
|
-
HTTP.headers(headers).delete(BASE_URI
|
27
|
+
HTTP.headers(headers).delete("#{BASE_URI}#{path}/#{id}")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def headers
|
34
|
+
{
|
35
|
+
Authorization: "Bearer #{@token}",
|
36
|
+
'Content-Type': 'application/json'
|
37
|
+
}
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
+
def make_request(&block)
|
41
|
+
retries ||= 0
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
rescue Timeout::Error
|
45
|
-
retry if (retries += 1) < 3
|
43
|
+
Timeout.timeout(30) do
|
44
|
+
block.call
|
46
45
|
end
|
46
|
+
rescue Timeout::Error
|
47
|
+
retry if (retries += 1) < 3
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|