Sha256: 00411c74ad3b946b1901817793d2483b72a63d5d99b9efb56d71f8c7560bd5ad

Contents?: true

Size: 1.5 KB

Versions: 13

Compression:

Stored size: 1.5 KB

Contents

require 'picsolve_docker_builder/helpers/kubernetes/resource'

module PicsolveDockerBuilder
  module Helpers
    module Kubernetes
      # A generic kuberntes resource
      class Service < Resource
        def config
          # workaround a bug on updating TODO: remove when fixed upstream
          @service.name = @image.name

          # configure the service
          @service.metadata = {} unless @service.metadata
          @service.metadata.name = @image.name
          @service.metadata.namespace = @image.composer.namespace
          @service.metadata.labels = template_labels
          @service.spec = {} unless @service.spec
          @service.spec.ports = @image.ports
          @service.spec.selector = {
            'name' => @image.name
          }
        end

        def deploy
          @existing = false
          begin
            @service = client.get_service @image.name, @image.composer.namespace
            @existing = true
          rescue KubeException
            @service = Kubeclient::Service.new
          end
          # config service
          config

          if @existing
            log.debug \
              "update service '#{@image.composer.namespace}/#{@image.name}' " \
              'on kubernetes'
            client.update_service @service
          else
            log.debug \
              "create service '#{@image.composer.namespace}/#{@image.name}' " \
              'on kubernetes'
            client.create_service @service
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
picsolve_docker_builder-0.5.5 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.5.4 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.5.3 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.5.2 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.5.1 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.5.0 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.4.0 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.3.2 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.3.1 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.3.0 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.2.0 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.1.1 lib/picsolve_docker_builder/helpers/kubernetes/service.rb
picsolve_docker_builder-0.1.0 lib/picsolve_docker_builder/helpers/kubernetes/service.rb