You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-network/4427-relaxed-dns-search-validation/README.md
+49-13Lines changed: 49 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,14 +86,18 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
86
86
## Summary
87
87
88
88
Currently, Kubernetes validates search string in the `dnsConfig.searches` according to [RFC-1123](https://datatracker.ietf.org/doc/html/rfc1123)
89
-
which defines restrictions for hostnames. While most DNS names identify hosts, there are record types (like SRV) that don't. For these, it's less clear
89
+
which defines restrictions for hostnames. However, there are reasons why this validation is too strict for the use in `dnsConfig.searches`.
90
+
91
+
Firstly, while most DNS names identify hosts, there are record types (like SRV) that don't. For these, it's less clear
90
92
whether hostname restrictions apply, for example [RFC-1035 Section 2.3.1](https://datatracker.ietf.org/doc/html/rfc1035#section-2.3.1) points out
91
93
that it's better to stick with valid host names but also states that labels must meet the hostname requirements.
92
94
93
95
In practice, legacy workloads sometimes include an underscore (`_`) in DNS names and DNS servers will generally allow this.
94
96
97
+
Secondly, users may require setting `dnsConfig.searches` to a single dot character (`.`) should they wish to avoid unnessesary DNS lookup calls to internal Kubernetes domain names.
98
+
95
99
This KEP proposes relaxing the checks on DNS search strings only. Allowing these values in the `searches` field of `dnsConfig` allows pods to
96
-
resolve short names properly in cases where the search string contains an underscore.
100
+
resolve short names properly in cases where the search string contains an underscore or is a single dot character.
97
101
98
102
## Motivation
99
103
@@ -131,15 +135,47 @@ Allowing underscores in the search string allows integration with legacy workloa
131
135
these names within Kubernetes. Since having underscores in a name creates other issues (such as inability to obtain a publicly trusted TLS certificate),
132
136
search strings seem like the only area where this is likely to occur.
133
137
138
+
Should a user require a DNS query to resolve to an external domain first (before the internal Kubernetes domain names) they would require adding a dot to the `dnsConfig.searches` list.
139
+
140
+
An example of this configuration could look like this:
141
+
142
+
```
143
+
apiVersion: v1
144
+
kind: Pod
145
+
metadata:
146
+
namespace: default
147
+
name: dns-example
148
+
spec:
149
+
containers:
150
+
- name: test
151
+
image: nginx
152
+
dnsPolicy: "None"
153
+
dnsConfig:
154
+
nameservers:
155
+
- 1.2.3.4
156
+
searches:
157
+
- .
158
+
- default.svc.cluster.local
159
+
- svc.cluster.local
160
+
- cluster.local
161
+
```
162
+
163
+
Applying the above Pod spec will result in the following error:
164
+
165
+
```
166
+
The Pod "dns-example" is invalid: spec.dnsConfig.searches[0]: Invalid value: "": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
167
+
```
168
+
134
169
### Goals
135
170
136
171
- Support workloads that need to resolve DNS short names where the full DNS name includes an underscore (`_`).
172
+
- Allow users to use a single dot character `.` as a search string
137
173
138
174
## Proposal
139
175
140
176
Introduce a RelaxedDNSSearchValidation feature gate which is disabled by default. When the feature gate is enabled,
141
177
a new DNS name validation function will be used, which keeps the existing validation logic but also allows an underscore (`_`) in any place
142
-
where a dash (`-`) would be allowed currently.
178
+
where a dash (`-`) would be allowed currently and allowing a single dot (`.`) character.
143
179
144
180
Since the relaxed check allows previously invalid values, care must be taken to support cluster downgrades safely. To accomplish this, the validation will distinguish between new resources and updates to existing resources:
145
181
- When the feature gate is disabled:
@@ -199,20 +235,20 @@ with a value that contains an underscore.
199
235
200
236
- Gate On
201
237
- New value
202
-
- Underscore (expect validation to pass)
203
-
- No Underscore (expect validation to pass)
238
+
- Underscore and/or dot (expect validation to pass)
239
+
- No Underscore and/or dot (expect validation to pass)
204
240
- Existing value
205
-
- Underscore (expect validation to pass)
206
-
- No Underscore (expect validation to pass)
241
+
- Underscore and/or dot (expect validation to pass)
242
+
- No Underscore and/or dot (expect validation to pass)
207
243
- Gate Off
208
244
- New value
209
-
- Underscore (expect validation to fail)
210
-
- No Underscore (expect validation to pass)
245
+
- Underscore and/or dot (expect validation to fail)
246
+
- No Underscore and/or dot (expect validation to pass)
211
247
- Existing value
212
-
- Underscore (expect validation to pass)
213
-
- No Underscore (expect validation to pass)
248
+
- Underscore and/or dot (expect validation to pass)
249
+
- No Underscore and/or dot (expect validation to pass)
214
250
- Ratcheting
215
-
- Turn gate on, write search string with underscore, turn gate off, change unrelated property on the object and verify that it passes validation, remove search value with the underscore, verify that saving a search string with an underscore is now prevented
251
+
- Turn gate on, write search string with underscore and/or dot, turn gate off, change unrelated property on the object and verify that it passes validation, remove search value with the underscore and/or dot, verify that saving a search string with an underscore and/or dot is now prevented
216
252
217
253
In addition to the Pod itself, each integration test should be repeated with objects that contain a pod spec template:
218
254
- Deployment
@@ -221,7 +257,7 @@ In addition to the Pod itself, each integration test should be repeated with obj
221
257
222
258
##### e2e tests
223
259
224
-
- Add a test that verifies successful creation of a pod whose `dnsConfig.searches` contains an underscore
260
+
- Add a test that verifies successful creation of a pod whose `dnsConfig.searches` contains an underscore and/or dot
225
261
- Add tests that verify successful creation of objects with a podTemplate whose `dnsConfig.searches`
0 commit comments