Previously, we gave names like "clustername-control-plane-something" to k8s cluster nodes in CP side and let them default to VM inhost names in the DP side. This commit changes the node names to cluster and nodepool UBID based strings in CP and DP. The current format is something like {(cluster|nodepool).ubid}-{r4nd0}. Alternatively, we can provide VM ubids as names to k8s and use them. However, associating VMs with cluster or nodepools in the names seemed more intuitive to me. One technicality I couldn't figure out was the node name setting during init phase. I initially tried supplying the node name through `nodeRegistration.name` in the kubeadm-config.yaml, but couldn't make it work.
23 lines
730 B
Ruby
Executable File
23 lines
730 B
Ruby
Executable File
#!/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require "json"
|
|
require_relative "../../common/lib/util"
|
|
|
|
params = JSON.parse($stdin.read)
|
|
|
|
begin
|
|
cluster_endpoint = params.fetch("cluster_endpoint")
|
|
join_token = params.fetch("join_token")
|
|
discovery_token_ca_cert_hash = params.fetch("discovery_token_ca_cert_hash")
|
|
certificate_key = params.fetch("certificate_key")
|
|
node_name = params.fetch("node_name")
|
|
rescue KeyError => e
|
|
puts "Needed #{e.key} in parameters"
|
|
exit 1
|
|
end
|
|
|
|
r "kubeadm join #{cluster_endpoint} --control-plane --token #{join_token} --discovery-token-ca-cert-hash #{discovery_token_ca_cert_hash} --certificate-key #{certificate_key} --node-name #{node_name}"
|
|
|
|
r("sudo /home/ubi/kubernetes/bin/setup-cni")
|