mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #12141 from gmarek/service_doc
Small changes to Services doc
This commit is contained in:
commit
60e17a54e7
@ -48,7 +48,7 @@ Documentation for other releases can be found at
|
|||||||
- [Environment variables](#environment-variables)
|
- [Environment variables](#environment-variables)
|
||||||
- [DNS](#dns)
|
- [DNS](#dns)
|
||||||
- [Headless services](#headless-services)
|
- [Headless services](#headless-services)
|
||||||
- [External services](#external-services)
|
- [Publishing services - service types](#publishing-services---service-types)
|
||||||
- [Type NodePort](#type-nodeport)
|
- [Type NodePort](#type-nodeport)
|
||||||
- [Type LoadBalancer](#type-loadbalancer)
|
- [Type LoadBalancer](#type-loadbalancer)
|
||||||
- [Shortcomings](#shortcomings)
|
- [Shortcomings](#shortcomings)
|
||||||
@ -355,22 +355,30 @@ they desire, but leaves them freedom to do discovery in their own way.
|
|||||||
Applications can still use a self-registration pattern and adapters for other
|
Applications can still use a self-registration pattern and adapters for other
|
||||||
discovery systems could easily be built upon this API.
|
discovery systems could easily be built upon this API.
|
||||||
|
|
||||||
## External services
|
## Publishing services - service types
|
||||||
|
|
||||||
For some parts of your application (e.g. frontends) you may want to expose a
|
For some parts of your application (e.g. frontends) you may want to expose a
|
||||||
Service onto an external (outside of your cluster, maybe public internet) IP
|
Service onto an external (outside of your cluster, maybe public internet) IP
|
||||||
address. Kubernetes supports two ways of doing this: `NodePort`s and
|
address, other services should be visible only from inside of the cluster.
|
||||||
`LoadBalancer`s.
|
|
||||||
|
|
||||||
Every `Service` has a `type` field which defines how the `Service` can be
|
|
||||||
accessed. Valid values for this field are:
|
Kubernetes `ServiceTypes` allow you to specify what kind of service you want.
|
||||||
|
The default and base type is `ClusterIP`, which exposes a service to connection
|
||||||
|
from inside the cluster. `NodePort` and `LoadBalancer` are two types that expose
|
||||||
|
services to external trafic.
|
||||||
|
|
||||||
|
Valid values for the `ServiceType` field are:
|
||||||
|
|
||||||
* `ClusterIP`: use a cluster-internal IP only - this is the default and is
|
* `ClusterIP`: use a cluster-internal IP only - this is the default and is
|
||||||
discussed above
|
discussed above. Choosing this value means that you want this service to be
|
||||||
* `NodePort`: use a cluster IP, but also expose the service on a port on each
|
reachable only from inside of the cluster.
|
||||||
node of the cluster (the same port on each node)
|
* `NodePort`: on top of having a cluster-internal IP, expose the service on a
|
||||||
* `LoadBalancer`: use a ClusterIP and a NodePort, but also ask the cloud
|
port on each node of the cluster (the same port on each node). You'll be able
|
||||||
provider for a load balancer which forwards to the `Service`
|
to contact the service on any `<NodeIP>:NodePort` address.
|
||||||
|
* `LoadBalancer`: on top of having a cluster-internal IP and exposing service
|
||||||
|
on a NodePort also, ask the cloud provider for a load balancer
|
||||||
|
which forwards to the `Service` exposed as a `<NodeIP>:NodePort`
|
||||||
|
for each Node.
|
||||||
|
|
||||||
Note that while `NodePort`s can be TCP or UDP, `LoadBalancer`s only support TCP
|
Note that while `NodePort`s can be TCP or UDP, `LoadBalancer`s only support TCP
|
||||||
as of Kubernetes 1.0.
|
as of Kubernetes 1.0.
|
||||||
@ -379,18 +387,21 @@ as of Kubernetes 1.0.
|
|||||||
|
|
||||||
If you set the `type` field to `"NodePort"`, the Kubernetes master will
|
If you set the `type` field to `"NodePort"`, the Kubernetes master will
|
||||||
allocate a port from a flag-configured range (default: 30000-32767), and each
|
allocate a port from a flag-configured range (default: 30000-32767), and each
|
||||||
node will proxy that port (the same port number on every node) into your `Service`.
|
Node will proxy that port (the same port number on every Node) into your `Service`.
|
||||||
That port will be reported in your `Service`'s `spec.ports[*].nodePort` field.
|
That port will be reported in your `Service`'s `spec.ports[*].nodePort` field.
|
||||||
|
|
||||||
If you want a specific port number, you can specify a value in the `nodePort`
|
If you want a specific port number, you can specify a value in the `nodePort`
|
||||||
field, and the system will allocate you that port or else the API transaction
|
field, and the system will allocate you that port or else the API transaction
|
||||||
will fail. The value you specify must be in the configured range for node
|
will fail (i.e. you need to take care about possible port collisions yourself).
|
||||||
ports.
|
The value you specify must be in the configured range for node ports.
|
||||||
|
|
||||||
This gives developers the freedom to set up their own load balancers, to
|
This gives developers the freedom to set up their own load balancers, to
|
||||||
configure cloud environments that are not fully supported by Kubernetes, or
|
configure cloud environments that are not fully supported by Kubernetes, or
|
||||||
even to just expose one or more nodes' IPs directly.
|
even to just expose one or more nodes' IPs directly.
|
||||||
|
|
||||||
|
Note that this Service will be visible as both `<NodeIP>:spec.ports[*].nodePort`
|
||||||
|
and `spec.clusterIp:spec.ports[*].port`.
|
||||||
|
|
||||||
### Type LoadBalancer
|
### Type LoadBalancer
|
||||||
|
|
||||||
On cloud providers which support external load balancers, setting the `type`
|
On cloud providers which support external load balancers, setting the `type`
|
||||||
|
Loading…
Reference in New Issue
Block a user