Class: CDK8sPlus25::K8S::ServicePort
- Inherits:
-
Jsii::Struct
- Object
- Jsii::Struct
- CDK8sPlus25::K8S::ServicePort
- Defined in:
- k8_s/service_port.rb
Overview
ServicePort contains information on service's port.
Instance Attribute Summary collapse
-
#app_protocol ⇒ String?
readonly
The application protocol for this port.
-
#name ⇒ String?
readonly
The name of this port within the service.
-
#node_port ⇒ Numeric?
readonly
The port on each node on which this service is exposed when type is NodePort or LoadBalancer.
-
#port ⇒ Numeric
readonly
The port that will be exposed by this service.
-
#protocol ⇒ String?
readonly
The IP protocol for this port.
-
#target_port ⇒ CDK8sPlus25::K8S::IntOrString?
readonly
Number or name of the port to access on the pods targeted by the service.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(port:, app_protocol: nil, name: nil, node_port: nil, protocol: nil, target_port: nil) ⇒ ServicePort
constructor
A new instance of ServicePort.
- #to_jsii ⇒ Object
Constructor Details
#initialize(port:, app_protocol: nil, name: nil, node_port: nil, protocol: nil, target_port: nil) ⇒ ServicePort
Returns a new instance of ServicePort.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'k8_s/service_port.rb', line 13 def initialize(port:, app_protocol: nil, name: nil, node_port: nil, protocol: nil, target_port: nil) @port = port Jsii::Type.check_type(@port, "eyJwcmltaXRpdmUiOiJudW1iZXIifQ==", "port") @app_protocol = app_protocol Jsii::Type.check_type(@app_protocol, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "appProtocol") unless @app_protocol.nil? @name = name Jsii::Type.check_type(@name, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "name") unless @name.nil? @node_port = node_port Jsii::Type.check_type(@node_port, "eyJwcmltaXRpdmUiOiJudW1iZXIifQ==", "nodePort") unless @node_port.nil? @protocol = protocol Jsii::Type.check_type(@protocol, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "protocol") unless @protocol.nil? @target_port = target_port Jsii::Type.check_type(@target_port, "eyJmcW4iOiJjZGs4cy1wbHVzLTI1Lms4cy5JbnRPclN0cmluZyJ9", "targetPort") unless @target_port.nil? end |
Instance Attribute Details
#app_protocol ⇒ String? (readonly)
The application protocol for this port.
This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.
37 38 39 |
# File 'k8_s/service_port.rb', line 37 def app_protocol @app_protocol end |
#name ⇒ String? (readonly)
The name of this port within the service.
This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. When considering the endpoints for a Service, this must match the 'name' field in the EndpointPort. Optional if only one ServicePort is defined on this service.
43 44 45 |
# File 'k8_s/service_port.rb', line 43 def name @name end |
#node_port ⇒ Numeric? (readonly)
The port on each node on which this service is exposed when type is NodePort or LoadBalancer.
Usually assigned by the system. If a value is specified, in-range, and not in use it will be used, otherwise the operation will fail. If not specified, a port will be allocated if this Service requires one. If this field is specified when creating a Service which does not need it, creation will fail. This field will be wiped when updating a Service to no longer need it (e.g. changing type from NodePort to ClusterIP). More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
49 50 51 |
# File 'k8_s/service_port.rb', line 49 def node_port @node_port end |
#port ⇒ Numeric (readonly)
The port that will be exposed by this service.
31 32 33 |
# File 'k8_s/service_port.rb', line 31 def port @port end |
#protocol ⇒ String? (readonly)
Default: TCP.
The IP protocol for this port.
Supports "TCP", "UDP", and "SCTP". Default is TCP.
56 57 58 |
# File 'k8_s/service_port.rb', line 56 def protocol @protocol end |
#target_port ⇒ CDK8sPlus25::K8S::IntOrString? (readonly)
Number or name of the port to access on the pods targeted by the service.
Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
62 63 64 |
# File 'k8_s/service_port.rb', line 62 def target_port @target_port end |
Class Method Details
.jsii_properties ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'k8_s/service_port.rb', line 64 def self.jsii_properties { :port => "port", :app_protocol => "appProtocol", :name => "name", :node_port => "nodePort", :protocol => "protocol", :target_port => "targetPort", } end |
Instance Method Details
#to_jsii ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'k8_s/service_port.rb', line 75 def to_jsii result = {} result.merge!({ "port" => @port, "appProtocol" => @app_protocol, "name" => @name, "nodePort" => @node_port, "protocol" => @protocol, "targetPort" => @target_port, }) result.compact end |