Class: Nvoi::Cli::Deploy::Steps::SetupK3s
- Inherits:
-
Object
- Object
- Nvoi::Cli::Deploy::Steps::SetupK3s
- Defined in:
- lib/nvoi/cli/deploy/steps/setup_k3s.rb
Overview
SetupK3s handles K3s cluster installation and configuration
Instance Method Summary collapse
-
#initialize(config, provider, log, main_server_ip) ⇒ SetupK3s
constructor
A new instance of SetupK3s.
- #run ⇒ Object
Constructor Details
#initialize(config, provider, log, main_server_ip) ⇒ SetupK3s
Returns a new instance of SetupK3s.
9 10 11 12 13 14 |
# File 'lib/nvoi/cli/deploy/steps/setup_k3s.rb', line 9 def initialize(config, provider, log, main_server_ip) @config = config @provider = provider @log = log @main_server_ip = main_server_ip end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nvoi/cli/deploy/steps/setup_k3s.rb', line 16 def run @log.info "Setting up K3s cluster" # Find master server group master_group, master_config = find_master_group raise Errors::K8sError, "no master server group found" unless master_group # Setup K3s on master master_name = @config.namer.server_name(master_group, 1) master = @provider.find_server(master_name) raise Errors::K8sError, "master server not found: #{master_name}" unless master master_ssh = External::Ssh.new(master.public_ipv4, @config.ssh_key_path) # Provision master cluster_token, master_private_ip = provision_master(master_ssh, master_group, master_name, master.private_ipv4) # Setup workers @config.deploy.application.servers.each do |group_name, group_config| next if group_name == master_group next unless group_config count = group_config.count.positive? ? group_config.count : 1 (1..count).each do |i| worker_name = @config.namer.server_name(group_name, i) setup_worker(worker_name, group_name, cluster_token, master_private_ip, master_ssh) end end @log.success "K3s cluster setup complete" end |