Class: Kubernetes::V1PodSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/kubernetes/models/v1_pod_spec.rb

Overview

PodSpec is a description of a pod.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1PodSpec

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 182

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.transform_keys(&:to_sym)

  if attributes.key?(:activeDeadlineSeconds)
    self.active_deadline_seconds = attributes[:activeDeadlineSeconds]
  end

  self.affinity = attributes[:affinity] if attributes.key?(:affinity)

  if attributes.key?(:automountServiceAccountToken)
    self. = attributes[:automountServiceAccountToken]
  end

  if attributes.key?(:containers) && (value = attributes[:containers]).is_a?(Array)
    self.containers = value
  end

  self.dns_config = attributes[:dnsConfig] if attributes.key?(:dnsConfig)

  self.dns_policy = attributes[:dnsPolicy] if attributes.key?(:dnsPolicy)

  if attributes.key?(:enableServiceLinks)
    self.enable_service_links = attributes[:enableServiceLinks]
  end

  if attributes.key?(:hostAliases) && (value = attributes[:hostAliases]).is_a?(Array)
    self.host_aliases = value
  end

  self.host_ipc = attributes[:hostIPC] if attributes.key?(:hostIPC)

  self.host_network = attributes[:hostNetwork] if attributes.key?(:hostNetwork)

  self.host_pid = attributes[:hostPID] if attributes.key?(:hostPID)

  self.hostname = attributes[:hostname] if attributes.key?(:hostname)

  if attributes.key?(:imagePullSecrets) && (value = attributes[:imagePullSecrets]).is_a?(Array)
    self.image_pull_secrets = value
  end

  if attributes.key?(:initContainers) && (value = attributes[:initContainers]).is_a?(Array)
    self.init_containers = value
  end

  self.node_name = attributes[:nodeName] if attributes.key?(:nodeName)

  if attributes.key?(:nodeSelector) && (value = attributes[:nodeSelector]).is_a?(Array)
    self.node_selector = value
  end

  self.priority = attributes[:priority] if attributes.key?(:priority)

  if attributes.key?(:priorityClassName)
    self.priority_class_name = attributes[:priorityClassName]
  end

  if attributes.key?(:readinessGates) && (value = attributes[:readinessGates]).is_a?(Array)
    self.readiness_gates = value
  end

  self.restart_policy = attributes[:restartPolicy] if attributes.key?(:restartPolicy)

  self.runtime_class_name = attributes[:runtimeClassName] if attributes.key?(:runtimeClassName)

  self.scheduler_name = attributes[:schedulerName] if attributes.key?(:schedulerName)

  self.security_context = attributes[:securityContext] if attributes.key?(:securityContext)

  self. = attributes[:serviceAccount] if attributes.key?(:serviceAccount)

  if attributes.key?(:serviceAccountName)
    self. = attributes[:serviceAccountName]
  end

  if attributes.key?(:shareProcessNamespace)
    self.share_process_namespace = attributes[:shareProcessNamespace]
  end

  self.subdomain = attributes[:subdomain] if attributes.key?(:subdomain)

  if attributes.key?(:terminationGracePeriodSeconds)
    self.termination_grace_period_seconds = attributes[:terminationGracePeriodSeconds]
  end

  if attributes.key?(:tolerations) && (value = attributes[:tolerations]).is_a?(Array)
    self.tolerations = value
  end

  return unless attributes.key?(:volumes)
  return unless (value = attributes[:volumes]).is_a?(Array)

  self.volumes = value
end

Instance Attribute Details

#active_deadline_secondsObject

Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.



19
20
21
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 19

def active_deadline_seconds
  @active_deadline_seconds
end

#affinityObject

If specified, the pod’s scheduling constraints



22
23
24
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 22

def affinity
  @affinity
end

#automount_service_account_tokenObject

AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.



25
26
27
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 25

def 
  
end

#containersObject

List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated.



28
29
30
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 28

def containers
  @containers
end

#dns_configObject

Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.



31
32
33
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 31

def dns_config
  @dns_config
end

#dns_policyObject

Set DNS policy for the pod. Defaults to "ClusterFirst". Valid values are ‘ClusterFirstWithHostNet’, ‘ClusterFirst’, ‘Default’ or ‘None’. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to ‘ClusterFirstWithHostNet’.



34
35
36
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 34

def dns_policy
  @dns_policy
end

