Sha256: 65fb4a296fca2679fce94abf9b2d7b78245bca36c715915131c166522086e911
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Metatron module Templates # The Service Kubernetes resource class Service < Template include Concerns::Annotated include Concerns::Namespaced attr_accessor :type, :selector, :additional_labels, :ports, :additional_selector_labels, :publish_not_ready_addresses def initialize(name, port = nil) super(name) @type = "ClusterIP" @selector = base_labels @additional_labels = {} @additional_selector_labels = {} @publish_not_ready_addresses = false return unless port @ports = [ { port: port.to_i, targetPort: port.to_i, protocol: "TCP", name: } ] end alias publishNotReadyAddresses publish_not_ready_addresses def formatted_ports ports&.any? ? { ports: } : {} end def render { apiVersion:, kind:, metadata: { name:, labels: base_labels.merge(additional_labels) }.merge(formatted_annotations).merge(formatted_namespace), spec: { type:, selector: selector.merge(additional_selector_labels), publishNotReadyAddresses: }.merge(formatted_ports) } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems