Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vitobotta/hetzner-k3s
Browse files Browse the repository at this point in the history
  • Loading branch information
vitobotta committed Sep 22, 2023
2 parents 2dd01a8 + ef64d1a commit a40406c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ worker_node_pools:
# kube_proxy_args:
# - arg1
# - ...
# api_server_hostname: k8s.example.com # optional: DNS for the k8s API LoadBalancer. After the script has run, create a DNS record with the address of the API LoadBalancer.
```

Most settings should be self explanatory; you can run `hetzner-k3s releases` to see a list of the available k3s releases.
Expand Down
1 change: 1 addition & 0 deletions src/configuration/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Configuration::Main
getter use_ssh_agent : Bool = false
getter ssh_allowed_networks : Array(String) = [] of String
getter api_allowed_networks : Array(String) = [] of String
getter api_server_hostname : String?
getter enable_public_net_ipv4 : Bool = true
getter enable_public_net_ipv6 : Bool = true
getter verify_host_key : Bool = false
Expand Down
7 changes: 6 additions & 1 deletion src/hetzner/load_balancer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ class Hetzner::LoadBalancer

property id : Int32
property name : String
property private_net : Array(Hetzner::Ipv4)
getter public_net : PublicNet?

def public_ip_address
public_net.try(&.ipv4).try(&.ip)
end

def private_ip_address
private_net[0].try(&.ip)
end
end
5 changes: 4 additions & 1 deletion src/kubernetes/installer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class Kubernetes::Installer
puts "Saving the kubeconfig file to #{kubeconfig_path}..."

kubeconfig = ssh.run(first_master, settings.ssh_port, "cat /etc/rancher/k3s/k3s.yaml", settings.use_ssh_agent, print_output: false).
gsub("127.0.0.1", api_server_ip_address).
gsub("127.0.0.1", settings.api_server_hostname ? settings.api_server_hostname : api_server_ip_address).
gsub("default", settings.cluster_name)

File.write(kubeconfig_path, kubeconfig)
Expand Down Expand Up @@ -360,6 +360,9 @@ class Kubernetes::Installer

private def generate_tls_sans
sans = ["--tls-san=#{api_server_ip_address}"]
sans << "--tls-san=#{settings.api_server_hostname}" if settings.api_server_hostname
sans << "--tls-san=#{load_balancer.not_nil!.private_ip_address}" if masters.size > 1

masters.each do |master|
master_private_ip = master.private_ip_address
sans << "--tls-san=#{master_private_ip}"
Expand Down
2 changes: 1 addition & 1 deletion templates/cluster_autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ spec:
- key: node-role.kubernetes.io/master
operator: Exists
containers:
- image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.26.3
- image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.27.3
name: cluster-autoscaler
resources:
limits:
Expand Down

0 comments on commit a40406c

Please sign in to comment.