Class: Porkadot::Cmd::Cli

Inherits:
Thor
  • Object
show all
Includes:
Utils
Defined in:
lib/porkadot/cmd/cli.rb

Instance Method Summary collapse

Methods included from Utils

#config, #logger

Instance Method Details

#allObject



83
84
85
86
# File 'lib/porkadot/cmd/cli.rb', line 83

def all
  invoke :render, [], options
  invoke :install, [], options
end

#set_configObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/porkadot/cmd/cli.rb', line 60

def set_config
  name = config.k8s.cluster_name
  certs = Porkadot::Assets::Certs.new(config)
  `kubectl config set-cluster #{name} \
    --server=https://#{config.k8s.control_plane_endpoint}`
  `kubectl config set \
    clusters.#{name}.certificate-authority-data \
    "#{certs.kubernetes.to_base64(:ca_cert)}"`
  `kubectl config set-credentials #{name}-admin`
  `kubectl config set \
    users.#{name}-admin.client-certificate-data \
    "#{certs.kubernetes.to_base64(:client_cert)}"`
  `kubectl config set \
    users.#{name}-admin.client-key-data \
    "#{certs.kubernetes.to_base64(:client_key)}"`
  `kubectl config set-context #{name} \
    --cluster=#{name} \
    --user=#{name}-admin`
  `kubectl config use-context #{name}`
end

#setup_containerdObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/porkadot/cmd/cli.rb', line 23

def setup_containerd
  logger.info "Setup containerd"
  kubelets = Porkadot::Install::KubeletList.new(self.config)
  nodes = []
  if node = options[:node]
    nodes = kubelets[node]
  elsif options[:bootstrap]
    bootstrap = Porkadot::Install::Bootstrap.new(self.config)
    nodes = bootstrap.host
  else
    nodes = kubelets.kubelets.values
  end
  kubelets.setup_containerd hosts: nodes, force: options[:force]
  ""
end

#setup_nodeObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/porkadot/cmd/cli.rb', line 43

def setup_node
  logger.info "Setup node default"
  kubelets = Porkadot::Install::KubeletList.new(self.config)
  nodes = []
  if node = options[:node]
    nodes = kubelets[node]
  elsif options[:bootstrap]
    bootstrap = Porkadot::Install::Bootstrap.new(self.config)
    nodes = bootstrap.host
  else
    nodes = kubelets.kubelets.values
  end
  kubelets.setup_default hosts: nodes, force: options[:force]
  ""
end