@@ -71,14 +71,15 @@ balancer in between your application and the backend Pods.
71
71
72
72
## Defining a Service
73
73
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 .
79
79
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:
82
83
83
84
``` yaml
84
85
apiVersion : v1
@@ -94,16 +95,20 @@ spec:
94
95
targetPort : 9376
95
96
` ` `
96
97
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/).
99
104
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).
103
111
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".
107
112
108
113
{{< note >}}
109
114
A Service can map _any_ incoming `port` to a `targetPort`. By default and
@@ -177,8 +182,8 @@ For example:
177
182
* You are migrating a workload to Kubernetes. While evaluating the approach,
178
183
you run only a portion of your backends in Kubernetes.
179
184
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 :
182
187
183
188
` ` ` yaml
184
189
apiVersion: v1
@@ -262,9 +267,9 @@ selector will fail due to this constraint. This prevents the Kubernetes API serv
262
267
from being used as a proxy to endpoints the caller may not be authorized to access.
263
268
{{< /note >}}
264
269
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
266
271
selectors and uses DNS names instead. For more information, see the
267
- [ExternalName](#externalname) section later in this document .
272
+ [ExternalName](#externalname) section.
268
273
269
274
# ## EndpointSlices
270
275
@@ -704,7 +709,7 @@ In a split-horizon DNS environment you would need two Services to be able to rou
704
709
and internal traffic to your endpoints.
705
710
706
711
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 :
708
713
709
714
{{< tabs name="service_tabs" >}}
710
715
{{% tab name="Default" %}}
@@ -1151,9 +1156,9 @@ spec:
1151
1156
- name: http
1152
1157
protocol: TCP
1153
1158
port: 80
1154
- targetPort: 9376
1159
+ targetPort: 49152
1155
1160
externalIPs:
1156
- - 80.11.12.10
1161
+ - 198.51.100.32
1157
1162
` ` `
1158
1163
1159
1164
# # Session stickiness
@@ -1178,13 +1183,17 @@ mechanism Kubernetes provides to expose a Service with a virtual IP address.
1178
1183
1179
1184
# # {{% heading "whatsnext" %}}
1180
1185
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.
1185
1193
1186
- For more context :
1194
+ For more context, read the following :
1187
1195
* [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