EnableServiceLinks indicates whether information about services should be injected into pod’s environment variables, matching the syntax of Docker links.



37
38
39
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 37

def enable_service_links
  @enable_service_links
end

#host_aliasesObject

HostAliases is an optional list of hosts and IPs that will be injected into the pod’s hosts file if specified. This is only valid for non-hostNetwork pods.



40
41
42
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 40

def host_aliases
  @host_aliases
end

#host_ipcObject

Use the host’s ipc namespace. Optional: Default to false.



43
44
45
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 43

def host_ipc
  @host_ipc
end

#host_networkObject

Host networking requested for this pod. Use the host’s network namespace. If this option is set, the ports that will be used must be specified. Default to false.



46
47
48
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 46

def host_network
  @host_network
end

#host_pidObject

Use the host’s pid namespace. Optional: Default to false.



49
50
51
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 49

def host_pid
  @host_pid
end

#hostnameObject

Specifies the hostname of the Pod If not specified, the pod’s hostname will be set to a system-defined value.



52
53
54
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 52

def hostname
  @hostname
end

#image_pull_secretsObject

ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod



55
56
57
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 55

def image_pull_secrets
  @image_pull_secrets
end

#init_containersObject

List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, or Liveness probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: kubernetes.io/docs/concepts/workloads/pods/init-containers/



58
59
60
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 58

def init_containers
  @init_containers
end

#node_nameObject

NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.



61
62
63
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 61

def node_name
  @node_name
end

#node_selectorObject

NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node’s labels for the pod to be scheduled on that node. More info: kubernetes.io/docs/concepts/configuration/assign-pod-node/



64
65
66
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 64

def node_selector
  @node_selector
end

#priorityObject

The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.



67
68
69
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 67

def priority
  @priority
end

#priority_class_nameObject

If specified, indicates the pod’s priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.



70
71
72
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 70

def priority_class_name
  @priority_class_name
end

#readiness_gatesObject

If specified, all readiness gates will be evaluated for pod readiness. A pod is ready when all its containers are ready AND all conditions specified in the readiness gates have status equal to "True" More info: github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md



73
74
75
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 73

def readiness_gates
  @readiness_gates
end

#restart_policyObject

Restart policy for all containers within the pod. One of Always, OnFailure, Never. Default to Always. More info: kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy



76
77
78
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 76

def restart_policy
  @restart_policy
end

#runtime_class_nameObject

RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the "legacy" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md This is an alpha feature and may change in the future.



79
80
81
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 79

def runtime_class_name
  @runtime_class_name
end

#scheduler_nameObject

If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.



82
83
84
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 82

def scheduler_name
  @scheduler_name
end

#security_contextObject

SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.



85
86
87
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 85

def security_context
  @security_context
end

#service_accountObject

DeprecatedServiceAccount is a depreciated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.



88
89
90
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 88

def 
  
end

#service_account_nameObject

ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/



91
92
93
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 91

def 
  
end

#share_process_namespaceObject

Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set. Optional: Default to false. This field is beta-level and may be disabled with the PodShareProcessNamespace feature.



94
95
96
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 94

def share_process_namespace
  @share_process_namespace
end

#subdomainObject

If specified, the fully qualified Pod hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>". If not specified, the pod will not have a domainname at all.



97
98
99
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 97

def subdomain
  @subdomain
end

#termination_grace_period_secondsObject

Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.



100
101
102
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 100

def termination_grace_period_seconds
  @termination_grace_period_seconds
end

#tolerationsObject

If specified, the pod’s tolerations.



103
104
105
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 103

def tolerations
  @tolerations
end

#volumesObject

List of volumes that can be mounted by containers belonging to the pod. More info: kubernetes.io/docs/concepts/storage/volumes



106
107
108
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 106

def volumes
  @volumes
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 109

