Service Port
Here's the most important attributes:
-
name -
string
- The name of this port within the service, must be a
DNS_LABEL
. All ports within aServiceSpec
must have unique names. - Optional if only one
ServicePort
is defined.
- The name of this port within the service, must be a
-
nodePort -
integer
- The port on each node on which this service is exposed when
type
isNodePort
orLoadBalancer
. Usually assigned by the system. - If specified, the value must be in-range and not in use, otherwise the operation will fail.
- If not specified, a port will be allocated if required.
- This field is cleared when updating a Service to no longer need it (e.g., changing
type
fromNodePort
toClusterIP
).
- The port on each node on which this service is exposed when
-
port -
integer
- The port that will be exposed by this service.
-
targetPort -
integer | string
- The port number or name 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 specified as a string, it will be looked up as a named port in the target Pod's container ports. - If not specified, the value of the
port
field is used. - This field is ignored for services with
clusterIP=None
, and should be omitted or set equal to theport
field.