Skip to content

Commit c67a986

Browse files
authored
Merge pull request #39499 from sftim/20230216_service_update_part_14
Revise Service concept, part 14
2 parents bbc9f8d + 5c775fc commit c67a986

File tree

1 file changed

+39
-30
lines changed
  • content/en/docs/concepts/services-networking

1 file changed

+39
-30
lines changed

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

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ balancer in between your application and the backend Pods.
7171

7272
## Defining a Service
7373

74-
A Service in Kubernetes is a REST object, similar to a Pod. Like all of the
75-
REST objects, you can `POST` a Service definition to the API server to create
76-
a new instance.
77-
The name of a Service object must be a valid
78-
[RFC 1035 label name](/docs/concepts/overview/working-with-objects/names#rfc-1035-label-names).
74+
A Service in Kubernetes is an
75+
{{< glossary_tooltip text="object" term_id="object" >}}
76+
(the same way that a Pod or a ConfigMap is an object). You can create,
77+
view or modify Service definitions using the Kubernetes API. Usually
78+
you use a tool such as `kubectl` to make those API calls for you.
7979

80-
For example, suppose you have a set of Pods where each listens on TCP port 9376
81-
and contains a label `app.kubernetes.io/name=MyApp`:
80+
For example, suppose you have a set of Pods that each listen on TCP port 9376
81+
and are labelled as `app.kubernetes.io/name=MyApp`. You can define a Service to
82+
publish that TCP listener:
8283

8384
```yaml
8485
apiVersion: v1
@@ -94,16 +95,20 @@ spec:
9495
targetPort: 9376
9596
```
9697
97-
This specification creates a new Service object named "my-service", which
98-
targets TCP port 9376 on any Pod with the `app.kubernetes.io/name=MyApp` label.
98+
Applying this manifest creates a new Service named "my-service", which
99+
targets TCP port 9376 on any Pod with the `app.kubernetes.io/name: MyApp` label.
100+
101+
Kubernetes assigns this Service an IP address (the _cluster IP_),
102+
that is used by the virtual IP address mechanism. For more details on that mechanism,
103+
read [Virtual IPs and Service Proxies](/docs/reference/networking/virtual-ips/).
99104

100-
Kubernetes assigns this Service an IP address (sometimes called the "cluster IP"),
101-
which is used by the Service proxies
102-
(see [Virtual IP addressing mechanism](#virtual-ip-addressing-mechanism) below).
105+
The controller for that Service continuously scans for Pods that
106+
match its selector, and then makes any necessary updates to the set of
107+
EndpointSlices for the Service.
108+
109+
The name of a Service object must be a valid
110+
[RFC 1035 label name](/docs/concepts/overview/working-with-objects/names#rfc-1035-label-names).
103111

104-
The controller for the Service selector continuously scans for Pods that
105-
match its selector, and then POSTs any updates to an Endpoint object
106-
also named "my-service".
107112

108113
{{< note >}}
109114
A Service can map _any_ incoming `port` to a `targetPort`. By default and
@@ -177,8 +182,8 @@ For example:
177182
* You are migrating a workload to Kubernetes. While evaluating the approach,
178183
you run only a portion of your backends in Kubernetes.
179184

180-
In any of these scenarios you can define a Service _without_ a Pod selector.
181-
For example:
185+
In any of these scenarios you can define a Service _without_ specifying a
186+
selector to match Pods. For example:
182187

183188
```yaml
184189
apiVersion: v1
@@ -262,9 +267,9 @@ selector will fail due to this constraint. This prevents the Kubernetes API serv
262267
from being used as a proxy to endpoints the caller may not be authorized to access.
263268
{{< /note >}}
264269

265-
An ExternalName Service is a special case of Service that does not have
270+
An `ExternalName` Service is a special case of Service that does not have
266271
selectors and uses DNS names instead. For more information, see the
267-
[ExternalName](#externalname) section later in this document.
272+
[ExternalName](#externalname) section.
268273

269274
### EndpointSlices
270275

@@ -704,7 +709,7 @@ In a split-horizon DNS environment you would need two Services to be able to rou
704709
and internal traffic to your endpoints.
705710

706711
To set an internal load balancer, add one of the following annotations to your Service
707-
depending on the cloud Service provider you're using.
712+
depending on the cloud service provider you're using:
708713

709714
{{< tabs name="service_tabs" >}}
710715
{{% tab name="Default" %}}
@@ -1151,9 +1156,9 @@ spec:
11511156
- name: http
11521157
protocol: TCP
11531158
port: 80
1154-
targetPort: 9376
1159+
targetPort: 49152
11551160
externalIPs:
1156-
- 80.11.12.10
1161+
- 198.51.100.32
11571162
```
11581163

11591164
## Session stickiness
@@ -1178,13 +1183,17 @@ mechanism Kubernetes provides to expose a Service with a virtual IP address.
11781183

11791184
## {{% heading "whatsnext" %}}
11801185

1181-
Learn more about the following:
1182-
* Follow the [Connecting Applications with Services](/docs/tutorials/services/connect-applications-service/) tutorial
1183-
* [Ingress](/docs/concepts/services-networking/ingress/) exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
1184-
* [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
1186+
Learn more about Services and how they fit into Kubernetes:
1187+
* Follow the [Connecting Applications with Services](/docs/tutorials/services/connect-applications-service/) tutorial.
1188+
* Read about [Ingress](/docs/concepts/services-networking/ingress/), which
1189+
exposes HTTP and HTTPS routes from outside the cluster to Services within
1190+
your cluster.
1191+
* Read about [Gateway](https://gateway-api.sigs.k8s.io/), an extension to
1192+
Kubernetes that provides more flexibility than Ingress.
11851193

1186-
For more context:
1194+
For more context, read the following:
11871195
* [Virtual IPs and Service Proxies](/docs/reference/networking/virtual-ips/)
1188-
* [API reference](/docs/reference/kubernetes-api/service-resources/service-v1/) for the Service API
1189-
* [API reference](/docs/reference/kubernetes-api/service-resources/endpoints-v1/) for the Endpoints API
1190-
* [API reference](/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/) for the EndpointSlice API
1196+
* [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
1197+
* [Service API reference](/docs/reference/kubernetes-api/service-resources/service-v1/)
1198+
* [EndpointSlice API reference](/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/)
1199+
* [Endpoint API reference (legacy)](/docs/reference/kubernetes-api/service-resources/endpoints-v1/)

0 commit comments

Comments
 (0)