# FileKeySelectorV1

- Kind: `class`
- Package: [Aspire.Hosting.Kubernetes](/reference/api/csharp/aspire.hosting.kubernetes.md)
- Version: `17.0.0`
- Namespace: `Aspire.Hosting.Kubernetes.Resources`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting.Kubernetes/Resources/FileKeySelectorV1.cs)

Selects a key from an environment variable file in a pod's emptyDir volume.

## Definition

```csharp
namespace Aspire.Hosting.Kubernetes.Resources;

public sealed class FileKeySelectorV1
{
    // ...
}
```

## Remarks

Requires Kubernetes 1.34 or later with the EnvFiles feature enabled. The feature is enabled by default from Kubernetes 1.35. An init container can write the file before the consuming container starts. Changes to the file do not update the environment of a running container.

## Constructors

- [FileKeySelectorV1](/reference/api/csharp/aspire.hosting.kubernetes/filekeyselectorv1/constructors.md#constructor)

## Properties

- [Key](/reference/api/csharp/aspire.hosting.kubernetes/filekeyselectorv1/properties.md#key) : `string` `get; set` -- Gets or sets the key whose value is selected from the environment variable file. Keys may contain printable ASCII characters except `=`. An invalid key prevents the pod from starting. In Kubernetes 1.34, where EnvFiles is alpha, keys are limited to 128 characters.
- [Optional](/reference/api/csharp/aspire.hosting.kubernetes/filekeyselectorv1/properties.md#optional) : `bool?` `get; set` -- Gets or sets whether the file or key may be absent. When true, a missing file or key leaves the environment variable unset. When false or unspecified, a missing file or key prevents the container from starting.
- [Path](/reference/api/csharp/aspire.hosting.kubernetes/filekeyselectorv1/properties.md#path) : `string` `get; set` -- Gets or sets the file path relative to the volume root. The path must not contain a parent directory component or start with `..`.
- [VolumeName](/reference/api/csharp/aspire.hosting.kubernetes/filekeyselectorv1/properties.md#volumename) : `string` `get; set` -- Gets or sets the name of the emptyDir volume containing the environment variable file.
