Class: Pangea::Kubernetes::Types::ClusterConfig

Inherits:
Resources::BaseAttributes
  • Object
show all
Defined in:
lib/pangea/kubernetes/types.rb

Overview

Cluster-level configuration — cloud-agnostic

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(attributes) ⇒ Object



421
422
423
424
425
# File 'lib/pangea/kubernetes/types.rb', line 421

def self.new(attributes)
  instance = super
  instance.vpn&.validate! if instance.vpn
  instance
end

Instance Method Details

#managed_kubernetes?Boolean

Returns:

  • (Boolean)


405
406
407
# File 'lib/pangea/kubernetes/types.rb', line 405

def managed_kubernetes?
  MANAGED_BACKENDS.include?(backend)
end

#nixos_backend?Boolean

Returns:

  • (Boolean)


409
410
411
# File 'lib/pangea/kubernetes/types.rb', line 409

def nixos_backend?
  NIXOS_BACKENDS.include?(backend)
end

#system_node_poolObject



413
414
415
# File 'lib/pangea/kubernetes/types.rb', line 413

def system_node_pool
  node_pools.find { |np| np.name == :system } || node_pools.first
end

#to_hObject



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/pangea/kubernetes/types.rb', line 427

def to_h
  hash = {
    backend: backend,
    kubernetes_version: kubernetes_version,
    region: region,
    node_pools: node_pools.map(&:to_h)
  }
  hash[:network] = network.to_h if network
  hash[:addons] = addons if addons.any?
  hash[:tags] = tags if tags.any?
  hash[:encryption_at_rest] = encryption_at_rest
  hash[:logging] = logging if logging.any?
  hash[:distribution] = distribution
  hash[:profile] = profile
  hash[:distribution_track] = distribution_track if distribution_track
  hash[:fluxcd] = fluxcd.to_h if fluxcd
  hash[:nixos] = nixos.to_h if nixos
  hash[:vpn] = vpn.to_h if vpn && vpn.links.any?
  hash[:persistent_state] = persistent_state.to_h if persistent_state
  hash[:role_arn] = role_arn if role_arn
  hash[:ami_id] = ami_id if ami_id
  hash[:ssm_ami_parameter] = ssm_ami_parameter if ssm_ami_parameter
  hash[:key_pair] = key_pair if key_pair
  hash[:project] = project if project
  hash[:gce_image] = gce_image if gce_image
  hash[:resource_group_name] = resource_group_name if resource_group_name
  hash[:dns_prefix] = dns_prefix if dns_prefix
  hash[:azure_image_id] = azure_image_id if azure_image_id
  hash
end

#worker_node_poolsObject



417
418
419
# File 'lib/pangea/kubernetes/types.rb', line 417

def worker_node_pools
  node_pools.reject { |np| np.name == :system }
end