def self.attribute_map
  {
    active_deadline_seconds: :activeDeadlineSeconds,
    affinity: :affinity,
    automount_service_account_token: :automountServiceAccountToken,
    containers: :containers,
    dns_config: :dnsConfig,
    dns_policy: :dnsPolicy,
    enable_service_links: :enableServiceLinks,
    host_aliases: :hostAliases,
    host_ipc: :hostIPC,
    host_network: :hostNetwork,
    host_pid: :hostPID,
    hostname: :hostname,
    image_pull_secrets: :imagePullSecrets,
    init_containers: :initContainers,
    node_name: :nodeName,
    node_selector: :nodeSelector,
    priority: :priority,
    priority_class_name: :priorityClassName,
    readiness_gates: :readinessGates,
    restart_policy: :restartPolicy,
    runtime_class_name: :runtimeClassName,
    scheduler_name: :schedulerName,
    security_context: :securityContext,
    service_account: :serviceAccount,
    service_account_name: :serviceAccountName,
    share_process_namespace: :shareProcessNamespace,
    subdomain: :subdomain,
    termination_grace_period_seconds: :terminationGracePeriodSeconds,
    tolerations: :tolerations,
    volumes: :volumes
  }
end

.swagger_typesObject

Attribute type mapping.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 145

def self.swagger_types
  {
    active_deadline_seconds: :Integer,
    affinity: :V1Affinity,
    automount_service_account_token: :BOOLEAN,
    containers: :'Array<V1Container>',
    dns_config: :V1PodDNSConfig,
    dns_policy: :String,
    enable_service_links: :BOOLEAN,
    host_aliases: :'Array<V1HostAlias>',
    host_ipc: :BOOLEAN,
    host_network: :BOOLEAN,
    host_pid: :BOOLEAN,
    hostname: :String,
    image_pull_secrets: :'Array<V1LocalObjectReference>',
    init_containers: :'Array<V1Container>',
    node_name: :String,
    node_selector: :'Hash<String, String>',
    priority: :Integer,
    priority_class_name: :String,
    readiness_gates: :'Array<V1PodReadinessGate>',
    restart_policy: :String,
    runtime_class_name: :String,
    scheduler_name: :String,
    security_context: :V1PodSecurityContext,
    service_account: :String,
    service_account_name: :String,
    share_process_namespace: :BOOLEAN,
    subdomain: :String,
    termination_grace_period_seconds: :Integer,
    tolerations: :'Array<V1Toleration>',
    volumes: :'Array<V1Volume>'
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 301

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    active_deadline_seconds == other.active_deadline_seconds &&
    affinity == other.affinity &&
     == other. &&
    containers == other.containers &&
    dns_config == other.dns_config &&
    dns_policy == other.dns_policy &&
    enable_service_links == other.enable_service_links &&
    host_aliases == other.host_aliases &&
    host_ipc == other.host_ipc &&
    host_network == other.host_network &&
    host_pid == other.host_pid &&
    hostname == other.hostname &&
    image_pull_secrets == other.image_pull_secrets &&
    init_containers == other.init_containers &&
    node_name == other.node_name &&
    node_selector == other.node_selector &&
    priority == other.priority &&
    priority_class_name == other.priority_class_name &&
    readiness_gates == other.readiness_gates &&
    restart_policy == other.restart_policy &&
    runtime_class_name == other.runtime_class_name &&
    scheduler_name == other.scheduler_name &&
    security_context == other.security_context &&
     == other. &&
     == other. &&
    share_process_namespace == other.share_process_namespace &&
    subdomain == other.subdomain &&
    termination_grace_period_seconds == other.termination_grace_period_seconds &&
    tolerations == other.tolerations &&
    volumes == other.volumes
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 377

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = Kubernetes.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 444

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 353

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        send("#{key}=", attributes[self.class.attribute_map[key]].map do |v|
                          _deserialize(Regexp.last_match(1), v)
                        end)
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


339
340
341
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 339

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



345
346
347
348
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 345

def hash
  [active_deadline_seconds, affinity, , containers, dns_config,
   dns_policy, enable_service_links, host_aliases, host_ipc, host_network, host_pid, hostname, image_pull_secrets, init_containers, node_name, node_selector, priority, priority_class_name, readiness_gates, restart_policy, runtime_class_name, scheduler_name, security_context, , , share_process_namespace, subdomain, termination_grace_period_seconds, tolerations, volumes].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



282
283
284
285
286
287
288
289
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 282

def list_invalid_properties
  invalid_properties = []
  if @containers.nil?
    invalid_properties.push("invalid value for 'containers', containers cannot be nil.")
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



423
424
425
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 423

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



429
430
431
432
433
434
435
436
437
438
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 429

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = send(attr)
    next if value.nil?

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



417
418
419
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 417

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



293
294
295
296
297
# File 'lib/kubernetes/models/v1_pod_spec.rb', line 293

def valid?
  return false if @containers.nil?

  true
end