Skip to content

Commit b2f830f

Browse files
authored
Merge pull request #36672 from sftim/20220411_remove_misleading_service_clusterip_detail
Avoid misleading text in Service concept
2 parents b49e20a + fdceaa2 commit b2f830f

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
@@ -647,21 +647,18 @@ For some parts of your application (for example, frontends) you may want to expo
647647
Service onto an external IP address, that's outside of your cluster.
648648

649649
Kubernetes `ServiceTypes` allow you to specify what kind of Service you want.
650-
The default is `ClusterIP`.
651650

652651
`Type` values and their behaviors are:
653652

654653
* `ClusterIP`: Exposes the Service on a cluster-internal IP. Choosing this value
655654
makes the Service only reachable from within the cluster. This is the
656-
default `ServiceType`.
655+
default that is used if you don't explicitly specify a `type` for a Service.
657656
* [`NodePort`](#type-nodeport): Exposes the Service on each Node's IP at a static port
658-
(the `NodePort`). A `ClusterIP` Service, to which the `NodePort` Service
659-
routes, is automatically created. You'll be able to contact the `NodePort` Service,
660-
from outside the cluster,
661-
by requesting `<NodeIP>:<NodePort>`.
657+
(the `NodePort`).
658+
To make the node port available, Kubernetes sets up a cluster IP address,
659+
the same as if you had requested a Service of `type: ClusterIP`.
662660
* [`LoadBalancer`](#loadbalancer): Exposes the Service externally using a cloud
663-
provider's load balancer. `NodePort` and `ClusterIP` Services, to which the external
664-
load balancer routes, are automatically created.
661+
provider's load balancer.
665662
* [`ExternalName`](#externalname): Maps the Service to the contents of the
666663
`externalName` field (e.g. `foo.bar.example.com`), by returning a `CNAME` record
667664
with its value. No proxying of any kind is set up.
@@ -681,20 +678,18 @@ allocates a port from a range specified by `--service-node-port-range` flag (def
681678
Each node proxies that port (the same port number on every Node) into your Service.
682679
Your Service reports the allocated port in its `.spec.ports[*].nodePort` field.
683680

684-
If you want to specify particular IP(s) to proxy the port, you can set the
685-
`--nodeport-addresses` flag for kube-proxy or the equivalent `nodePortAddresses`
686-
field of the
687-
[kube-proxy configuration file](/docs/reference/config-api/kube-proxy-config.v1alpha1/)
688-
to particular IP block(s).
681+
Using a NodePort gives you the freedom to set up your own load balancing solution,
682+
to configure environments that are not fully supported by Kubernetes, or even
683+
to expose one or more nodes' IP addresses directly.
689684

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

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

699694
If you want a specific port number, you can specify a value in the `nodePort`
700695
field. The control plane will either allocate you that port or report that
@@ -703,16 +698,8 @@ This means that you need to take care of possible port collisions yourself.
703698
You also have to use a valid port number, one that's inside the range configured
704699
for NodePort use.
705700

706-
Using a NodePort gives you the freedom to set up your own load balancing solution,
707-
to configure environments that are not fully supported by Kubernetes, or even
708-
to expose one or more nodes' IPs directly.
709-
710-
Note that this Service is visible as `<NodeIP>:spec.ports[*].nodePort`
711-
and `.spec.clusterIP:spec.ports[*].port`.
712-
If the `--nodeport-addresses` flag for kube-proxy or the equivalent field
713-
in the kube-proxy configuration file is set, `<NodeIP>` would be filtered node IP(s).
714-
715-
For example:
701+
Here is an example manifest for a Service of `type: NodePort` that specifies
702+
a NodePort value (30007, in this example).
716703

717704
```yaml
718705
apiVersion: v1
@@ -732,6 +719,33 @@ spec:
732719
nodePort: 30007
733720
```
734721
722+
#### Custom IP address configuration for `type: NodePort` Services {#service-nodeport-custom-listen-address}
723+
724+
You can set up nodes in your cluster to use a particular IP address for serving node port
725+
services. You might want to do this if each node is connected to multiple networks (for example:
726+
one network for application traffic, and another network for traffic between nodes and the
727+
control plane).
728+
729+
If you want to specify particular IP address(es) to proxy the port, you can set the
730+
`--nodeport-addresses` flag for kube-proxy or the equivalent `nodePortAddresses`
731+
field of the
732+
[kube-proxy configuration file](/docs/reference/config-api/kube-proxy-config.v1alpha1/)
733+
to particular IP block(s).
734+
735+
This flag takes a comma-delimited list of IP blocks (e.g. `10.0.0.0/8`, `192.0.2.0/25`)
736+
to specify IP address ranges that kube-proxy should consider as local to this node.
737+
738+
For example, if you start kube-proxy with the `--nodeport-addresses=127.0.0.0/8` flag,
739+
kube-proxy only selects the loopback interface for NodePort Services.
740+
The default for `--nodeport-addresses` is an empty list.
741+
This means that kube-proxy should consider all available network interfaces for NodePort.
742+
(That's also compatible with earlier Kubernetes releases.)
743+
Note that this Service is visible as `<NodeIP>:spec.ports[*].nodePort`
744+
and `.spec.clusterIP:spec.ports[*].port`.
745+
If the `--nodeport-addresses` flag for kube-proxy or the equivalent field
746+
in the kube-proxy configuration file is set, `<NodeIP>` would be a filtered node IP address (or possibly IP addresses).
747+
748+
735749
### Type LoadBalancer {#loadbalancer}
736750

737751
On cloud providers which support external load balancers, setting the `type`
@@ -770,6 +784,16 @@ the loadBalancer is set up with an ephemeral IP address. If you specify a `loadB
770784
but your cloud provider does not support the feature, the `loadbalancerIP` field that you
771785
set is ignored.
772786

787+
To implement a Service of `type: LoadBalancer`, Kubernetes typically starts off
788+
by making the changes that are equivalent to you requesting a Service of
789+
`type: NodePort`. The cloud-controller-manager component then configures the external load balancer to
790+
forward traffic to that assigned node port.
791+
792+
_As an alpha feature_, you can configure a load balanced Service to
793+
[omit](#load-balancer-nodeport-allocation) assigning a node port, provided that the
794+
cloud provider implementation supports this.
795+
796+
773797
{{< note >}}
774798

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

13511375
## Virtual IP implementation {#the-gory-details-of-virtual-ips}
13521376

0 commit comments

Comments
 (0)