Skip to content

Commit 20c9001

Browse files
authored
Merge pull request #5477 from HirazawaUi/implete-consistent-3721
[KEP-3721] Align KEPs with implemented PRs and documentation.
2 parents 53748cd + a0f6a09 commit 20c9001

File tree

1 file changed

+49
-28
lines changed
  • keps/sig-node/3721-support-for-env-files

1 file changed

+49
-28
lines changed

keps/sig-node/3721-support-for-env-files/README.md

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -250,44 +250,65 @@ the file and `Path` is the relative path in this volume mount filesystem.
250250
```
251251
type EnvVarSource struct {
252252
...
253-
// Selects a key of the env file.
254-
// +optional
255-
FileKeyRef *FileKeySelector `json:"fileKeyRef,omitempty" protobuf:"bytes,5,opt,name=fileKeyRef"`
253+
// FileKeyRef selects a key of the env file.
254+
// Requires the EnvFiles feature gate to be enabled.
255+
//
256+
// +featureGate=EnvFiles
257+
// +optional
258+
FileKeyRef *FileKeySelector `json:"fileKeyRef,omitempty" protobuf:"bytes,5,opt,name=fileKeyRef"`
256259
...
257260
}
258261
259262
type FileKeySelector struct {
260-
// The name of the volume mount containing the env file.
261-
VolumeName string `json:",inline" protobuf:"bytes,1,opt,name=volumeName"`
262-
// The path within the volume from which to select the file.
263-
// May be specified as either an absolute path or relative to the volume.
264-
Path string `json:",inline" protobuf:"bytes,2,opt,name=path"`
265-
// The key within the env file. An invalid key will prevent the pod from starting.
266-
Key string `json:"key" protobuf:"bytes,3,opt,name=key"`
267-
// Specify whether the file or its key must be defined. If the file or key
268-
// does not exist, then the env var is not published.
269-
// If optional is set to true and the specified key does not exist,
270-
// the environment variable will not be set in the Pod's containers.
271-
//
272-
// If optional is set to false and the specified key does not exist,
273-
// an error will be returned during Pod creation.
274-
// +optional
275-
// +default=false
276-
Optional *bool `json:"optional,omitempty" protobuf:"varint,4,opt,name=optional"`
263+
// The name of the volume mount containing the env file.
264+
// +required
265+
VolumeName string `json:"volumeName" protobuf:"bytes,1,opt,name=volumeName"`
266+
// The path within the volume from which to select the file.
267+
// Must be relative and may not contain the '..' path or start with '..'.
268+
// +required
269+
Path string `json:"path" protobuf:"bytes,2,opt,name=path"`
270+
// The key within the env file. An invalid key will prevent the pod from starting.
271+
// The keys defined within a source may consist of any printable ASCII characters except '='.
272+
// During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters.
273+
// +required
274+
Key string `json:"key" protobuf:"bytes,3,opt,name=key"`
275+
// Specify whether the file or its key must be defined. If the file or key
276+
// does not exist, then the env var is not published.
277+
// If optional is set to true and the specified key does not exist,
278+
// the environment variable will not be set in the Pod's containers.
279+
//
280+
// If optional is set to false and the specified key does not exist,
281+
// an error will be returned during Pod creation.
282+
// +optional
283+
// +default=false
284+
Optional *bool `json:"optional,omitempty" protobuf:"varint,4,opt,name=optional"`
277285
}
278286
```
279287

280288
### Env File
281289

282290
The full specification of an env file:
283291

284-
1. **File Format**: The environment variable (env) file must adhere to valid [.env syntax](https://smartmob-rfc.readthedocs.io/en/latest/2-dotenv.html) to ensure correct parsing. An example:
292+
1. **File Format**: The environment variable (env) file must adhere to valid env file syntax to ensure proper parsing. The syntax for env files is as follows:
293+
* Blank Lines: Blank lines are ignored.
294+
* Leading Spaces: Leading spaces on all lines are ignored.
295+
* Variable Declaration: Variables must be declared as `VAR=VAL`. Spaces surrounding `=` and trailing spaces are ignored.
296+
```
297+
VAR=VAL → VAL
298+
```
299+
* Comments: Lines beginning with # are treated as comments and ignored.
300+
```
301+
# comment
302+
VAR=VAL → VAL
303+
VAR=VAL # not a comment → VAL # not a comment
304+
```
305+
* Line Continuation: A backslash (`\`) at the end of a variable declaration line indicates the value continues on the next line. The lines are joined with a single space.
306+
```
307+
VAR=VAL \
308+
VAL2
309+
→ VAL VAL2
310+
```
285311
286-
```
287-
KEY1=VALUE1
288-
KEY2=VALUE2
289-
...
290-
```
291312
292313
2. **Variable Naming**: We will apply the same variable name [restrictions](https://github.com/kubernetes/kubernetes/blob/a7ca13ea29ba5b3c91fd293cdbaec8fb5b30cee2/pkg/apis/core/validation/validation.go#L2583-L2596) as other API-defined env vars.
293314
@@ -319,7 +340,6 @@ Below are the ones we mapped and their outcome once this KEP is implemented.
319340
|4. Either the filepath or key specified in `FileKeySelector` field does not exist but `optional` field is set to true | Pod created | Container starts and env vars are not populated. |
320341
|5. The specified file is not a parsable env file. | Pod created | Container fails to start and error message is reported in the events.|
321342
|6. The specified file contains invalid env var names. | Pod created | Container fails to start and erorr message is reported in the events.|
322-
|7. The container's UID does not have permission to read the env file. | Pod created | Container fails to start and erorr message is reported in the events.|
323343
324344
325345
### Security Considerations
@@ -552,7 +572,8 @@ N/A
552572
## Implementation History
553573
554574
* 2023/02/15: Initial proposal
555-
* 2024/06/06: Open the new PR and continue implementing the KEP.
575+
* 2025/06/06: Open the new PR and continue implementing the KEP.
576+
* 2025/08/13: Align KEPs with implemented PRs and documentation.
556577
557578
## Drawbacks
558579

0 commit comments

Comments
 (0)