@@ -18,22 +18,23 @@ weight: 10
18
18
19
19
{{< glossary_definition term_id="service" length="short" >}}
20
20
21
- With Kubernetes you don't need to modify your application to use an unfamiliar service discovery mechanism.
22
- Kubernetes gives Pods their own IP addresses and a single DNS name for a set of Pods,
23
- and can load-balance across them.
21
+ A key aim of Services in Kubernetes is that you don't need to modify your existing
22
+ application to use an unfamiliar service discovery mechanism.
23
+ You can run code in Pods, whether this is a code designed for a cloud-native world, or
24
+ an older app you've containerized. You use a Service to make that set of Pods available
25
+ on the network so that clients can interact with it.
24
26
25
- <!-- body -->
26
-
27
- ## Motivation
28
-
29
- Kubernetes {{< glossary_tooltip term_id="pod" text="Pods" >}} are created and destroyed
30
- to match the desired state of your cluster. Pods are nonpermanent resources.
31
27
If you use a {{< glossary_tooltip term_id="deployment" >}} to run your app,
32
- it can create and destroy Pods dynamically.
28
+ that Deployment can create and destroy Pods dynamically. From one moment to the next,
29
+ you don't know how many of those Pods are working and healthy; you might not even know
30
+ what those healthy Pods are named.
31
+ Kubernetes {{< glossary_tooltip term_id="pod" text="Pods" >}} are created and destroyed
32
+ to match the desired state of your cluster. Pods are emphemeral resources (you should not
33
+ expect that an individual Pod is reliable and durable).
33
34
34
- Each Pod gets its own IP address, however in a Deployment, the set of Pods
35
- running in one moment in time could be different from
36
- the set of Pods running that application a moment later.
35
+ Each Pod gets its own IP address (Kubernetes expects network plugins to ensure this).
36
+ For a given Deployment in your cluster, the set of Pods running in one moment in
37
+ time could be different from the set of Pods running that application a moment later.
37
38
38
39
This leads to a problem: if some set of Pods (call them "backends") provides
39
40
functionality to other Pods (call them "frontends") inside your cluster,
@@ -42,14 +43,13 @@ to, so that the frontend can use the backend part of the workload?
42
43
43
44
Enter _ Services_ .
44
45
45
- ## Service resources {#service-resource}
46
+ <!-- body -->
46
47
47
- In Kubernetes, a Service is an abstraction which defines a logical set of Pods
48
- and a policy by which to access them (sometimes this pattern is called
49
- a micro-service). The set of Pods targeted by a Service is usually determined
50
- by a {{< glossary_tooltip text="selector" term_id="selector" >}}.
51
- To learn about other ways to define Service endpoints,
52
- see [ Services _ without_ selectors] ( #services-without-selectors ) .
48
+ ## Services in Kubernetes
49
+
50
+ The Service API, part of Kubernetes, is an abstraction to help you expose groups of
51
+ Pods over a network. Each Service object defines a logical set of endpoints (usually
52
+ these endpoints are Pods) along with a policy about how to make those pods accessible.
53
53
54
54
For example, consider a stateless image-processing backend which is running with
55
55
3 replicas. Those replicas are fungible&mdash ; frontends do not care which backend
@@ -59,6 +59,26 @@ track of the set of backends themselves.
59
59
60
60
The Service abstraction enables this decoupling.
61
61
62
+ The set of Pods targeted by a Service is usually determined
63
+ by a {{< glossary_tooltip text="selector" term_id="selector" >}} that you
64
+ define.
65
+ To learn about other ways to define Service endpoints,
66
+ see [ Services _ without_ selectors] ( #services-without-selectors ) .
67
+
68
+ If your workload speaks HTTP, you might choose to use an
69
+ [ Ingress] ( /docs/concepts/services-networking/ingress/ ) to control how web traffic
70
+ reaches that workload.
71
+ Ingress is not a Service type, but it acts as the entry point for your
72
+ cluster. An Ingress lets you consolidate your routing rules into a single resource, so
73
+ that you can expose multiple components of your workload, running separately in your
74
+ cluster, behind a single listener.
75
+
76
+ The [ Gateway] ( https://gateway-api.sigs.k8s.io/#what-is-the-gateway-api ) API for Kubernetes
77
+ provides extra capabilities beyond Ingress and Service. You can add Gateway to your cluster -
78
+ it is a family of extension APIs, implemented using
79
+ {{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResourceDefinitions" >}} -
80
+ and then use these to configure access to network services that are running in your cluster.
81
+
62
82
### Cloud-native service discovery
63
83
64
84
If you're able to use Kubernetes APIs for service discovery in your application,
@@ -69,6 +89,9 @@ whenever the set of Pods in a Service changes.
69
89
For non-native applications, Kubernetes offers ways to place a network port or load
70
90
balancer in between your application and the backend Pods.
71
91
92
+ Either way, your workload can use these [ service discovery] ( #discovering-services )
93
+ mechanisms to find the target it wants to connect to.
94
+
72
95
## Defining a Service
73
96
74
97
A Service in Kubernetes is an
0 commit comments