Merge pull request #39499 from sftim/20230216_service_update_part_14
Revise Service concept, part 14
This commit is contained in:
commit
c67a986cf0
|
|
@ -71,14 +71,15 @@ balancer in between your application and the backend Pods.
|
|||
|
||||
## Defining a Service
|
||||
|
||||
A Service in Kubernetes is a REST object, similar to a Pod. Like all of the
|
||||
REST objects, you can `POST` a Service definition to the API server to create
|
||||
a new instance.
|
||||
The name of a Service object must be a valid
|
||||
[RFC 1035 label name](/docs/concepts/overview/working-with-objects/names#rfc-1035-label-names).
|
||||
A Service in Kubernetes is an
|
||||
{{< glossary_tooltip text="object" term_id="object" >}}
|
||||
(the same way that a Pod or a ConfigMap is an object). You can create,
|
||||
view or modify Service definitions using the Kubernetes API. Usually
|
||||
you use a tool such as `kubectl` to make those API calls for you.
|
||||
|
||||
For example, suppose you have a set of Pods where each listens on TCP port 9376
|
||||
and contains a label `app.kubernetes.io/name=MyApp`:
|
||||
For example, suppose you have a set of Pods that each listen on TCP port 9376
|
||||
and are labelled as `app.kubernetes.io/name=MyApp`. You can define a Service to
|
||||
publish that TCP listener:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
|
|
@ -94,16 +95,20 @@ spec:
|
|||
targetPort: 9376
|
||||
```
|
||||
|
||||
This specification creates a new Service object named "my-service", which
|
||||
targets TCP port 9376 on any Pod with the `app.kubernetes.io/name=MyApp` label.
|
||||
Applying this manifest creates a new Service named "my-service", which
|
||||
targets TCP port 9376 on any Pod with the `app.kubernetes.io/name: MyApp` label.
|
||||
|
||||
Kubernetes assigns this Service an IP address (sometimes called the "cluster IP"),
|
||||
which is used by the Service proxies
|
||||
(see [Virtual IP addressing mechanism](#virtual-ip-addressing-mechanism) below).
|
||||
Kubernetes assigns this Service an IP address (the _cluster IP_),
|
||||
that is used by the virtual IP address mechanism. For more details on that mechanism,
|
||||
read [Virtual IPs and Service Proxies](/docs/reference/networking/virtual-ips/).
|
||||
|
||||
The controller for that Service continuously scans for Pods that
|
||||
match its selector, and then makes any necessary updates to the set of
|
||||
EndpointSlices for the Service.
|
||||
|
||||
The name of a Service object must be a valid
|
||||
[RFC 1035 label name](/docs/concepts/overview/working-with-objects/names#rfc-1035-label-names).
|
||||
|
||||
The controller for the Service selector continuously scans for Pods that
|
||||
match its selector, and then POSTs any updates to an Endpoint object
|
||||
also named "my-service".
|
||||
|
||||
{{< note >}}
|
||||
A Service can map _any_ incoming `port` to a `targetPort`. By default and
|
||||
|
|
@ -177,8 +182,8 @@ For example:
|
|||
* You are migrating a workload to Kubernetes. While evaluating the approach,
|
||||
you run only a portion of your backends in Kubernetes.
|
||||
|
||||
In any of these scenarios you can define a Service _without_ a Pod selector.
|
||||
For example:
|
||||
In any of these scenarios you can define a Service _without_ specifying a
|
||||
selector to match Pods. For example:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
|
|
@ -262,9 +267,9 @@ selector will fail due to this constraint. This prevents the Kubernetes API serv
|
|||
from being used as a proxy to endpoints the caller may not be authorized to access.
|
||||
{{< /note >}}
|
||||
|
||||
An ExternalName Service is a special case of Service that does not have
|
||||
An `ExternalName` Service is a special case of Service that does not have
|
||||
selectors and uses DNS names instead. For more information, see the
|
||||
[ExternalName](#externalname) section later in this document.
|
||||
[ExternalName](#externalname) section.
|
||||
|
||||
### EndpointSlices
|
||||
|
||||
|
|
@ -704,7 +709,7 @@ In a split-horizon DNS environment you would need two Services to be able to rou
|
|||
and internal traffic to your endpoints.
|
||||
|
||||
To set an internal load balancer, add one of the following annotations to your Service
|
||||
depending on the cloud Service provider you're using.
|
||||
depending on the cloud service provider you're using:
|
||||
|
||||
{{< tabs name="service_tabs" >}}
|
||||
{{% tab name="Default" %}}
|
||||
|
|
@ -1151,9 +1156,9 @@ spec:
|
|||
- name: http
|
||||
protocol: TCP
|
||||
port: 80
|
||||
targetPort: 9376
|
||||
targetPort: 49152
|
||||
externalIPs:
|
||||
- 80.11.12.10
|
||||
- 198.51.100.32
|
||||
```
|
||||
|
||||
## Session stickiness
|
||||
|
|
@ -1178,13 +1183,17 @@ mechanism Kubernetes provides to expose a Service with a virtual IP address.
|
|||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
Learn more about the following:
|
||||
* Follow the [Connecting Applications with Services](/docs/tutorials/services/connect-applications-service/) tutorial
|
||||
* [Ingress](/docs/concepts/services-networking/ingress/) exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
|
||||
* [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
|
||||
Learn more about Services and how they fit into Kubernetes:
|
||||
* Follow the [Connecting Applications with Services](/docs/tutorials/services/connect-applications-service/) tutorial.
|
||||
* Read about [Ingress](/docs/concepts/services-networking/ingress/), which
|
||||
exposes HTTP and HTTPS routes from outside the cluster to Services within
|
||||
your cluster.
|
||||
* Read about [Gateway](https://gateway-api.sigs.k8s.io/), an extension to
|
||||
Kubernetes that provides more flexibility than Ingress.
|
||||
|
||||
For more context:
|
||||
For more context, read the following:
|
||||
* [Virtual IPs and Service Proxies](/docs/reference/networking/virtual-ips/)
|
||||
* [API reference](/docs/reference/kubernetes-api/service-resources/service-v1/) for the Service API
|
||||
* [API reference](/docs/reference/kubernetes-api/service-resources/endpoints-v1/) for the Endpoints API
|
||||
* [API reference](/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/) for the EndpointSlice API
|
||||
* [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
|
||||
* [Service API reference](/docs/reference/kubernetes-api/service-resources/service-v1/)
|
||||
* [EndpointSlice API reference](/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/)
|
||||
* [Endpoint API reference (legacy)](/docs/reference/kubernetes-api/service-resources/endpoints-v1/)
|
||||
|
|
|
|||
Loading…
Reference in New Issue