hetzner-k3s 0.5.8 → 0.6.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +31 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +13 -2
- data/Gemfile.lock +22 -53
- data/README.md +8 -3
- data/bin/build.sh +12 -6
- data/config/warble.rb +182 -0
- data/exe/hetzner-k3s +3 -0
- data/hetzner-k3s.gemspec +4 -4
- data/lib/hetzner/infra/client.rb +5 -5
- data/lib/hetzner/infra/firewall.rb +7 -9
- data/lib/hetzner/infra/load_balancer.rb +1 -1
- data/lib/hetzner/infra/network.rb +19 -9
- data/lib/hetzner/infra/server.rb +3 -4
- data/lib/hetzner/k3s/cli.rb +6 -5
- data/lib/hetzner/k3s/cluster.rb +55 -36
- data/lib/hetzner/k3s/configuration.rb +55 -23
- data/lib/hetzner/k3s/version.rb +1 -1
- data/lib/hetzner/utils.rb +19 -10
- metadata +25 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47f4f550ab72a6db22b9f7218df70b43744629596fdd5a2fc406b3c19dbe8414
|
4
|
+
data.tar.gz: 26022acdc0c470c7b35e5ae813f6d058f63d261d98f23791ba9b3c88bca978b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1ad2a4f068ba963b6c4258b43a3f6858ef96f96c6c5ea7713f4f012b555acabb532261ffdc7156654e374223a55f1dd8beedd3290db0b88dcfe30a6762c515f
|
7
|
+
data.tar.gz: af74bb06441566cb0590d88824399b64bf823ad7d3923056e827a7bd1231f5671477b6d65f393b5b9c4e154504c63d98ac86f1a53c80db0e2f60b25804250309
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- '*'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
mcos:
|
10
|
+
runs-on: macos-12
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: '2.7.1'
|
17
|
+
|
18
|
+
- name: Get ruby-packer
|
19
|
+
run: |
|
20
|
+
curl -o rubyc-macos https://github.com/pmq20/ruby-packer/releases/download/darwin-x64/rubyc
|
21
|
+
chmod +x rubyc-macos
|
22
|
+
|
23
|
+
- name: Build for macOS
|
24
|
+
run: |
|
25
|
+
env CC="xcrun clang -mmacosx-version-min=10.10 -Wno-implicit-function-declaration" time ./rubyc-macos -r ./ -o ./hetzner-k3s-macos exe/hetzner-k3s
|
26
|
+
|
27
|
+
- uses: ncipollo/release-action@v1
|
28
|
+
with:
|
29
|
+
tag: v$(ruby -r ./lib/hetzner/k3s/version -e 'puts Hetzner::K3s::VERSION')
|
30
|
+
artifacts: "hetzner-k3s-macos"
|
31
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-2.7.1
|
data/Gemfile
CHANGED
@@ -5,5 +5,16 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in k3s.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
9
|
-
gem '
|
8
|
+
# platforms :jruby do
|
9
|
+
# gem 'rake', '~> 12.0'
|
10
|
+
# gem 'rspec', '~> 3.0'
|
11
|
+
|
12
|
+
# gem 'childprocess'
|
13
|
+
# gem 'ed25519'
|
14
|
+
# gem 'http'
|
15
|
+
# gem 'jruby-openssl'
|
16
|
+
# gem 'net-ssh'
|
17
|
+
# gem 'sshkey'
|
18
|
+
# gem 'thor'
|
19
|
+
# gem 'http-parser'
|
20
|
+
# end
|
data/Gemfile.lock
CHANGED
@@ -1,90 +1,59 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hetzner-k3s (0.5.
|
4
|
+
hetzner-k3s (0.5.9)
|
5
5
|
bcrypt_pbkdf
|
6
|
+
childprocess
|
6
7
|
ed25519
|
7
|
-
|
8
|
+
httparty
|
8
9
|
net-ssh
|
9
10
|
sshkey
|
10
|
-
subprocess
|
11
11
|
thor
|
12
12
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
-
addressable (2.8.0)
|
17
|
-
public_suffix (>= 2.0.2, < 5.0)
|
18
16
|
ast (2.4.2)
|
19
17
|
bcrypt_pbkdf (1.1.0)
|
20
|
-
|
21
|
-
domain_name (0.5.20190701)
|
22
|
-
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
childprocess (4.1.0)
|
23
19
|
ed25519 (1.3.0)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
http-form_data (~> 2.2)
|
32
|
-
http-parser (~> 1.2.0)
|
33
|
-
http-cookie (1.0.5)
|
34
|
-
domain_name (~> 0.5)
|
35
|
-
http-form_data (2.3.0)
|
36
|
-
http-parser (1.2.3)
|
37
|
-
ffi-compiler (>= 1.0, < 2.0)
|
20
|
+
httparty (0.20.0)
|
21
|
+
mime-types (~> 3.0)
|
22
|
+
multi_xml (>= 0.5.2)
|
23
|
+
mime-types (3.4.1)
|
24
|
+
mime-types-data (~> 3.2015)
|
25
|
+
mime-types-data (3.2022.0105)
|
26
|
+
multi_xml (0.6.0)
|
38
27
|
net-ssh (6.1.0)
|
39
|
-
parallel (1.
|
40
|
-
parser (3.1.
|
28
|
+
parallel (1.20.1)
|
29
|
+
parser (3.1.2.1)
|
41
30
|
ast (~> 2.4.1)
|
42
|
-
public_suffix (4.0.7)
|
43
31
|
rainbow (3.1.1)
|
44
|
-
|
45
|
-
regexp_parser (2.2.0)
|
32
|
+
regexp_parser (2.5.0)
|
46
33
|
rexml (3.2.5)
|
47
|
-
|
48
|
-
rspec-core (~> 3.10.0)
|
49
|
-
rspec-expectations (~> 3.10.0)
|
50
|
-
rspec-mocks (~> 3.10.0)
|
51
|
-
rspec-core (3.10.1)
|
52
|
-
rspec-support (~> 3.10.0)
|
53
|
-
rspec-expectations (3.10.1)
|
54
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
-
rspec-support (~> 3.10.0)
|
56
|
-
rspec-mocks (3.10.2)
|
57
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
-
rspec-support (~> 3.10.0)
|
59
|
-
rspec-support (3.10.2)
|
60
|
-
rubocop (1.25.1)
|
34
|
+
rubocop (1.12.1)
|
61
35
|
parallel (~> 1.10)
|
62
|
-
parser (>= 3.
|
36
|
+
parser (>= 3.0.0.0)
|
63
37
|
rainbow (>= 2.2.2, < 4.0)
|
64
38
|
regexp_parser (>= 1.8, < 3.0)
|
65
39
|
rexml
|
66
|
-
rubocop-ast (>= 1.
|
40
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
67
41
|
ruby-progressbar (~> 1.7)
|
68
42
|
unicode-display_width (>= 1.4.0, < 3.0)
|
69
|
-
rubocop-ast (1.
|
70
|
-
parser (>=
|
43
|
+
rubocop-ast (1.4.1)
|
44
|
+
parser (>= 2.7.1.5)
|
71
45
|
ruby-progressbar (1.11.0)
|
72
46
|
sshkey (2.0.0)
|
73
|
-
subprocess (1.5.5)
|
74
47
|
thor (1.2.1)
|
75
|
-
|
76
|
-
unf_ext
|
77
|
-
unf_ext (0.0.8.2)
|
78
|
-
unicode-display_width (2.1.0)
|
48
|
+
unicode-display_width (2.2.0)
|
79
49
|
|
80
50
|
PLATFORMS
|
81
51
|
ruby
|
52
|
+
x86_64-darwin-21
|
82
53
|
|
83
54
|
DEPENDENCIES
|
84
55
|
hetzner-k3s!
|
85
|
-
rake (~> 12.0)
|
86
|
-
rspec (~> 3.0)
|
87
56
|
rubocop
|
88
57
|
|
89
58
|
BUNDLED WITH
|
90
|
-
2.3.
|
59
|
+
2.3.21
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Alternatively, if you don't want to set up a Ruby runtime but have Docker instal
|
|
44
44
|
docker run --rm -it \
|
45
45
|
-v ${PWD}:/cluster \
|
46
46
|
-v ${HOME}/.ssh:/tmp/.ssh \
|
47
|
-
vitobotta/hetzner-k3s:v0.5.
|
47
|
+
vitobotta/hetzner-k3s:v0.5.9 \
|
48
48
|
create-cluster \
|
49
49
|
--config-file /cluster/test.yaml
|
50
50
|
```
|
@@ -65,6 +65,8 @@ public_ssh_key_path: "~/.ssh/id_rsa.pub"
|
|
65
65
|
private_ssh_key_path: "~/.ssh/id_rsa"
|
66
66
|
ssh_allowed_networks:
|
67
67
|
- 0.0.0.0/0
|
68
|
+
api_allowed_networks:
|
69
|
+
- 0.0.0.0/0
|
68
70
|
verify_host_key: false
|
69
71
|
location: nbg1
|
70
72
|
schedule_workloads_on_masters: false
|
@@ -104,6 +106,7 @@ enable_encryption: true
|
|
104
106
|
# kube_proxy_args:
|
105
107
|
# - arg1
|
106
108
|
# - ...
|
109
|
+
# existing_network: <specify if you want to use an existing network, otherwise one will be created for this cluster>
|
107
110
|
|
108
111
|
```
|
109
112
|
|
@@ -143,9 +146,11 @@ curl \
|
|
143
146
|
'https://api.hetzner.cloud/v1/images'
|
144
147
|
```
|
145
148
|
|
146
|
-
|
149
|
+
Notes:
|
147
150
|
|
148
|
-
|
151
|
+
- if you use a custom image, the creation of the servers may take longer than when using the default image
|
152
|
+
- 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
|
153
|
+
- the setting `api_allowed_networks` allows specifying which networks can access the Kubernetes API, but this only works with single master clusters currently. Multi-master HA clusters require a load balancer for the API, but load balancers are not yet covered by Hetzner's firewalls.
|
149
154
|
|
150
155
|
Finally, to create the cluster run:
|
151
156
|
|
data/bin/build.sh
CHANGED
@@ -2,11 +2,17 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
-
IMAGE="vitobotta/hetzner-k3s"
|
5
|
+
# IMAGE="vitobotta/hetzner-k3s"
|
6
6
|
|
7
|
-
docker build -t ${IMAGE}:v0.5.
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# docker build -t ${IMAGE}:v0.5.9 \
|
8
|
+
# --platform=linux/amd64 \
|
9
|
+
# --cache-from ${IMAGE}:v0.5.8 \
|
10
|
+
# --build-arg BUILDKIT_INLINE_CACHE=1 .
|
11
11
|
|
12
|
-
docker push vitobotta/hetzner-k3s:v0.5.
|
12
|
+
# docker push vitobotta/hetzner-k3s:v0.5.9
|
13
|
+
|
14
|
+
warble
|
15
|
+
|
16
|
+
echo "#!/usr/bin/env java -jar" > dist/hetzner-k3s
|
17
|
+
cat dist/hetzner-k3s.jar >> dist/hetzner-k3s
|
18
|
+
chmod +x dist/hetzner-k3s
|
data/config/warble.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
# Disable Rake-environment-task framework detection by uncommenting/setting to false
|
2
|
+
# Warbler.framework_detection = false
|
3
|
+
|
4
|
+
# Warbler web application assembly configuration file
|
5
|
+
Warbler::Config.new do |config|
|
6
|
+
# Features: additional options controlling how the jar is built.
|
7
|
+
# Currently the following features are supported:
|
8
|
+
# - *gemjar*: package the gem repository in a jar file in WEB-INF/lib
|
9
|
+
# - *executable*: embed a web server and make the war executable
|
10
|
+
# - *runnable*: allows to run bin scripts e.g. `java -jar my.war -S rake -T`
|
11
|
+
# - *compiled*: compile .rb files to .class files
|
12
|
+
config.features = %w(executable runnable compiled)
|
13
|
+
|
14
|
+
# Application directories to be included in the webapp.
|
15
|
+
config.dirs = %w(bin config exe lib)
|
16
|
+
|
17
|
+
# Additional files/directories to include, above those in config.dirs
|
18
|
+
# config.includes = FileList["db"]
|
19
|
+
|
20
|
+
# Additional files/directories to exclude
|
21
|
+
# config.excludes = FileList["lib/tasks/*"]
|
22
|
+
|
23
|
+
# Additional Java .jar files to include. Note that if .jar files are placed
|
24
|
+
# in lib (and not otherwise excluded) then they need not be mentioned here.
|
25
|
+
# JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your
|
26
|
+
# own versions if you directly set the value
|
27
|
+
# config.java_libs += FileList["lib/java/*.jar"]
|
28
|
+
|
29
|
+
# Loose Java classes and miscellaneous files to be included.
|
30
|
+
# config.java_classes = FileList["target/classes/**.*"]
|
31
|
+
|
32
|
+
# One or more pathmaps defining how the java classes should be copied into
|
33
|
+
# the archive. The example pathmap below accompanies the java_classes
|
34
|
+
# configuration above. See http://rake.rubyforge.org/classes/String.html#M000017
|
35
|
+
# for details of how to specify a pathmap.
|
36
|
+
# config.pathmaps.java_classes << "%{target/classes/,}p"
|
37
|
+
|
38
|
+
# Bundler support is built-in. If Warbler finds a Gemfile in the
|
39
|
+
# project directory, it will be used to collect the gems to bundle
|
40
|
+
# in your application. If you wish to explicitly disable this
|
41
|
+
# functionality, uncomment here.
|
42
|
+
config.bundler = true
|
43
|
+
|
44
|
+
# An array of Bundler groups to avoid including in the war file.
|
45
|
+
# Defaults to ["development", "test", "assets"].
|
46
|
+
# config.bundle_without = []
|
47
|
+
|
48
|
+
# Other gems to be included. If you don't use Bundler or a gemspec
|
49
|
+
# file, you need to tell Warbler which gems your application needs
|
50
|
+
# so that they can be packaged in the archive.
|
51
|
+
# For Rails applications, the Rails gems are included by default
|
52
|
+
# unless the vendor/rails directory is present.
|
53
|
+
# config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]
|
54
|
+
# config.gems << "tzinfo"
|
55
|
+
|
56
|
+
# Uncomment this if you don't want to package rails gem.
|
57
|
+
# config.gems -= ["rails"]
|
58
|
+
|
59
|
+
# The most recent versions of gems are used.
|
60
|
+
# You can specify versions of gems by using a hash assignment:
|
61
|
+
# config.gems["rails"] = "4.2.5"
|
62
|
+
|
63
|
+
# You can also use regexps or Gem::Dependency objects for flexibility or
|
64
|
+
# finer-grained control.
|
65
|
+
# config.gems << /^sinatra-/
|
66
|
+
# config.gems << Gem::Dependency.new("sinatra", "= 1.4.7")
|
67
|
+
|
68
|
+
# Include gem dependencies not mentioned specifically. Default is
|
69
|
+
# true, uncomment to turn off.
|
70
|
+
# config.gem_dependencies = false
|
71
|
+
|
72
|
+
# Array of regular expressions matching relative paths in gems to be
|
73
|
+
# excluded from the war. Defaults to empty, but you can set it like
|
74
|
+
# below, which excludes test files.
|
75
|
+
# config.gem_excludes = [/^(test|spec)\//]
|
76
|
+
|
77
|
+
# Pathmaps for controlling how application files are copied into the archive
|
78
|
+
# config.pathmaps.application = ["WEB-INF/%p"]
|
79
|
+
|
80
|
+
# Name of the archive (without the extension). Defaults to the basename
|
81
|
+
# of the project directory.
|
82
|
+
config.jar_name = "hetzner-k3s"
|
83
|
+
|
84
|
+
# File extension for the archive. Defaults to either 'jar' or 'war'.
|
85
|
+
config.jar_extension = "jar"
|
86
|
+
|
87
|
+
# Destionation for the created archive. Defaults to project's root directory.
|
88
|
+
config.autodeploy_dir = "dist/"
|
89
|
+
|
90
|
+
# Name of the MANIFEST.MF template for the war file. Defaults to a simple
|
91
|
+
# MANIFEST.MF that contains the version of Warbler used to create the war file.
|
92
|
+
# config.manifest_file = "config/MANIFEST.MF"
|
93
|
+
|
94
|
+
# When using the 'compiled' feature and specified, only these Ruby
|
95
|
+
# files will be compiled. Default is to compile all \.rb files in
|
96
|
+
# the application.
|
97
|
+
# config.compiled_ruby_files = FileList['app/**/*.rb']
|
98
|
+
|
99
|
+
# Determines if ruby files in supporting gems will be compiled.
|
100
|
+
# Ignored unless compile feature is used.
|
101
|
+
config.compile_gems = true
|
102
|
+
|
103
|
+
# When set it specify the bytecode version for compiled class files
|
104
|
+
# config.bytecode_version = "1.6"
|
105
|
+
|
106
|
+
# When set to true, Warbler will override the value of ENV['GEM_HOME'] even it
|
107
|
+
# has already been set. When set to false it will use any existing value of
|
108
|
+
# GEM_HOME if it is set.
|
109
|
+
# config.override_gem_home = true
|
110
|
+
|
111
|
+
# Allows for specifing custom executables
|
112
|
+
# config.executable = ["exe/hetzner-k3s"]
|
113
|
+
|
114
|
+
# Sets default (prefixed) parameters for the executables
|
115
|
+
# config.executable_params = "do:something"
|
116
|
+
|
117
|
+
# If set to true, moves jar files into WEB-INF/lib. Prior to version 1.4.2 of Warbler this was done
|
118
|
+
# by default. But since 1.4.2 this config defaults to false. It may need to be set to true for
|
119
|
+
# web servers that do not explode the WAR file.
|
120
|
+
# Alternatively, this option can be set to a regular expression, which will
|
121
|
+
# act as a jar selector -- only jar files that match the pattern will be
|
122
|
+
# included in the archive.
|
123
|
+
# config.move_jars_to_webinf_lib = false
|
124
|
+
|
125
|
+
# === War files only below here ===
|
126
|
+
|
127
|
+
# Embedded webserver to use with the 'executable' feature. Currently supported
|
128
|
+
# webservers are:
|
129
|
+
# - *jetty* - Embedded Jetty from Eclipse
|
130
|
+
# config.webserver = 'jetty'
|
131
|
+
|
132
|
+
# Path to the pre-bundled gem directory inside the war file. Default
|
133
|
+
# is 'WEB-INF/gems'. Specify path if gems are already bundled
|
134
|
+
# before running Warbler. This also sets 'gem.path' inside web.xml.
|
135
|
+
# config.gem_path = "WEB-INF/vendor/bundler_gems"
|
136
|
+
|
137
|
+
# Files for WEB-INF directory (next to web.xml). This contains
|
138
|
+
# web.xml by default. If there is an .erb-File it will be processed
|
139
|
+
# with webxml-config. You may want to exclude this file via
|
140
|
+
# config.excludes.
|
141
|
+
# config.webinf_files += FileList["jboss-web.xml"]
|
142
|
+
|
143
|
+
# Files to be included in the root of the webapp. Note that files in public
|
144
|
+
# will have the leading 'public/' part of the path stripped during staging.
|
145
|
+
# config.public_html = FileList["public/**/*", "doc/**/*"]
|
146
|
+
|
147
|
+
# Pathmaps for controlling how public HTML files are copied into the .war
|
148
|
+
# config.pathmaps.public_html = ["%{public/,}p"]
|
149
|
+
|
150
|
+
# Value of RAILS_ENV for the webapp -- default as shown below
|
151
|
+
# config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
|
152
|
+
|
153
|
+
# Public ROOT mapping, by default assets are copied into .war ROOT directory.
|
154
|
+
# config.public.root = ''
|
155
|
+
|
156
|
+
# Application booter to use, either :rack or :rails (autodetected by default)
|
157
|
+
# config.webxml.booter = :rails
|
158
|
+
|
159
|
+
# When using the :rack booter, "Rackup" script to use.
|
160
|
+
# - For 'rackup.path', the value points to the location of the rackup
|
161
|
+
# script in the web archive file. You need to make sure this file
|
162
|
+
# gets included in the war, possibly by adding it to config.includes
|
163
|
+
# or config.webinf_files above.
|
164
|
+
# - For 'rackup', the rackup script you provide as an inline string
|
165
|
+
# is simply embedded in web.xml.
|
166
|
+
# The script is evaluated in a Rack::Builder to load the application.
|
167
|
+
# Examples:
|
168
|
+
# config.webxml.rackup.path = 'WEB-INF/hello.ru'
|
169
|
+
# config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)}
|
170
|
+
# config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru"))
|
171
|
+
|
172
|
+
# Control the pool of Rails runtimes. Leaving unspecified means
|
173
|
+
# the pool will grow as needed to service requests. It is recommended
|
174
|
+
# that you fix these values when running a production server!
|
175
|
+
# If you're using threadsafe! mode, you probably don't want to set these values,
|
176
|
+
# since 1 runtime(default for threadsafe mode) will be enough.
|
177
|
+
# config.webxml.jruby.min.runtimes = 2
|
178
|
+
# config.webxml.jruby.max.runtimes = 4
|
179
|
+
|
180
|
+
# JNDI data source name
|
181
|
+
# config.webxml.jndi = 'jdbc/rails'
|
182
|
+
end
|
data/exe/hetzner-k3s
CHANGED
data/hetzner-k3s.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.'
|
13
13
|
spec.homepage = 'https://github.com/vitobotta/hetzner-k3s'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.7.1')
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
18
|
|
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.metadata['source_code_uri'] = 'https://github.com/vitobotta/hetzner-k3s'
|
21
21
|
spec.metadata['changelog_uri'] = 'https://github.com/vitobotta/hetzner-k3s'
|
22
22
|
|
23
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'childprocess'
|
24
24
|
spec.add_dependency 'ed25519'
|
25
|
-
spec.add_dependency '
|
25
|
+
spec.add_dependency 'httparty'
|
26
|
+
spec.add_dependency 'bcrypt_pbkdf'
|
26
27
|
spec.add_dependency 'net-ssh'
|
27
28
|
spec.add_dependency 'sshkey'
|
28
|
-
spec.add_dependency 'subprocess'
|
29
29
|
spec.add_dependency 'thor'
|
30
30
|
spec.add_development_dependency 'rubocop'
|
31
31
|
|
data/lib/hetzner/infra/client.rb
CHANGED
@@ -12,19 +12,19 @@ module Hetzner
|
|
12
12
|
|
13
13
|
def get(path)
|
14
14
|
make_request do
|
15
|
-
JSON.parse
|
15
|
+
JSON.parse HTTParty.get(BASE_URI + path, headers: headers).body
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def post(path, data)
|
20
20
|
make_request do
|
21
|
-
|
21
|
+
HTTParty.post(BASE_URI + path, body: data.to_json, headers: headers)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def delete(path, id)
|
26
26
|
make_request do
|
27
|
-
|
27
|
+
HTTParty.delete("#{BASE_URI}#{path}/#{id}", headers: headers)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,8 +32,8 @@ module Hetzner
|
|
32
32
|
|
33
33
|
def headers
|
34
34
|
{
|
35
|
-
Authorization
|
36
|
-
'Content-Type'
|
35
|
+
'Authorization' => "Bearer #{@token}",
|
36
|
+
'Content-Type' => 'application/json'
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
@@ -7,9 +7,10 @@ module Hetzner
|
|
7
7
|
@cluster_name = cluster_name
|
8
8
|
end
|
9
9
|
|
10
|
-
def create(high_availability:,
|
10
|
+
def create(high_availability:, ssh_networks:, api_networks:)
|
11
11
|
@high_availability = high_availability
|
12
|
-
@
|
12
|
+
@ssh_networks = ssh_networks
|
13
|
+
@api_networks = api_networks
|
13
14
|
puts
|
14
15
|
|
15
16
|
if (firewall = find_firewall)
|
@@ -47,7 +48,7 @@ module Hetzner
|
|
47
48
|
|
48
49
|
private
|
49
50
|
|
50
|
-
attr_reader :hetzner_client, :cluster_name, :firewall, :high_availability, :
|
51
|
+
attr_reader :hetzner_client, :cluster_name, :firewall, :high_availability, :ssh_networks, :api_networks
|
51
52
|
|
52
53
|
def create_firewall_config
|
53
54
|
rules = [
|
@@ -56,7 +57,7 @@ module Hetzner
|
|
56
57
|
direction: 'in',
|
57
58
|
protocol: 'tcp',
|
58
59
|
port: '22',
|
59
|
-
source_ips:
|
60
|
+
source_ips: ssh_networks,
|
60
61
|
destination_ips: []
|
61
62
|
},
|
62
63
|
{
|
@@ -98,17 +99,14 @@ module Hetzner
|
|
98
99
|
direction: 'in',
|
99
100
|
protocol: 'tcp',
|
100
101
|
port: '6443',
|
101
|
-
source_ips:
|
102
|
-
'0.0.0.0/0',
|
103
|
-
'::/0'
|
104
|
-
],
|
102
|
+
source_ips: api_networks,
|
105
103
|
destination_ips: []
|
106
104
|
}
|
107
105
|
end
|
108
106
|
|
109
107
|
{
|
110
108
|
name: cluster_name,
|
111
|
-
rules:
|
109
|
+
rules: rules
|
112
110
|
}
|
113
111
|
end
|
114
112
|
|
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
module Hetzner
|
4
4
|
class Network
|
5
|
-
def initialize(hetzner_client:, cluster_name:)
|
5
|
+
def initialize(hetzner_client:, cluster_name:, existing_network:)
|
6
6
|
@hetzner_client = hetzner_client
|
7
7
|
@cluster_name = cluster_name
|
8
|
+
@existing_network = existing_network
|
8
9
|
end
|
9
10
|
|
10
11
|
def create(location:)
|
@@ -29,9 +30,13 @@ module Hetzner
|
|
29
30
|
|
30
31
|
def delete
|
31
32
|
if (network = find_network)
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
if network['name'] == existing_network
|
34
|
+
puts 'Network existed before cluster, skipping.'
|
35
|
+
else
|
36
|
+
puts 'Deleting network...'
|
37
|
+
hetzner_client.delete('/networks', network['id'])
|
38
|
+
puts '...network deleted.'
|
39
|
+
end
|
35
40
|
else
|
36
41
|
puts 'Network no longer exists, skipping.'
|
37
42
|
end
|
@@ -39,9 +44,18 @@ module Hetzner
|
|
39
44
|
puts
|
40
45
|
end
|
41
46
|
|
47
|
+
def find_network
|
48
|
+
network_name = existing_network || cluster_name
|
49
|
+
hetzner_client.get('/networks')['networks'].detect { |network| network['name'] == network_name }
|
50
|
+
end
|
51
|
+
|
52
|
+
def get
|
53
|
+
find_network
|
54
|
+
end
|
55
|
+
|
42
56
|
private
|
43
57
|
|
44
|
-
attr_reader :hetzner_client, :cluster_name, :location
|
58
|
+
attr_reader :hetzner_client, :cluster_name, :location, :existing_network
|
45
59
|
|
46
60
|
def network_config
|
47
61
|
{
|
@@ -56,9 +70,5 @@ module Hetzner
|
|
56
70
|
]
|
57
71
|
}
|
58
72
|
end
|
59
|
-
|
60
|
-
def find_network
|
61
|
-
hetzner_client.get('/networks')['networks'].detect { |network| network['name'] == cluster_name }
|
62
|
-
end
|
63
73
|
end
|
64
74
|
end
|
data/lib/hetzner/infra/server.rb
CHANGED
@@ -37,7 +37,6 @@ module Hetzner
|
|
37
37
|
else
|
38
38
|
puts "Error creating server #{server_name}. Response details below:"
|
39
39
|
puts
|
40
|
-
p response
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -99,8 +98,8 @@ module Hetzner
|
|
99
98
|
def server_config
|
100
99
|
@server_config ||= {
|
101
100
|
name: server_name,
|
102
|
-
location
|
103
|
-
image
|
101
|
+
location: location,
|
102
|
+
image: image,
|
104
103
|
firewalls: [
|
105
104
|
{ firewall: firewall_id }
|
106
105
|
],
|
@@ -111,7 +110,7 @@ module Hetzner
|
|
111
110
|
ssh_keys: [
|
112
111
|
ssh_key_id
|
113
112
|
],
|
114
|
-
user_data
|
113
|
+
user_data: user_data,
|
115
114
|
labels: {
|
116
115
|
cluster: cluster_name,
|
117
116
|
role: (server_name =~ /master/ ? 'master' : 'worker')
|