Skip to content

Commit 8121620

Browse files
authored
Merge pull request #36675 from sftim/20221208_refactor_service_docs
Migrate reference details out Service concept
2 parents 58d150d + b581bd4 commit 8121620

File tree

6 files changed

+506
-374
lines changed

6 files changed

+506
-374
lines changed

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

Lines changed: 27 additions & 373 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Networking Reference
3+
content_type: reference
4+
weight: 85
5+
---
6+
7+
<!-- overview -->
8+
This section of the Kubernetes documentation provides reference details
9+
of Kubernetes networking.
10+
11+
<!-- body -->

content/en/docs/reference/ports-and-protocols.md renamed to content/en/docs/reference/networking/ports-and-protocols.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Ports and Protocols
33
content_type: reference
4-
weight: 90
4+
weight: 40
55
---
66

77
When running Kubernetes in an environment with strict network boundaries, such
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: Protocols for Services
3+
content_type: reference
4+
weight: 10
5+
---
6+
7+
<!-- overview -->
8+
If you configure a {{< glossary_tooltip text="Service" term_id="service" >}},
9+
you can select from any network protocol that Kubernetes supports.
10+
11+
Kubernetes supports the following protocols with Services:
12+
13+
- [`SCTP`](#protocol-sctp)
14+
- [`TCP`](#protocol-tcp) _(the default)_
15+
- [`UDP`](#protocol-udp)
16+
17+
When you define a Service, you can also specify the
18+
[application protocol](/docs/concepts/services-networking/service/#application-protocol)
19+
that it uses.
20+
21+
This document details some special cases, all of them typically using TCP
22+
as a transport protocol:
23+
24+
- [HTTP](#protocol-http-special) and [HTTPS](#protocol-http-special)
25+
- [PROXY protocol](#protocol-proxy-special)
26+
- [TLS](#protocol-tls-special) termination at the load balancer
27+
28+
<!-- body -->
29+
## Supported protocols {#protocol-support}
30+
31+
There are 3 valid values for the `protocol` of a port for a Service:
32+
33+
### `SCTP` {#protocol-sctp}
34+
35+
{{< feature-state for_k8s_version="v1.20" state="stable" >}}
36+
37+
When using a network plugin that supports SCTP traffic, you can use SCTP for
38+
most Services. For `type: LoadBalancer` Services, SCTP support depends on the cloud
39+
provider offering this facility. (Most do not).
40+
41+
SCTP is not supported on nodes that run Windows.
42+
43+
#### Support for multihomed SCTP associations {#caveat-sctp-multihomed}
44+
45+
The support of multihomed SCTP associations requires that the CNI plugin can support the assignment of multiple interfaces and IP addresses to a Pod.
46+
47+
NAT for multihomed SCTP associations requires special logic in the corresponding kernel modules.
48+
49+
{{< note >}}
50+
The kube-proxy does not support the management of SCTP associations when it is in userspace mode.
51+
{{< /note >}}
52+
53+
54+
### `TCP` {#protocol-tcp}
55+
56+
You can use TCP for any kind of Service, and it's the default network protocol.
57+
58+
### `UDP` {#protocol-udp}
59+
60+
You can use UDP for most Services. For `type: LoadBalancer` Services,
61+
UDP support depends on the cloud provider offering this facility.
62+
63+
64+
## Special cases
65+
66+
### HTTP {#protocol-http-special}
67+
68+
If your cloud provider supports it, you can use a Service in LoadBalancer mode to
69+
configure a load balancer outside of your Kubernetes cluster, in a special mode
70+
where your cloud provider's load balancer implements HTTP / HTTPS reverse proxying,
71+
with traffic forwarded to the backend endpoints for that Service.
72+
73+
Typically, you set the protocol for the Service to `TCP` and add an
74+
{{< glossary_tooltip text="annotation" term_id="annotation" >}}
75+
(usually specific to your cloud provider) that configures the load balancer
76+
to handle traffic at the HTTP level.
77+
This configuration might also include serving HTTPS (HTTP over TLS) and
78+
reverse-proxying plain HTTP to your workload.
79+
80+
{{< note >}}
81+
You can also use an {{< glossary_tooltip term_id="ingress" >}} to expose
82+
HTTP/HTTPS Services.
83+
{{< /note >}}
84+
85+
You might additionally want to specify that the
86+
[application protocol](/docs/concepts/services-networking/service/#application-protocol)
87+
of the connection is `http` or `https`. Use `http` if the session from the
88+
load balancer to your workload is HTTP without TLS, and use `https` if the
89+
session from the load balancer to your workload uses TLS encryption.
90+
91+
### PROXY protocol {#protocol-proxy-special}
92+
93+
If your cloud provider supports it, you can use a Service set to `type: LoadBalancer`
94+
to configure a load balancer outside of Kubernetes itself, that will forward connections
95+
wrapped with the
96+
[PROXY protocol](https://www.haproxy.org/download/2.5/doc/proxy-protocol.txt).
97+
98+
The load balancer then sends an initial series of octets describing the
99+
incoming connection, similar to this example (PROXY protocol v1):
100+
101+
```
102+
PROXY TCP4 192.0.2.202 10.0.42.7 12345 7\r\n
103+
```
104+
105+
The data after the proxy protocol preamble are the original
106+
data from the client. When either side closes the connection,
107+
the load balancer also triggers a connection close and sends
108+
any remaining data where feasible.
109+
110+
Typically, you define a Service with the protocol to `TCP`.
111+
You also set an annotation, specific to your
112+
cloud provider, that configures the load balancer to wrap each incoming connection in the PROXY protocol.
113+
114+
### TLS {#protocol-tls-special}
115+
116+
If your cloud provider supports it, you can use a Service set to `type: LoadBalancer` as
117+
a way to set up external reverse proxying, where the connection from client to load
118+
balancer is TLS encrypted and the load balancer is the TLS server peer.
119+
The connection from the load balancer to your workload can also be TLS,
120+
or might be plain text. The exact options available to you depend on your
121+
cloud provider or custom Service implementation.
122+
123+
Typically, you set the protocol to `TCP` and set an annotation
124+
(usually specific to your cloud provider) that configures the load balancer
125+
to act as a TLS server. You would configure the TLS identity (as server,
126+
and possibly also as a client that connects to your workload) using
127+
mechanisms that are specific to your cloud provider.

0 commit comments

Comments
 (0)