Class: Kubernetes::V1Container
- Inherits:
-
Object
- Object
- Kubernetes::V1Container
- Defined in:
- lib/kubernetes/models/v1_container.rb
Overview
A single application container that you want to run within a pod.
Instance Attribute Summary collapse
-
#args ⇒ Object
Arguments to the entrypoint.
-
#command ⇒ Object
Entrypoint array.
-
#env ⇒ Object
List of environment variables to set in the container.
-
#env_from ⇒ Object
List of sources to populate environment variables in the container.
-
#image ⇒ Object
Docker image name.
-
#image_pull_policy ⇒ Object
Image pull policy.
-
#lifecycle ⇒ Object
Actions that the management system should take in response to container lifecycle events.
-
#liveness_probe ⇒ Object
Periodic probe of container liveness.
-
#name ⇒ Object
Name of the container specified as a DNS_LABEL.
-
#ports ⇒ Object
List of ports to expose from the container.
-
#readiness_probe ⇒ Object
Periodic probe of container service readiness.
-
#resources ⇒ Object
Compute Resources required by this container.
-
#security_context ⇒ Object
Security options the pod should run with.
-
#stdin ⇒ Object
Whether this container should allocate a buffer for stdin in the container runtime.
-
#stdin_once ⇒ Object
Whether the container runtime should close the stdin channel after it has been opened by a single attach.
-
#termination_message_path ⇒ Object
Optional: Path at which the file to which the container’s termination message will be written is mounted into the container’s filesystem.
-
#termination_message_policy ⇒ Object
Indicate how the termination message should be populated.
-
#tty ⇒ Object
Whether this container should allocate a TTY for itself, also requires ‘stdin’ to be true.
-
#volume_devices ⇒ Object
volumeDevices is the list of block devices to be used by the container.
-
#volume_mounts ⇒ Object
Pod volumes to mount into the container’s filesystem.
-
#working_dir ⇒ Object
Container’s working directory.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ V1Container
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ V1Container
Initializes the object
137 138 139 140 141 142 143 144 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/kubernetes/models/v1_container.rb', line 137 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?(:args) && (value = attributes[:args]).is_a?(Array) self.args = value end if attributes.key?(:command) && (value = attributes[:command]).is_a?(Array) self.command = value end if attributes.key?(:env) && (value = attributes[:env]).is_a?(Array) self.env = value end if attributes.key?(:envFrom) && (value = attributes[:envFrom]).is_a?(Array) self.env_from = value end self.image = attributes[:image] if attributes.key?(:image) self.image_pull_policy = attributes[:imagePullPolicy] if attributes.key?(:imagePullPolicy) self.lifecycle = attributes[:lifecycle] if attributes.key?(:lifecycle) self.liveness_probe = attributes[:livenessProbe] if attributes.key?(:livenessProbe) self.name = attributes[:name] if attributes.key?(:name) if attributes.key?(:ports) && (value = attributes[:ports]).is_a?(Array) self.ports = value end self.readiness_probe = attributes[:readinessProbe] if attributes.key?(:readinessProbe) self.resources = attributes[:resources] if attributes.key?(:resources) self.security_context = attributes[:securityContext] if attributes.key?(:securityContext) self.stdin = attributes[:stdin] if attributes.key?(:stdin) self.stdin_once = attributes[:stdinOnce] if attributes.key?(:stdinOnce) if attributes.key?(:terminationMessagePath) self. = attributes[:terminationMessagePath] end if attributes.key?(:terminationMessagePolicy) self. = attributes[:terminationMessagePolicy] end self.tty = attributes[:tty] if attributes.key?(:tty) if attributes.key?(:volumeDevices) && (value = attributes[:volumeDevices]).is_a?(Array) self.volume_devices = value end if attributes.key?(:volumeMounts) && (value = attributes[:volumeMounts]).is_a?(Array) self.volume_mounts = value end self.working_dir = attributes[:workingDir] if attributes.key?(:workingDir) end |
Instance Attribute Details
#args ⇒ Object
Arguments to the entrypoint. The docker image’s CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
19 20 21 |
# File 'lib/kubernetes/models/v1_container.rb', line 19 def args @args end |
#command ⇒ Object
Entrypoint array. Not executed within a shell. The docker image’s ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container’s environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
22 23 24 |
# File 'lib/kubernetes/models/v1_container.rb', line 22 def command @command end |
#env ⇒ Object
List of environment variables to set in the container. Cannot be updated.
25 26 27 |
# File 'lib/kubernetes/models/v1_container.rb', line 25 def env @env end |
#env_from ⇒ Object
List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.
28 29 30 |
# File 'lib/kubernetes/models/v1_container.rb', line 28 def env_from @env_from end |
#image ⇒ Object
Docker image name. More info: kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.
31 32 33 |
# File 'lib/kubernetes/models/v1_container.rb', line 31 def image @image end |
#image_pull_policy ⇒ Object
Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: kubernetes.io/docs/concepts/containers/images#updating-images
34 35 36 |
# File 'lib/kubernetes/models/v1_container.rb', line 34 def image_pull_policy @image_pull_policy end |
#lifecycle ⇒ Object
Actions that the management system should take in response to container lifecycle events. Cannot be updated.
37 38 39 |
# File 'lib/kubernetes/models/v1_container.rb', line 37 def lifecycle @lifecycle end |
#liveness_probe ⇒ Object
Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
40 41 42 |
# File 'lib/kubernetes/models/v1_container.rb', line 40 def liveness_probe @liveness_probe end |
#name ⇒ Object
Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.
43 44 45 |
# File 'lib/kubernetes/models/v1_container.rb', line 43 def name @name end |
#ports ⇒ Object
List of ports to expose from the container. Exposing a port here gives the system additional information about the network connections a container uses, but is primarily informational. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default "0.0.0.0" address inside a container will be accessible from the network. Cannot be updated.
46 47 48 |
# File 'lib/kubernetes/models/v1_container.rb', line 46 def ports @ports end |
#readiness_probe ⇒ Object
Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
49 50 51 |
# File 'lib/kubernetes/models/v1_container.rb', line 49 def readiness_probe @readiness_probe end |
#resources ⇒ Object
Compute Resources required by this container. Cannot be updated. More info: kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
52 53 54 |
# File 'lib/kubernetes/models/v1_container.rb', line 52 def resources @resources end |
#security_context ⇒ Object
Security options the pod should run with. More info: kubernetes.io/docs/concepts/policy/security-context/ More info: kubernetes.io/docs/tasks/configure-pod-container/security-context/
55 56 57 |
# File 'lib/kubernetes/models/v1_container.rb', line 55 def security_context @security_context end |
#stdin ⇒ Object
Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.
58 59 60 |
# File 'lib/kubernetes/models/v1_container.rb', line 58 def stdin @stdin end |
#stdin_once ⇒ Object
Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false
61 62 63 |
# File 'lib/kubernetes/models/v1_container.rb', line 61 def stdin_once @stdin_once end |
#termination_message_path ⇒ Object
Optional: Path at which the file to which the container’s termination message will be written is mounted into the container’s filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.
64 65 66 |
# File 'lib/kubernetes/models/v1_container.rb', line 64 def end |
#termination_message_policy ⇒ Object
Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.
67 68 69 |
# File 'lib/kubernetes/models/v1_container.rb', line 67 def end |
#tty ⇒ Object
Whether this container should allocate a TTY for itself, also requires ‘stdin’ to be true. Default is false.
70 71 72 |
# File 'lib/kubernetes/models/v1_container.rb', line 70 def tty @tty end |
#volume_devices ⇒ Object
volumeDevices is the list of block devices to be used by the container. This is a beta feature.
73 74 75 |
# File 'lib/kubernetes/models/v1_container.rb', line 73 def volume_devices @volume_devices end |
#volume_mounts ⇒ Object
Pod volumes to mount into the container’s filesystem. Cannot be updated.
76 77 78 |
# File 'lib/kubernetes/models/v1_container.rb', line 76 def volume_mounts @volume_mounts end |
#working_dir ⇒ Object
Container’s working directory. If not specified, the container runtime’s default will be used, which might be configured in the container image. Cannot be updated.
79 80 81 |
# File 'lib/kubernetes/models/v1_container.rb', line 79 def working_dir @working_dir end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/kubernetes/models/v1_container.rb', line 82 def self.attribute_map { args: :args, command: :command, env: :env, env_from: :envFrom, image: :image, image_pull_policy: :imagePullPolicy, lifecycle: :lifecycle, liveness_probe: :livenessProbe, name: :name, ports: :ports, readiness_probe: :readinessProbe, resources: :resources, security_context: :securityContext, stdin: :stdin, stdin_once: :stdinOnce, termination_message_path: :terminationMessagePath, termination_message_policy: :terminationMessagePolicy, tty: :tty, volume_devices: :volumeDevices, volume_mounts: :volumeMounts, working_dir: :workingDir } end |
.swagger_types ⇒ Object
Attribute type mapping.
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 |
# File 'lib/kubernetes/models/v1_container.rb', line 109 def self.swagger_types { args: :'Array<String>', command: :'Array<String>', env: :'Array<V1EnvVar>', env_from: :'Array<V1EnvFromSource>', image: :String, image_pull_policy: :String, lifecycle: :V1Lifecycle, liveness_probe: :V1Probe, name: :String, ports: :'Array<V1ContainerPort>', readiness_probe: :V1Probe, resources: :V1ResourceRequirements, security_context: :V1SecurityContext, stdin: :BOOLEAN, stdin_once: :BOOLEAN, termination_message_path: :String, termination_message_policy: :String, tty: :BOOLEAN, volume_devices: :'Array<V1VolumeDevice>', volume_mounts: :'Array<V1VolumeMount>', working_dir: :String } end |
Instance Method Details
#==(other) ⇒ Object
Checks equality by comparing each attribute.
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 |
# File 'lib/kubernetes/models/v1_container.rb', line 223 def ==(other) return true if equal?(other) self.class == other.class && args == other.args && command == other.command && env == other.env && env_from == other.env_from && image == other.image && image_pull_policy == other.image_pull_policy && lifecycle == other.lifecycle && liveness_probe == other.liveness_probe && name == other.name && ports == other.ports && readiness_probe == other.readiness_probe && resources == other.resources && security_context == other.security_context && stdin == other.stdin && stdin_once == other.stdin_once && == other. && == other. && tty == other.tty && volume_devices == other.volume_devices && volume_mounts == other.volume_mounts && working_dir == other.working_dir end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
290 291 292 293 294 295 296 297 298 299 300 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 |
# File 'lib/kubernetes/models/v1_container.rb', line 290 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
357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/kubernetes/models/v1_container.rb', line 357 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
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/kubernetes/models/v1_container.rb', line 266 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
252 253 254 |
# File 'lib/kubernetes/models/v1_container.rb', line 252 def eql?(other) self == other end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
258 259 260 261 |
# File 'lib/kubernetes/models/v1_container.rb', line 258 def hash [args, command, env, env_from, image, image_pull_policy, lifecycle, liveness_probe, name, ports, readiness_probe, resources, security_context, stdin, stdin_once, , , tty, volume_devices, volume_mounts, working_dir].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
206 207 208 209 210 211 |
# File 'lib/kubernetes/models/v1_container.rb', line 206 def list_invalid_properties invalid_properties = [] invalid_properties.push("invalid value for 'name', name cannot be nil.") if @name.nil? invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
336 337 338 |
# File 'lib/kubernetes/models/v1_container.rb', line 336 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
342 343 344 345 346 347 348 349 350 351 |
# File 'lib/kubernetes/models/v1_container.rb', line 342 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_s ⇒ String
Returns the string representation of the object
330 331 332 |
# File 'lib/kubernetes/models/v1_container.rb', line 330 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
215 216 217 218 219 |
# File 'lib/kubernetes/models/v1_container.rb', line 215 def valid? return false if @name.nil? true end |