hetzner-k3s 0.3.5 → 0.3.9

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: 59252c55a4a701b664c992d568121caaef5766cc28809e79484071ca018763ed
4
- data.tar.gz: 5101372e1ce68608087529423fb7f3f61fc31bcf0966398ab4116545011c39f9
3
+ metadata.gz: 9c3b95ba8775783388acc881cbffd928c3fb00d92b6e6a5369b2bbd47f163aae
4
+ data.tar.gz: 495ea16d040b3808cb069ef6b03cec04bd7e6dd8f3fe7e623e7e49a1e3dc6eb3
5
5
  SHA512:
6
- metadata.gz: ddc9b31b733f73d3e62c74b3b023d29009abb6c4e83a3504818d9bcb39657b379911dc3a00bac96c27e7c71477730e76ff42de5a09f68ab9a67f47920eac0018
7
- data.tar.gz: dcd457cecdb1643b516448c922678ff36c46f283cdc2889befda796ccde6d42cbf6e54d74609105cef62eb7523a255a392871f1d6853cc32f86a83f1e5abcb45
6
+ metadata.gz: 01a31eca33e328550f1583ff036c9002f8deb784bb76e0cb1e01df0677be9d678bfae1f619354bdb538ced6ba3a95bb5f03180429536c245e822372b452e82a7
7
+ data.tar.gz: aa92fef9440c4e85afe30bbecb86091f44d0cd693c71b44b141432199f1c710488f6b7dfbf0dd59658d8a9d341414c5c75ea5d162cff12b10949f22cd0ef1cda
data/Dockerfile CHANGED
@@ -3,6 +3,8 @@ FROM ruby:2.7.4-alpine
3
3
  RUN apk update --no-cache \
4
4
  && apk add build-base git openssh-client
5
5
 
6
+ COPY . .
7
+
6
8
  RUN gem install hetzner-k3s
7
9
 
8
10
  COPY entrypoint.sh /entrypoint.sh
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hetzner-k3s (0.3.5)
4
+ hetzner-k3s (0.3.9)
5
5
  bcrypt_pbkdf
6
6
  ed25519
7
7
  http
data/README.md CHANGED
@@ -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 create-cluster --config-file /cluster/test.yaml
41
+ docker run --rm -it -v ${PWD}:/cluster -v ${HOME}/.ssh:/tmp/.ssh vitobotta/hetzner-k3s:v0.3.8 create-cluster --config-file /cluster/test.yaml
42
42
  ```
43
43
 
44
44
  Replace `test.yaml` with the name of your config file.
@@ -72,6 +72,9 @@ It should hopefully be self explanatory; you can run `hetzner-k3s releases` to s
72
72
 
73
73
  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.
74
74
 
75
+ **Important**: The tool assignes the label `cluster` to each server it creates, with the clsuter name you specify in the config file, as the value. So please ensure you don't create unrelated servers in the same project having
76
+ the label `cluster=<cluster name>`, because otherwise they will be deleted if you delete the cluster. I recommend you create a separate Hetzner project for each cluster, see note at the end of this README for more details.
77
+
75
78
 
76
79
  If you set `masters.instance_count` to 1 then the tool will create a non highly available control plane; for production clusters you may want to set it to a number greater than 1. This number must be odd to avoid split brain issues with etcd and the recommended number is 3.
77
80
 
@@ -225,8 +228,25 @@ The other annotations should be self explanatory. You can find a list of the ava
225
228
  Once the cluster is ready you can create persistent volumes out of the box with the default storage class `hcloud-volumes`, since the Hetzner CSI driver is installed automatically. This will use Hetzner's block storage (based on Ceph so it's replicated and highly available) for your persistent volumes. Note that the minimum size of a volume is 10Gi. If you specify a smaller size for a volume, the volume will be created with a capacity of 10Gi anyway.
226
229
 
227
230
 
231
+ ## Keeping a project per cluster
232
+
233
+ I recommend that you create a separate Hetzner project for each cluster, because otherwise multiple clusters will attempt to create overlapping routes. I will make the pod cidr configurable in the future to avoid this, but I still recommend keeping clusters separated from each other. This way, if you want to delete a cluster with all the resources created for it, you can just delete the project.
234
+
235
+
228
236
  ## changelog
229
237
 
238
+ - 0.3.9
239
+ - Add command "version" to print the version of the tool in use
240
+
241
+ - 0.3.8
242
+ - Fix: added a check on a label to ensure that only servers that belong to the cluster are deleted from the project
243
+
244
+ - 0.3.7
245
+ - Ensure that the cluster name only contains lowercase letters, digits and dashes for compatibility with the cloud controller manager
246
+
247
+ - 0.3.6
248
+ - Retry SSH commands when IO errors occur
249
+
230
250
  - 0.3.5
231
251
  - Add descriptions for firewall rules
232
252
 
@@ -3,6 +3,7 @@ require "http"
3
3
  require "sshkey"
4
4
 
5
5
  require_relative "cluster"
6
+ require_relative "version"
6
7
 
7
8
  module Hetzner
8
9
  module K3s
@@ -11,6 +12,11 @@ module Hetzner
11
12
  true
12
13
  end
13
14
 
15
+ desc "version", "Print the version"
16
+ def version
17
+ puts Hetzner::K3s::VERSION
18
+ end
19
+
14
20
  desc "create-cluster", "Create a k3s cluster in Hetzner Cloud"
15
21
  option :config_file, required: true
16
22
 
@@ -110,7 +116,8 @@ module Hetzner
110
116
  end
111
117
 
112
118
  def validate_cluster_name
113
- errors << "Cluster name is an invalid format" unless configuration["cluster_name"] =~ /\A([A-Za-z0-9\-\_]+)\Z/
119
+ errors << "Cluster name is an invalid format (only lowercase letters, digits and dashes are allowed)" unless configuration["cluster_name"] =~ /\A[a-z\d-]+\z/
120
+ errors << "Ensure that the cluster name starts with a normal letter" unless configuration["cluster_name"] =~ /\A[a-z]+.*\z/
114
121
  end
115
122
 
116
123
  def validate_kubeconfig_path
@@ -457,7 +457,7 @@ class Cluster
457
457
 
458
458
  puts "...server #{server_name} is now up."
459
459
  end
460
- rescue Errno::ENETUNREACH, Errno::EHOSTUNREACH, Timeout::Error
460
+ rescue Errno::ENETUNREACH, Errno::EHOSTUNREACH, Timeout::Error, IOError
461
461
  retry
462
462
  end
463
463
 
@@ -501,7 +501,7 @@ class Cluster
501
501
  end
502
502
 
503
503
  def all_servers
504
- @all_servers ||= hetzner_client.get("/servers")["servers"]
504
+ @all_servers ||= hetzner_client.get("/servers")["servers"].select{ |server| belongs_to_cluster?(server) == true }
505
505
  end
506
506
 
507
507
  def masters
@@ -624,4 +624,8 @@ class Cluster
624
624
  temp_file_path
625
625
  end
626
626
 
627
+ def belongs_to_cluster?(server)
628
+ server.dig("labels", "cluster") == cluster_name
629
+ end
630
+
627
631
  end
@@ -1,5 +1,5 @@
1
1
  module Hetzner
2
2
  module K3s
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hetzner-k3s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vito Botta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-17 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor