Class: Metatron::Templates::StatefulSet

Inherits:
Metatron::Template show all
Includes:
Concerns::Annotated, Concerns::Namespaced, Concerns::PodProducer
Defined in:
lib/metatron/templates/stateful_set.rb

Overview

Template for basic StatefulSet k8s resource

Instance Attribute Summary collapse

Attributes inherited from Metatron::Template

#additional_labels, #api_version, #kind, #label_namespace, #name

Instance Method Summary collapse

Methods included from Concerns::Namespaced

#formatted_namespace, included, #namespaced_initialize

Methods included from Concerns::PodProducer

#formatted_affinity, #formatted_containers, #formatted_image_pull_secrets, #formatted_init_containers, #formatted_node_selector, #formatted_pod_annotations, #formatted_security_context, #formatted_tolerations, #formatted_volumes, included, #pod_metadata, #pod_producer_initialize, #pod_spec, #pod_template, #volume_claim_templates

Methods included from Concerns::Annotated

#annotated_initialize, #formatted_annotations, included

Methods inherited from Metatron::Template

initializer, initializers, metatron_template_class?, nearest_metatron_ancestor

Constructor Details

#initialize(name, replicas: 1) ⇒ StatefulSet

Returns a new instance of StatefulSet.



13
14
15
16
17
18
19
# File 'lib/metatron/templates/stateful_set.rb', line 13

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

Instance Attribute Details

#pod_management_policyObject Also known as: podManagementPolicy

Returns the value of attribute pod_management_policy.



11
12
13
# File 'lib/metatron/templates/stateful_set.rb', line 11

def pod_management_policy
  @pod_management_policy
end

#replicasObject

Returns the value of attribute replicas.



11
12
13
# File 'lib/metatron/templates/stateful_set.rb', line 11

def replicas
  @replicas
end

#service_nameObject Also known as: serviceName

Returns the value of attribute service_name.



11
12
13
# File 'lib/metatron/templates/stateful_set.rb', line 11

def service_name
  @service_name
end

#update_strategyObject Also known as: strategy, updateStrategy

Returns the value of attribute update_strategy.



11
12
13
# File 'lib/metatron/templates/stateful_set.rb', line 11

def update_strategy
  @update_strategy
end

Instance Method Details

#renderObject

rubocop:disable Metrics/AbcSize



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/metatron/templates/stateful_set.rb', line 28

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