Files
ubicloud/rhizome/kubernetes/bin/join-node
mohi-kalantari c89ec92275 Start listening on ipv6 ip of nodes in control plane nodes
So far, we only listened on the IPv4 IP of nodes, creating the k8s
apiserver load balancer in IPv4 mode. From now on, we will also listen
on the IPv6 IP, making the LB dual stack.
2025-04-30 16:30:24 +02:00

74 lines
1.7 KiB
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
require "json"
require "yaml"
require_relative "../../common/lib/util"
params = JSON.parse($stdin.read)
begin
is_control_plane = params.fetch("is_control_plane")
endpoint = params.fetch("endpoint")
join_token = params.fetch("join_token")
discovery_token_ca_cert_hash = params.fetch("discovery_token_ca_cert_hash")
node_name = params.fetch("node_name")
node_ipv4 = params.fetch("node_ipv4")
node_ipv6 = params.fetch("node_ipv6")
if is_control_plane
certificate_key = params.fetch("certificate_key")
end
rescue KeyError => e
puts "Needed #{e.key} in parameters"
exit 1
end
config = {
"apiVersion" => "kubeadm.k8s.io/v1beta4",
"kind" => "JoinConfiguration",
"discovery" => {
"bootstrapToken" => {
"token" => join_token,
"apiServerEndpoint" => endpoint,
"caCertHashes" => [discovery_token_ca_cert_hash]
}
},
"nodeRegistration" => {
"name" => node_name,
"kubeletExtraArgs" => [
{
"name" => "node-ip",
"value" => "#{node_ipv4},#{node_ipv6}"
}
]
}
}
if is_control_plane
config["controlPlane"] = {
"certificateKey" => certificate_key,
"localAPIEndpoint" => {
"advertiseAddress" => node_ipv4,
"bindPort" => 6443
},
"apiServer" => {
"extraArgs" => [
{
"name" => "bind-address",
"value" => "::"
},
{
"name" => "advertise-address",
"value" => node_ipv4
}
]
}
}
end
config_path = "/tmp/join-config.yaml"
safe_write_to_file(config_path, config.to_yaml)
r("kubeadm join --config #{config_path}")
r("sudo /home/ubi/kubernetes/bin/setup-cni")