Class: Porkadot::Configs::EtcdNode
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from CertsUtils
#certs_root_dir, #ipaddr?
#asset_path, #config, #logger, #method_missing, #raw, #respond_to_missing?, #secrets_path
Constructor Details
#initialize(config, name, raw) ⇒ EtcdNode
Returns a new instance of EtcdNode.
27
28
29
30
31
32
|
# File 'lib/porkadot/configs/etcd.rb', line 27
def initialize config, name, raw
@config = config
@kubelet = config.nodes[name]
@name = name
@raw = raw || ::Porkadot::Raw.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Porkadot::ConfigUtils
Instance Attribute Details
#kubelet ⇒ Object
Returns the value of attribute kubelet.
24
25
26
|
# File 'lib/porkadot/configs/etcd.rb', line 24
def kubelet
@kubelet
end
|
#name ⇒ Object
Returns the value of attribute name.
25
26
27
|
# File 'lib/porkadot/configs/etcd.rb', line 25
def name
@name
end
|
Instance Method Details
#additional_sans ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/porkadot/configs/etcd.rb', line 107
def additional_sans
sans = []
[self.member_name, self.member_address].each do |san|
if self.ipaddr?(san)
sans << "IP:#{san}"
else
sans << "DNS:#{san}"
end
end
sans << "IP:127.0.0.1"
return sans
end
|
#advertise_client_urls ⇒ Object
69
70
71
|
# File 'lib/porkadot/configs/etcd.rb', line 69
def advertise_client_urls
["https://#{member_address}:2379"]
end
|
#advertise_peer_urls ⇒ Object
73
74
75
|
# File 'lib/porkadot/configs/etcd.rb', line 73
def advertise_peer_urls
["https://#{member_address}:2380"]
end
|
#ca_crt_path ⇒ Object
128
129
130
|
# File 'lib/porkadot/configs/etcd.rb', line 128
def ca_crt_path
File.join(self.target_secrets_path, 'ca.crt')
end
|
#etcd_crt_path ⇒ Object
136
137
138
|
# File 'lib/porkadot/configs/etcd.rb', line 136
def etcd_crt_path
File.join(self.target_secrets_path, 'etcd.crt')
end
|
#etcd_key_path ⇒ Object
132
133
134
|
# File 'lib/porkadot/configs/etcd.rb', line 132
def etcd_key_path
File.join(self.target_secrets_path, 'etcd.key')
end
|
#initial_cluster ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/porkadot/configs/etcd.rb', line 99
def initial_cluster
return {}.tap do |rtn|
self.config.etcd_nodes.each do |_, v|
rtn[v.member_name] = "https://#{v.member_address}:2380"
end
end
end
|
#listen_address(label_key) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/porkadot/configs/etcd.rb', line 42
def listen_address label_key
listen_address = nil
if self.raw.labels
listen_address = self.raw.labels[label_key] || self.raw.labels[Porkadot::ETCD_LISTEN_ADDRESS_LABEL]
end
if !listen_adress
if self.ipaddr?(self.raw.hostname)
listen_address = self.raw.hostname
elsif self.ipaddr?(self.raw.name)
listen_address = self.raw.name
else
listen_address = '0.0.0.0'
end
end
return listen_address
end
|
#listen_client_address ⇒ Object
#listen_client_urls ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/porkadot/configs/etcd.rb', line 77
def listen_client_urls
address = self.listen_client_address
if address != '0.0.0.0'
return ["https://#{address}:2379", "https://127.0.0.1:2379"]
else
return ["https://#{address}:2379"]
end
end
|
#listen_metrics_urls ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'lib/porkadot/configs/etcd.rb', line 90
def listen_metrics_urls
address = self.listen_client_address
if address != '0.0.0.0'
return ["http://#{address}:2381", "http://127.0.0.1:2381"]
else
return ["http://#{address}:2381"]
end
end
|
#listen_peer_address ⇒ Object
#listen_peer_urls ⇒ Object
86
87
88
|
# File 'lib/porkadot/configs/etcd.rb', line 86
def listen_peer_urls
["https://#{self.listen_client_address}:2380"]
end
|
#member_address ⇒ Object
38
39
40
|
# File 'lib/porkadot/configs/etcd.rb', line 38
def member_address
return (self.raw.labels && self.raw.labels[Porkadot::ETCD_ADDRESS_LABEL]) || self.raw.hostname || self.name
end
|
#member_name ⇒ Object
34
35
36
|
# File 'lib/porkadot/configs/etcd.rb', line 34
def member_name
return (self.raw.labels && self.raw.labels[Porkadot::ETCD_MEMBER_LABEL]) || self.raw.hostname || self.name
end
|
#target_path ⇒ Object
120
121
122
|
# File 'lib/porkadot/configs/etcd.rb', line 120
def target_path
File.join(self.kubelet.addon_path, 'etcd')
end
|
#target_secrets_path ⇒ Object
124
125
126
|
# File 'lib/porkadot/configs/etcd.rb', line 124
def target_secrets_path
File.join(self.kubelet.addon_secrets_path, 'etcd')
end
|