Skip to content

Commit fdceaa2

Browse files
author
Tim Bannister
committed
Avoid misleading text in Service concept
The existing text implied that creating a node port or load balanced Service would actually add an extra Service object that you could see in the Kubernetes API. This isn't true, so avoid implying that it is.
1 parent f620f5d commit fdceaa2

File tree

1 file changed

+55
-31
lines changed
  • content/en/docs/concepts/services-networking

1 file changed

+55
-31
lines changed

content/en/docs/concepts/services-networking/service.md

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -593,21 +593,18 @@ For some parts of your application (for example, frontends) you may want to expo
593593
Service onto an external IP address, that's outside of your cluster.
594594

595595
Kubernetes `ServiceTypes` allow you to specify what kind of Service you want.
596-
The default is `ClusterIP`.
597596

598597
`Type` values and their behaviors are:
599598

600599
* `ClusterIP`: Exposes the Service on a cluster-internal IP. Choosing this value
601600
makes the Service only reachable from within the cluster. This is the
602-
default `ServiceType`.
601+
default that is used if you don't explicitly specify a `type` for a Service.
603602
* [`NodePort`](#type-nodeport): Exposes the Service on each Node's IP at a static port
604-
(the `NodePort`). A `ClusterIP` Service, to which the `NodePort` Service
605-
routes, is automatically created. You'll be able to contact the `NodePort` Service,
606-
from outside the cluster,
607-
by requesting `<NodeIP>:<NodePort>`.
603+
(the `NodePort`).
604+
To make the node port available, Kubernetes sets up a cluster IP address,
605+
the same as if you had requested a Service of `type: ClusterIP`.
608606
* [`LoadBalancer`](#loadbalancer): Exposes the Service externally using a cloud
609-
provider's load balancer. `NodePort` and `ClusterIP` Services, to which the external
610-
load balancer routes, are automatically created.
607+
provider's load balancer.
611608
* [`ExternalName`](#externalname): Maps the Service to the contents of the
612609
`externalName` field (e.g. `foo.bar.example.com`), by returning a `CNAME` record
613610
with its value. No proxying of any kind is set up.
@@ -627,20 +624,18 @@ allocates a port from a range specified by `--service-node-port-range` flag (def
627624
Each node proxies that port (the same port number on every Node) into your Service.
628625
Your Service reports the allocated port in its `.spec.ports[*].nodePort` field.
629626

630-
If you want to specify particular IP(s) to proxy the port, you can set the
631-
`--nodeport-addresses` flag for kube-proxy or the equivalent `nodePortAddresses`
632-
field of the
633-
[kube-proxy configuration file](/docs/reference/config-api/kube-proxy-config.v1alpha1/)
634-
to particular IP block(s).
627+
Using a NodePort gives you the freedom to set up your own load balancing solution,
628+
to configure environments that are not fully supported by Kubernetes, or even
629+
to expose one or more nodes' IP addresses directly.
635630

636-
This flag takes a comma-delimited list of IP blocks (e.g. `10.0.0.0/8`, `192.0.2.0/25`)
637-
to specify IP address ranges that kube-proxy should consider as local to this node.
631+
For a node port Service, Kubernetes additionally allocates a port (TCP, UDP or
632+
SCTP to match the protocol of the Service). Every node in the cluster configures
633+
itself to listen on that assigned port and to forward traffic to one of the ready
634+
endpoints associated with that Service. You'll be able to contact the `type: NodePort`
635+
Service, from outside the cluster, by connecting to any node using the appropriate
636+
protocol (for example: TCP), and the appropriate port (as assigned to that Service).
638637

639-
For example, if you start kube-proxy with the `--nodeport-addresses=127.0.0.0/8` flag,
640-
kube-proxy only selects the loopback interface for NodePort Services.
641-
The default for `--nodeport-addresses` is an empty list.
642-
This means that kube-proxy should consider all available network interfaces for NodePort.
643-
(That's also compatible with earlier Kubernetes releases).
638+
#### Choosing your own port {#nodeport-custom-port}
644639

645640
If you want a specific port number, you can specify a value in the `nodePort`
646641
field. The control plane will either allocate you that port or report that
@@ -649,16 +644,8 @@ This means that you need to take care of possible port collisions yourself.
649644
You also have to use a valid port number, one that's inside the range configured
650645
for NodePort use.
651646

652-
Using a NodePort gives you the freedom to set up your own load balancing solution,
653-
to configure environments that are not fully supported by Kubernetes, or even
654-
to expose one or more nodes' IPs directly.
655-
656-
Note that this Service is visible as `<NodeIP>:spec.ports[*].nodePort`
657-
and `.spec.clusterIP:spec.ports[*].port`.
658-
If the `--nodeport-addresses` flag for kube-proxy or the equivalent field
659-
in the kube-proxy configuration file is set, `<NodeIP>` would be filtered node IP(s).
660-
661-
For example:
647+
Here is an example manifest for a Service of `type: NodePort` that specifies
648+
a NodePort value (30007, in this example).
662649

663650
```yaml
664651
apiVersion: v1
@@ -678,6 +665,33 @@ spec:
678665
nodePort: 30007
679666
```
680667
668+
#### Custom IP address configuration for `type: NodePort` Services {#service-nodeport-custom-listen-address}
669+
670+
You can set up nodes in your cluster to use a particular IP address for serving node port
671+
services. You might want to do this if each node is connected to multiple networks (for example:
672+
one network for application traffic, and another network for traffic between nodes and the
673+
control plane).
674+
675+
If you want to specify particular IP address(es) to proxy the port, you can set the
676+
`--nodeport-addresses` flag for kube-proxy or the equivalent `nodePortAddresses`
677+
field of the
678+
[kube-proxy configuration file](/docs/reference/config-api/kube-proxy-config.v1alpha1/)
679+
to particular IP block(s).
680+
681+
This flag takes a comma-delimited list of IP blocks (e.g. `10.0.0.0/8`, `192.0.2.0/25`)
682+
to specify IP address ranges that kube-proxy should consider as local to this node.
683+
684+
For example, if you start kube-proxy with the `--nodeport-addresses=127.0.0.0/8` flag,
685+
kube-proxy only selects the loopback interface for NodePort Services.
686+
The default for `--nodeport-addresses` is an empty list.
687+
This means that kube-proxy should consider all available network interfaces for NodePort.
688+
(That's also compatible with earlier Kubernetes releases.)
689+
Note that this Service is visible as `<NodeIP>:spec.ports[*].nodePort`
690+
and `.spec.clusterIP:spec.ports[*].port`.
691+
If the `--nodeport-addresses` flag for kube-proxy or the equivalent field
692+
in the kube-proxy configuration file is set, `<NodeIP>` would be a filtered node IP address (or possibly IP addresses).
693+
694+
681695
### Type LoadBalancer {#loadbalancer}
682696

683697
On cloud providers which support external load balancers, setting the `type`
@@ -716,6 +730,16 @@ the loadBalancer is set up with an ephemeral IP address. If you specify a `loadB
716730
but your cloud provider does not support the feature, the `loadbalancerIP` field that you
717731
set is ignored.
718732

733+
To implement a Service of `type: LoadBalancer`, Kubernetes typically starts off
734+
by making the changes that are equivalent to you requesting a Service of
735+
`type: NodePort`. The cloud-controller-manager component then configures the external load balancer to
736+
forward traffic to that assigned node port.
737+
738+
_As an alpha feature_, you can configure a load balanced Service to
739+
[omit](#load-balancer-nodeport-allocation) assigning a node port, provided that the
740+
cloud provider implementation supports this.
741+
742+
719743
{{< note >}}
720744

721745
On **Azure**, if you want to use a user-specified public type `loadBalancerIP`, you first need
@@ -1292,7 +1316,7 @@ a load balancer or node-port.
12921316
The `Type` field is designed as nested functionality - each level adds to the
12931317
previous. This is not strictly required on all cloud providers (e.g. Google Compute Engine does
12941318
not need to allocate a `NodePort` to make `LoadBalancer` work, but AWS does)
1295-
but the current API requires it.
1319+
but the Kubernetes API design for Service requires it anyway.
12961320

12971321
## Virtual IP implementation {#the-gory-details-of-virtual-ips}
12981322

0 commit comments

Comments
 (0)