Class: Kubernetes::V1ServiceSpec
- Inherits:
-
Object
- Object
- Kubernetes::V1ServiceSpec
- Defined in:
- lib/kubernetes/models/v1_service_spec.rb
Overview
ServiceSpec describes the attributes that a user creates on a service.
Instance Attribute Summary collapse
-
#cluster_ip ⇒ Object
clusterIP is the IP address of the service and is usually assigned randomly by the master.
-
#external_i_ps ⇒ Object
externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service.
-
#external_name ⇒ Object
externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service.
-
#external_traffic_policy ⇒ Object
externalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints.
-
#health_check_node_port ⇒ Object
healthCheckNodePort specifies the healthcheck nodePort for the service.
-
#load_balancer_ip ⇒ Object
Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field.
-
#load_balancer_source_ranges ⇒ Object
If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs.
-
#ports ⇒ Object
The list of ports that are exposed by this service.
-
#publish_not_ready_addresses ⇒ Object
publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service.
-
#selector ⇒ Object
Route service traffic to pods with label keys and values matching this selector.
-
#session_affinity ⇒ Object
Supports "ClientIP" and "None".
-
#session_affinity_config ⇒ Object
sessionAffinityConfig contains the configurations of session affinity.
-
#type ⇒ Object
type determines how the Service is exposed.
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 = {}) ⇒ V1ServiceSpec
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 = {}) ⇒ V1ServiceSpec
Initializes the object
97 98 99 100 101 102 103 104 105 106 107 108 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 143 144 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 97 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.transform_keys(&:to_sym) self.cluster_ip = attributes[:clusterIP] if attributes.key?(:clusterIP) if attributes.key?(:externalIPs) && (value = attributes[:externalIPs]).is_a?(Array) self.external_i_ps = value end self.external_name = attributes[:externalName] if attributes.key?(:externalName) if attributes.key?(:externalTrafficPolicy) self.external_traffic_policy = attributes[:externalTrafficPolicy] end if attributes.key?(:healthCheckNodePort) self.health_check_node_port = attributes[:healthCheckNodePort] end self.load_balancer_ip = attributes[:loadBalancerIP] if attributes.key?(:loadBalancerIP) if attributes.key?(:loadBalancerSourceRanges) && (value = attributes[:loadBalancerSourceRanges]).is_a?(Array) self.load_balancer_source_ranges = value end if attributes.key?(:ports) && (value = attributes[:ports]).is_a?(Array) self.ports = value end if attributes.key?(:publishNotReadyAddresses) self.publish_not_ready_addresses = attributes[:publishNotReadyAddresses] end if attributes.key?(:selector) && (value = attributes[:selector]).is_a?(Array) self.selector = value end self.session_affinity = attributes[:sessionAffinity] if attributes.key?(:sessionAffinity) if attributes.key?(:sessionAffinityConfig) self.session_affinity_config = attributes[:sessionAffinityConfig] end self.type = attributes[:type] if attributes.key?(:type) end |
Instance Attribute Details
#cluster_ip ⇒ Object
clusterIP is the IP address of the service and is usually assigned randomly by the master. If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are "None", empty string (""), or a valid IP address. "None" can be specified for headless services when proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
19 20 21 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 19 def cluster_ip @cluster_ip end |
#external_i_ps ⇒ Object
externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.
22 23 24 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 22 def external_i_ps @external_i_ps end |
#external_name ⇒ Object
externalName is the external reference that kubedns or equivalent will return as a CNAME record for this service. No proxying will be involved. Must be a valid RFC-1123 hostname (tools.ietf.org/html/rfc1123) and requires Type to be ExternalName.
25 26 27 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 25 def external_name @external_name end |
#external_traffic_policy ⇒ Object
externalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints. "Local" preserves the client source IP and avoids a second hop for LoadBalancer and Nodeport type services, but risks potentially imbalanced traffic spreading. "Cluster" obscures the client source IP and may cause a second hop to another node, but should have good overall load-spreading.
28 29 30 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 28 def external_traffic_policy @external_traffic_policy end |
#health_check_node_port ⇒ Object
healthCheckNodePort specifies the healthcheck nodePort for the service. If not specified, HealthCheckNodePort is created by the service api backend with the allocated nodePort. Will use user-specified nodePort value if specified by the client. Only effects when Type is set to LoadBalancer and ExternalTrafficPolicy is set to Local.
31 32 33 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 31 def health_check_node_port @health_check_node_port end |
#load_balancer_ip ⇒ Object
Only applies to Service Type: LoadBalancer LoadBalancer will get created with the IP specified in this field. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature.
34 35 36 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 34 def load_balancer_ip @load_balancer_ip end |
#load_balancer_source_ranges ⇒ Object
If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature." More info: kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/
37 38 39 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 37 def load_balancer_source_ranges @load_balancer_source_ranges end |
#ports ⇒ Object
The list of ports that are exposed by this service. More info: kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
40 41 42 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 40 def ports @ports end |
#publish_not_ready_addresses ⇒ Object
publishNotReadyAddresses, when set to true, indicates that DNS implementations must publish the notReadyAddresses of subsets for the Endpoints associated with the Service. The default value is false. The primary use case for setting this field is to use a StatefulSet’s Headless Service to propagate SRV records for its Pods without respect to their readiness for purpose of peer discovery.
43 44 45 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 43 def publish_not_ready_addresses @publish_not_ready_addresses end |
#selector ⇒ Object
Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: kubernetes.io/docs/concepts/services-networking/service/
46 47 48 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 46 def selector @selector end |
#session_affinity ⇒ Object
Supports "ClientIP" and "None". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
49 50 51 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 49 def session_affinity @session_affinity end |
#session_affinity_config ⇒ Object
sessionAffinityConfig contains the configurations of session affinity.
52 53 54 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 52 def session_affinity_config @session_affinity_config end |
#type ⇒ Object
type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. "ExternalName" maps to the specified externalName. "ClusterIP" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is "None", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. "NodePort" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. "LoadBalancer" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: kubernetes.io/docs/concepts/services-networking/service/#publishing-services—service-types
55 56 57 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 55 def type @type end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 58 def self.attribute_map { cluster_ip: :clusterIP, external_i_ps: :externalIPs, external_name: :externalName, external_traffic_policy: :externalTrafficPolicy, health_check_node_port: :healthCheckNodePort, load_balancer_ip: :loadBalancerIP, load_balancer_source_ranges: :loadBalancerSourceRanges, ports: :ports, publish_not_ready_addresses: :publishNotReadyAddresses, selector: :selector, session_affinity: :sessionAffinity, session_affinity_config: :sessionAffinityConfig, type: :type } end |
.swagger_types ⇒ Object
Attribute type mapping.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 77 def self.swagger_types { cluster_ip: :String, external_i_ps: :'Array<String>', external_name: :String, external_traffic_policy: :String, health_check_node_port: :Integer, load_balancer_ip: :String, load_balancer_source_ranges: :'Array<String>', ports: :'Array<V1ServicePort>', publish_not_ready_addresses: :BOOLEAN, selector: :'Hash<String, String>', session_affinity: :String, session_affinity_config: :V1SessionAffinityConfig, type: :String } end |
Instance Method Details
#==(other) ⇒ Object
Checks equality by comparing each attribute.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 160 def ==(other) return true if equal?(other) self.class == other.class && cluster_ip == other.cluster_ip && external_i_ps == other.external_i_ps && external_name == other.external_name && external_traffic_policy == other.external_traffic_policy && health_check_node_port == other.health_check_node_port && load_balancer_ip == other.load_balancer_ip && load_balancer_source_ranges == other.load_balancer_source_ranges && ports == other.ports && publish_not_ready_addresses == other.publish_not_ready_addresses && selector == other.selector && session_affinity == other.session_affinity && session_affinity_config == other.session_affinity_config && type == other.type end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
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 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 219 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
286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 286 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
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 195 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
181 182 183 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 181 def eql?(other) self == other end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
187 188 189 190 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 187 def hash [cluster_ip, external_i_ps, external_name, external_traffic_policy, health_check_node_port, load_balancer_ip, load_balancer_source_ranges, ports, publish_not_ready_addresses, selector, session_affinity, session_affinity_config, type].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
148 149 150 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 148 def list_invalid_properties [] end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
265 266 267 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 265 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
271 272 273 274 275 276 277 278 279 280 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 271 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
259 260 261 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 259 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
154 155 156 |
# File 'lib/kubernetes/models/v1_service_spec.rb', line 154 def valid? true end |