Class: Kube::Cluster::Standard::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/kube/cluster/standard/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(name:, ports:, namespace: "default", **options, &block) ⇒ Service

Returns a new instance of Service.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kube/cluster/standard/service.rb', line 10

def initialize(name:, ports:, namespace: "default", **options, &block)
  super() {
    .name = name
    .namespace = namespace
    .labels = { "app" => name }
    spec.selector = { "app" => name }
    spec.ports = ports.map do |port|
      { name: "http-#{port}", port: port, targetPort: port, protocol: "TCP" }
    end

    instance_exec(&block) if block_given?
  }
end