Class: Porkadot::Configs::Kubernetes::Networking

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

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) ⇒ Networking

Returns a new instance of Networking.



241
242
243
244
# File 'lib/porkadot/configs/kubernetes.rb', line 241

def initialize config
  @config = config
  @raw = config.raw.kubernetes.networking
end

Dynamic Method Handling

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

Instance Method Details

#_pod_subnetObject



274
275
276
# File 'lib/porkadot/configs/kubernetes.rb', line 274

def _pod_subnet
  self.pod_subnet.split(",").map{|net| IPAddr.new(net)}
end

#default_service_subnetObject



256
257
258
# File 'lib/porkadot/configs/kubernetes.rb', line 256

def default_service_subnet
  self.service_subnet.split(',')[0]
end

#dns_ipObject



251
252
253
254
# File 'lib/porkadot/configs/kubernetes.rb', line 251

def dns_ip
  cluster_ip_range = IPAddr.new(self.default_service_subnet)
  cluster_ip_range.to_range.first(11)[10]
end

#kubernetes_ipObject



246
247
248
249
# File 'lib/porkadot/configs/kubernetes.rb', line 246

def kubernetes_ip
  cluster_ip_range = IPAddr.new(self.default_service_subnet)
  cluster_ip_range.to_range.first(2)[1]
end

#pod_v4subnetObject Also known as: enable_ipv4



260
261
262
263
264
# File 'lib/porkadot/configs/kubernetes.rb', line 260

def pod_v4subnet
  if ip = self._pod_subnet.find{ |net| net.ipv4? }
    return "#{ip.to_s}/#{ip.prefix}"
  end
end

#pod_v6subnetObject Also known as: enable_ipv6



267
268
269
270
271
# File 'lib/porkadot/configs/kubernetes.rb', line 267

def pod_v6subnet
  if ip = self._pod_subnet.find{ |net| net.ipv6? }
    return "#{ip.to_s}/#{ip.prefix}"
  end
end