Class: Porkadot::Configs::Kubelet

Inherits:
Object
  • Object
show all
Includes:
Porkadot::ConfigUtils
Defined in:
lib/porkadot/configs/kubelet.rb

Direct Known Subclasses

Bootstrap::Kubelet

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Porkadot::ConfigUtils

#asset_path, #config, #logger, #method_missing, #raw, #respond_to_missing?, #secrets_path

Constructor Details

#initialize(config, name, raw) ⇒ Kubelet

Returns a new instance of Kubelet.



41
42
43
44
45
46
47
48
49
50
# File 'lib/porkadot/configs/kubelet.rb', line 41

def initialize config, name, raw
  @config = config
  @name = name
  @raw = raw || ::Porkadot::Raw.new
  hostname = @raw.hostname || name
  con = { hostname: hostname }
  gcon = config.connection.to_hash
  lcon = @raw.connection ? @raw.connection.to_hash : {}
  @connection = ::Porkadot::Raw.new(con.rmerge(gcon.rmerge(lcon)))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Porkadot::ConfigUtils

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



39
40
41
# File 'lib/porkadot/configs/kubelet.rb', line 39

def connection
  @connection
end

#nameObject (readonly)

Returns the value of attribute name.



38
39
40
# File 'lib/porkadot/configs/kubelet.rb', line 38

def name
  @name
end

Instance Method Details

#addon_pathObject



96
97
98
# File 'lib/porkadot/configs/kubelet.rb', line 96

def addon_path
  File.join(self.target_path, 'addons')
end

#addon_secrets_pathObject



100
101
102
# File 'lib/porkadot/configs/kubelet.rb', line 100

def addon_secrets_path
  File.join(self.target_secrets_path, 'addons')
end

#annotationsObject



69
70
71
# File 'lib/porkadot/configs/kubelet.rb', line 69

def annotations
  return self.raw.annotations || {}
end

#apiserver?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/porkadot/configs/kubelet.rb', line 52

def apiserver?
  self.raw.labels && self.raw.labels.include?(Porkadot::K8S_MASTER_LABEL)
end

#bootstrap_cert_pathObject



108
109
110
# File 'lib/porkadot/configs/kubelet.rb', line 108

def bootstrap_cert_path
  File.join(self.target_path, 'bootstrap.crt')
end

#bootstrap_key_pathObject



104
105
106
# File 'lib/porkadot/configs/kubelet.rb', line 104

def bootstrap_key_path
  File.join(self.target_secrets_path, 'bootstrap.key')
end

#control_plane_endpointObject



56
57
58
# File 'lib/porkadot/configs/kubelet.rb', line 56

def control_plane_endpoint
  (self.raw.kubernetes && self.raw.kubernetes.control_plane_endpoint) || self.config.k8s.control_plane_endpoint
end

#hostnameObject



84
85
86
# File 'lib/porkadot/configs/kubelet.rb', line 84

def hostname
  self.raw.hostname || self.name
end

#kubelet_configObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/porkadot/configs/kubelet.rb', line 73

def kubelet_config
  kc = self.raw.config || ::Porkadot::Raw.new
  kc = kc.merge(self.config.kubernetes.kubelet.config)
  kc.clusterDNS << self.config.k8s.networking.dns_ip.to_s
  kc.clusterDomain = self.config.k8s.networking.dns_domain
  if self.raw.taints
    kc.registerWithTaints = self.raw.taints
  end
  return kc
end

#labelsObject



65
66
67
# File 'lib/porkadot/configs/kubelet.rb', line 65

def labels
  return self.raw.labels || {}
end

#labels_stringObject



60
61
62
63
# File 'lib/porkadot/configs/kubelet.rb', line 60

def labels_string
  return '' unless self.raw.labels
  return self.raw.labels.map{|v| v.compact.join('=')}.join(',')
end

#target_pathObject



88
89
90
# File 'lib/porkadot/configs/kubelet.rb', line 88

def target_path
  File.join(self.config.assets_dir, 'kubelet', name)
end

#target_secrets_pathObject



92
93
94
# File 'lib/porkadot/configs/kubelet.rb', line 92

def target_secrets_path
  File.join(self.config.secrets_root_dir, 'kubelet', name)
end