Sha256: 205491b7d97e549e7a75f94ddb53c5fad9a629d33d68f05679dbcbfcb1069f79

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Metatron
  module Templates
    # Template for basic StatefulSet k8s resource
    class StatefulSet < Template
      include Concerns::Annotated
      include Concerns::PodProducer
      include Concerns::Namespaced

      attr_accessor :replicas, :service_name, :pod_management_policy, :update_strategy

      def initialize(name, replicas: 1)
        super(name)
        @replicas = replicas
        @api_version = "apps/v1"
        @pod_management_policy = "OrderedReady"
        @service_name = name
      end

      alias enableServiceLinks enable_service_links
      alias podManagementPolicy pod_management_policy
      alias serviceName service_name
      alias strategy update_strategy
      alias strategy= update_strategy=
      alias updateStrategy update_strategy

      def render # rubocop:disable Metrics/AbcSize
        {
          apiVersion:,
          kind:,
          metadata: {
            name:,
            labels: { "#{label_namespace}/name": name }.merge(additional_labels)
          }.merge(formatted_annotations).merge(formatted_namespace),
          spec: {
            replicas:,
            serviceName:,
            updateStrategy:,
            selector: {
              matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
            }
          }.merge(pod_template).merge(volume_claim_templates).compact
        }
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
metatron-0.6.0 lib/metatron/templates/stateful_set.rb
metatron-0.5.0 lib/metatron/templates/stateful_set.rb
metatron-0.4.2 lib/metatron/templates/stateful_set.rb
metatron-0.4.1 lib/metatron/templates/stateful_set.rb
metatron-0.4.0 lib/metatron/templates/stateful_set.rb
metatron-0.3.4 lib/metatron/templates/stateful_set.rb
metatron-0.3.3 lib/metatron/templates/stateful_set.rb
metatron-0.3.2 lib/metatron/templates/stateful_set.rb
metatron-0.3.1 lib/metatron/templates/stateful_set.rb
metatron-0.3.0 lib/metatron/templates/stateful_set.rb
metatron-0.2.8 lib/metatron/templates/stateful_set.rb
metatron-0.2.7 lib/metatron/templates/stateful_set.rb
metatron-0.2.6 lib/metatron/templates/stateful_set.rb
metatron-0.2.5 lib/metatron/templates/stateful_set.rb