Skip to content

Commit c98e9e5

Browse files
authored
Merge pull request #23882 from kbhawkey/kb-service-word-cleanup
reword pod lifecycle, cleanup
2 parents 073500a + 6a40107 commit c98e9e5

File tree

1 file changed

+83
-72
lines changed
  • content/en/docs/concepts/services-networking

1 file changed

+83
-72
lines changed

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

Lines changed: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ and can load-balance across them.
2424

2525
## Motivation
2626

27-
Kubernetes {{< glossary_tooltip term_id="pod" text="Pods" >}} are mortal.
28-
They are born and when they die, they are not resurrected.
27+
Kubernetes {{< glossary_tooltip term_id="pod" text="Pods" >}} are created and destroyed
28+
to match the state of your cluster. Pods are nonpermanent resources.
2929
If you use a {{< glossary_tooltip term_id="deployment" >}} to run your app,
3030
it can create and destroy Pods dynamically.
3131

@@ -45,9 +45,9 @@ Enter _Services_.
4545
In Kubernetes, a Service is an abstraction which defines a logical set of Pods
4646
and a policy by which to access them (sometimes this pattern is called
4747
a micro-service). The set of Pods targeted by a Service is usually determined
48-
by a {{< glossary_tooltip text="selector" term_id="selector" >}}
49-
(see [below](#services-without-selectors) for why you might want a Service
50-
_without_ a selector).
48+
by a {{< glossary_tooltip text="selector" term_id="selector" >}}.
49+
To learn about other ways to define Service endpoints,
50+
see [Services _without_ selectors](#services-without-selectors).
5151

5252
For example, consider a stateless image-processing backend which is running with
5353
3 replicas. Those replicas are fungible&mdash;frontends do not care which backend
@@ -129,12 +129,12 @@ Services most commonly abstract access to Kubernetes Pods, but they can also
129129
abstract other kinds of backends.
130130
For example:
131131

132-
* You want to have an external database cluster in production, but in your
133-
test environment you use your own databases.
134-
* You want to point your Service to a Service in a different
135-
{{< glossary_tooltip term_id="namespace" >}} or on another cluster.
136-
* You are migrating a workload to Kubernetes. Whilst evaluating the approach,
137-
you run only a proportion of your backends in Kubernetes.
132+
* You want to have an external database cluster in production, but in your
133+
test environment you use your own databases.
134+
* You want to point your Service to a Service in a different
135+
{{< glossary_tooltip term_id="namespace" >}} or on another cluster.
136+
* You are migrating a workload to Kubernetes. While evaluating the approach,
137+
you run only a proportion of your backends in Kubernetes.
138138

139139
In any of these scenarios you can define a Service _without_ a Pod selector.
140140
For example:
@@ -151,7 +151,7 @@ spec:
151151
targetPort: 9376
152152
```
153153

154-
Because this Service has no selector, the corresponding Endpoint object is *not*
154+
Because this Service has no selector, the corresponding Endpoint object is not
155155
created automatically. You can manually map the Service to the network address and port
156156
where it's running, by adding an Endpoint object manually:
157157

@@ -188,6 +188,7 @@ selectors and uses DNS names instead. For more information, see the
188188
[ExternalName](#externalname) section later in this document.
189189

190190
### EndpointSlices
191+
191192
{{< feature-state for_k8s_version="v1.17" state="beta" >}}
192193

193194
EndpointSlices are an API resource that can provide a more scalable alternative
@@ -204,9 +205,8 @@ described in detail in [EndpointSlices](/docs/concepts/services-networking/endpo
204205

205206
{{< feature-state for_k8s_version="v1.19" state="beta" >}}
206207

207-
The AppProtocol field provides a way to specify an application protocol to be
208-
used for each Service port. The value of this field is mirrored by corresponding
209-
Endpoints and EndpointSlice resources.
208+
The `AppProtocol` field provides a way to specify an application protocol for each Service port.
209+
The value of this field is mirrored by corresponding Endpoints and EndpointSlice resources.
210210

211211
## Virtual IPs and service proxies
212212

@@ -224,20 +224,19 @@ resolution?
224224

225225
There are a few reasons for using proxying for Services:
226226

227-
* There is a long history of DNS implementations not respecting record TTLs,
228-
and caching the results of name lookups after they should have expired.
229-
* Some apps do DNS lookups only once and cache the results indefinitely.
230-
* Even if apps and libraries did proper re-resolution, the low or zero TTLs
231-
on the DNS records could impose a high load on DNS that then becomes
232-
difficult to manage.
227+
* There is a long history of DNS implementations not respecting record TTLs,
228+
and caching the results of name lookups after they should have expired.
229+
* Some apps do DNS lookups only once and cache the results indefinitely.
230+
* Even if apps and libraries did proper re-resolution, the low or zero TTLs
231+
on the DNS records could impose a high load on DNS that then becomes
232+
difficult to manage.
233233

234234
### User space proxy mode {#proxy-mode-userspace}
235235

236236
In this mode, kube-proxy watches the Kubernetes master for the addition and
237237
removal of Service and Endpoint objects. For each Service it opens a
238238
port (randomly chosen) on the local node. Any connections to this "proxy port"
239-
are
240-
proxied to one of the Service's backend Pods (as reported via
239+
are proxied to one of the Service's backend Pods (as reported via
241240
Endpoints). kube-proxy takes the `SessionAffinity` setting of the Service into
242241
account when deciding which backend Pod to use.
243242

@@ -255,7 +254,7 @@ In this mode, kube-proxy watches the Kubernetes control plane for the addition a
255254
removal of Service and Endpoint objects. For each Service, it installs
256255
iptables rules, which capture traffic to the Service's `clusterIP` and `port`,
257256
and redirect that traffic to one of the Service's
258-
backend sets. For each Endpoint object, it installs iptables rules which
257+
backend sets. For each Endpoint object, it installs iptables rules which
259258
select a backend Pod.
260259

261260
By default, kube-proxy in iptables mode chooses a backend at random.
@@ -298,12 +297,12 @@ higher throughput of network traffic.
298297
IPVS provides more options for balancing traffic to backend Pods;
299298
these are:
300299

301-
- `rr`: round-robin
302-
- `lc`: least connection (smallest number of open connections)
303-
- `dh`: destination hashing
304-
- `sh`: source hashing
305-
- `sed`: shortest expected delay
306-
- `nq`: never queue
300+
* `rr`: round-robin
301+
* `lc`: least connection (smallest number of open connections)
302+
* `dh`: destination hashing
303+
* `sh`: source hashing
304+
* `sed`: shortest expected delay
305+
* `nq`: never queue
307306

308307
{{< note >}}
309308
To run kube-proxy in IPVS mode, you must make IPVS available on
@@ -389,7 +388,7 @@ compatible](https://docs.docker.com/userguide/dockerlinks/) variables (see
389388
and simpler `{SVCNAME}_SERVICE_HOST` and `{SVCNAME}_SERVICE_PORT` variables,
390389
where the Service name is upper-cased and dashes are converted to underscores.
391390

392-
For example, the Service `"redis-master"` which exposes TCP port 6379 and has been
391+
For example, the Service `redis-master` which exposes TCP port 6379 and has been
393392
allocated cluster IP address 10.0.0.11, produces the following environment
394393
variables:
395394

@@ -423,19 +422,19 @@ Services and creates a set of DNS records for each one. If DNS has been enabled
423422
throughout your cluster then all Pods should automatically be able to resolve
424423
Services by their DNS name.
425424

426-
For example, if you have a Service called `"my-service"` in a Kubernetes
427-
Namespace `"my-ns"`, the control plane and the DNS Service acting together
428-
create a DNS record for `"my-service.my-ns"`. Pods in the `"my-ns"` Namespace
425+
For example, if you have a Service called `my-service` in a Kubernetes
426+
namespace `my-ns`, the control plane and the DNS Service acting together
427+
create a DNS record for `my-service.my-ns`. Pods in the `my-ns` namespace
429428
should be able to find it by simply doing a name lookup for `my-service`
430-
(`"my-service.my-ns"` would also work).
429+
(`my-service.my-ns` would also work).
431430

432-
Pods in other Namespaces must qualify the name as `my-service.my-ns`. These names
431+
Pods in other namespaces must qualify the name as `my-service.my-ns`. These names
433432
will resolve to the cluster IP assigned for the Service.
434433

435434
Kubernetes also supports DNS SRV (Service) records for named ports. If the
436-
`"my-service.my-ns"` Service has a port named `"http"` with the protocol set to
435+
`my-service.my-ns` Service has a port named `http` with the protocol set to
437436
`TCP`, you can do a DNS SRV query for `_http._tcp.my-service.my-ns` to discover
438-
the port number for `"http"`, as well as the IP address.
437+
the port number for `http`, as well as the IP address.
439438

440439
The Kubernetes DNS server is the only way to access `ExternalName` Services.
441440
You can find more information about `ExternalName` resolution in
@@ -467,9 +466,9 @@ For headless Services that do not define selectors, the endpoints controller doe
467466
not create `Endpoints` records. However, the DNS system looks for and configures
468467
either:
469468

470-
* CNAME records for [`ExternalName`](#externalname)-type Services.
471-
* A records for any `Endpoints` that share a name with the Service, for all
472-
other types.
469+
* CNAME records for [`ExternalName`](#externalname)-type Services.
470+
* A records for any `Endpoints` that share a name with the Service, for all
471+
other types.
473472

474473
## Publishing Services (ServiceTypes) {#publishing-services-service-types}
475474

@@ -481,26 +480,26 @@ The default is `ClusterIP`.
481480

482481
`Type` values and their behaviors are:
483482

484-
* `ClusterIP`: Exposes the Service on a cluster-internal IP. Choosing this value
485-
makes the Service only reachable from within the cluster. This is the
486-
default `ServiceType`.
487-
* [`NodePort`](#nodeport): Exposes the Service on each Node's IP at a static port
488-
(the `NodePort`). A `ClusterIP` Service, to which the `NodePort` Service
489-
routes, is automatically created. You'll be able to contact the `NodePort` Service,
490-
from outside the cluster,
491-
by requesting `<NodeIP>:<NodePort>`.
492-
* [`LoadBalancer`](#loadbalancer): Exposes the Service externally using a cloud
493-
provider's load balancer. `NodePort` and `ClusterIP` Services, to which the external
494-
load balancer routes, are automatically created.
495-
* [`ExternalName`](#externalname): Maps the Service to the contents of the
496-
`externalName` field (e.g. `foo.bar.example.com`), by returning a `CNAME` record
497-
498-
with its value. No proxying of any kind is set up.
499-
{{< note >}}
500-
You need either kube-dns version 1.7 or CoreDNS version 0.0.8 or higher to use the `ExternalName` type.
501-
{{< /note >}}
502-
503-
You can also use [Ingress](/docs/concepts/services-networking/ingress/) to expose your Service. Ingress is not a Service type, but it acts as the entry point for your cluster. It lets you consolidate your routing rules into a single resource as it can expose multiple services under the same IP address.
483+
* `ClusterIP`: Exposes the Service on a cluster-internal IP. Choosing this value
484+
makes the Service only reachable from within the cluster. This is the
485+
default `ServiceType`.
486+
* [`NodePort`](#nodeport): Exposes the Service on each Node's IP at a static port
487+
(the `NodePort`). A `ClusterIP` Service, to which the `NodePort` Service
488+
routes, is automatically created. You'll be able to contact the `NodePort` Service,
489+
from outside the cluster,
490+
by requesting `<NodeIP>:<NodePort>`.
491+
* [`LoadBalancer`](#loadbalancer): Exposes the Service externally using a cloud
492+
provider's load balancer. `NodePort` and `ClusterIP` Services, to which the external
493+
load balancer routes, are automatically created.
494+
* [`ExternalName`](#externalname): Maps the Service to the contents of the
495+
`externalName` field (e.g. `foo.bar.example.com`), by returning a `CNAME` record
496+
with its value. No proxying of any kind is set up.
497+
{{< note >}}You need either `kube-dns` version 1.7 or CoreDNS version 0.0.8 or higher
498+
to use the `ExternalName` type.
499+
{{< /note >}}
500+
501+
You can also use [Ingress](/docs/concepts/services-networking/ingress/) to expose your Service. Ingress is not a Service type, but it acts as the entry point for your cluster. It lets you consolidate your routing rules
502+
into a single resource as it can expose multiple services under the same IP address.
504503

505504
### Type NodePort {#nodeport}
506505

@@ -509,7 +508,6 @@ allocates a port from a range specified by `--service-node-port-range` flag (def
509508
Each node proxies that port (the same port number on every Node) into your Service.
510509
Your Service reports the allocated port in its `.spec.ports[*].nodePort` field.
511510

512-
513511
If you want to specify particular IP(s) to proxy the port, you can set the `--nodeport-addresses` flag in kube-proxy to particular IP block(s); this is supported since Kubernetes v1.10.
514512
This flag takes a comma-delimited list of IP blocks (e.g. 10.0.0.0/8, 192.0.2.0/25) to specify IP address ranges that kube-proxy should consider as local to this node.
515513

@@ -530,6 +528,7 @@ Note that this Service is visible as `<NodeIP>:spec.ports[*].nodePort`
530528
and `.spec.clusterIP:spec.ports[*].port`. (If the `--nodeport-addresses` flag in kube-proxy is set, <NodeIP> would be filtered NodeIP(s).)
531529

532530
For example:
531+
533532
```yaml
534533
apiVersion: v1
535534
kind: Service
@@ -606,19 +605,21 @@ Specify the assigned IP address as loadBalancerIP. Ensure that you have updated
606605
{{< /note >}}
607606

608607
#### Internal load balancer
608+
609609
In a mixed environment it is sometimes necessary to route traffic from Services inside the same
610610
(virtual) network address block.
611611

612612
In a split-horizon DNS environment you would need two Services to be able to route both external and internal traffic to your endpoints.
613613

614-
You can achieve this by adding one the following annotations to a Service.
615-
The annotation to add depends on the cloud Service provider you're using.
614+
To set an internal load balancer, add one of the following annotations to your Service
615+
depending on the cloud Service provider you're using.
616616

617617
{{< tabs name="service_tabs" >}}
618618
{{% tab name="Default" %}}
619619
Select one of the tabs.
620620
{{% /tab %}}
621621
{{% tab name="GCP" %}}
622+
622623
```yaml
623624
[...]
624625
metadata:
@@ -627,8 +628,10 @@ metadata:
627628
cloud.google.com/load-balancer-type: "Internal"
628629
[...]
629630
```
631+
630632
{{% /tab %}}
631633
{{% tab name="AWS" %}}
634+
632635
```yaml
633636
[...]
634637
metadata:
@@ -637,8 +640,10 @@ metadata:
637640
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
638641
[...]
639642
```
643+
640644
{{% /tab %}}
641645
{{% tab name="Azure" %}}
646+
642647
```yaml
643648
[...]
644649
metadata:
@@ -647,8 +652,10 @@ metadata:
647652
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
648653
[...]
649654
```
655+
650656
{{% /tab %}}
651657
{{% tab name="IBM Cloud" %}}
658+
652659
```yaml
653660
[...]
654661
metadata:
@@ -657,8 +664,10 @@ metadata:
657664
service.kubernetes.io/ibm-load-balancer-cloud-provider-ip-type: "private"
658665
[...]
659666
```
667+
660668
{{% /tab %}}
661669
{{% tab name="OpenStack" %}}
670+
662671
```yaml
663672
[...]
664673
metadata:
@@ -667,8 +676,10 @@ metadata:
667676
service.beta.kubernetes.io/openstack-internal-load-balancer: "true"
668677
[...]
669678
```
679+
670680
{{% /tab %}}
671681
{{% tab name="Baidu Cloud" %}}
682+
672683
```yaml
673684
[...]
674685
metadata:
@@ -677,28 +688,32 @@ metadata:
677688
service.beta.kubernetes.io/cce-load-balancer-internal-vpc: "true"
678689
[...]
679690
```
691+
680692
{{% /tab %}}
681693
{{% tab name="Tencent Cloud" %}}
694+
682695
```yaml
683696
[...]
684697
metadata:
685698
annotations:
686699
service.kubernetes.io/qcloud-loadbalancer-internal-subnetid: subnet-xxxxx
687700
[...]
688701
```
702+
689703
{{% /tab %}}
690704
{{% tab name="Alibaba Cloud" %}}
705+
691706
```yaml
692707
[...]
693708
metadata:
694709
annotations:
695710
service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"
696711
[...]
697712
```
713+
698714
{{% /tab %}}
699715
{{< /tabs >}}
700716

701-
702717
#### TLS support on AWS {#ssl-support-on-aws}
703718

704719
For partial TLS / SSL support on clusters running on AWS, you can add three
@@ -823,7 +838,6 @@ to the value of `"true"`. The annotation
823838
`service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout` can
824839
also be used to set maximum time, in seconds, to keep the existing connections open before deregistering the instances.
825840

826-
827841
```yaml
828842
metadata:
829843
name: my-service
@@ -991,6 +1005,7 @@ spec:
9911005
type: ExternalName
9921006
externalName: my.database.example.com
9931007
```
1008+
9941009
{{< note >}}
9951010
ExternalName accepts an IPv4 address string, but as a DNS names comprised of digits, not as an IP address. ExternalNames that resemble IPv4 addresses are not resolved by CoreDNS or ingress-nginx because ExternalName
9961011
is intended to specify a canonical DNS name. To hardcode an IP address, consider using
@@ -1173,7 +1188,7 @@ of the Service.
11731188

11741189
{{< note >}}
11751190
You can also use {{< glossary_tooltip term_id="ingress" >}} in place of Service
1176-
to expose HTTP / HTTPS Services.
1191+
to expose HTTP/HTTPS Services.
11771192
{{< /note >}}
11781193

11791194
### PROXY protocol
@@ -1189,6 +1204,7 @@ incoming connection, similar to this example
11891204
```
11901205
PROXY TCP4 192.0.2.202 10.0.42.7 12345 7\r\n
11911206
```
1207+
11921208
followed by the data from the client.
11931209
11941210
### SCTP
@@ -1227,13 +1243,8 @@ SCTP is not supported on Windows based nodes.
12271243
The kube-proxy does not support the management of SCTP associations when it is in userspace mode.
12281244
{{< /warning >}}
12291245
1230-
1231-
12321246
## {{% heading "whatsnext" %}}
12331247
1234-
12351248
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
12361249
* Read about [Ingress](/docs/concepts/services-networking/ingress/)
12371250
* Read about [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
1238-
1239-

0 commit comments

Comments
 (0)