Skip to content

[docs] Document Kubernetes fileKeyRef environment variable support - #1868

Closed
aspire-repo-bot[bot] wants to merge 1 commit into
release/17.0from
docs/pr-20847-38099325716-1-df7c2eb396b0f17f
Closed

aspire-repo-bot[bot] wants to merge 1 commit into
release/17.0from
docs/pr-20847-38099325716-1-df7c2eb396b0f17f

Conversation

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Documents changes from microsoft/aspire#20847

@amcasey

Target branch

Targeting release/17.0 based on the source PR's linked issue (#19756) milestone 17.0.

Why this is needed

microsoft/aspire#20847 adds EnvVarSourceV1.FileKeyRef and the new FileKeySelectorV1 type, letting Kubernetes workloads source an individual environment variable from a key in an env file written by an init container — without mounting the file into the application container or overriding its entrypoint. This is a new public API (new_public_type signal) with its own "User-facing usage" section in the PR body (pr_body_has_user_facing_section signal), so it needs a docs update on the Kubernetes integration page.

What changed

Added a new "Select environment variables from a generated file" section to the Kubernetes integration reference page, between the existing "Inline ephemeral CSI volumes" and "Customize individual resources" sections. It includes:

  • A <Aside type="caution"> calling out the Kubernetes 1.34+ requirement (EnvFiles feature gate, enabled by default from 1.35) and that changes to the file after container start don't update the running environment.
  • A C# code example modeled on the PR's own usage sample, showing the init container writing the file to an emptyDir volume, and the application container selecting SOURCE_KEY via FileKeyRef.
  • A short explanation of VolumeName, Path, Key, and Optional semantics (matching the XML doc comments on FileKeySelectorV1).
  • A note that this C# resource-model type isn't exported as a typed TypeScript AppHost API, consistent with how the page documents the nearby CSI volumes feature.

Files modified

  • src/frontend/src/content/docs/integrations/compute/kubernetes.mdx (updated)

No new pages were created; this is an addition to the existing Kubernetes integration reference page.

Generated by PR Documentation Check for #20847 · copilot · auto · 58.7 AIC · ⌖ 10.5 AIC · ⊞ 20.4K · ◷

@aspire-repo-bot aspire-repo-bot Bot added the docs-from-code Copilot initiated issue from dotnet/aspire repo label Oct 11, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor Author

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #1868. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #1868 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

David Pine (IEvangelist) pushed a commit that referenced this pull request Nov 1, 2026
…2002)

## Summary

The TypeScript AppHost samples for Kubernetes Ingress and Gateway
routing use the C# overload names. Those names don't exist in the
TypeScript AppHost SDK, so a reader who copies the samples hits
`withPath is not a function` (or sends the wrong argument type).

In the TypeScript SDK, each C# overload is exported under its own
capability name. Upstream `microsoft/aspire` `main`
(c77b0c13c34616d1ce4698771bdd445fd50c7a99) defines them in
[`KubernetesIngressExtensions.cs`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/src/Aspire.Hosting.Kubernetes/KubernetesIngressExtensions.cs),
[`KubernetesGatewayExtensions.cs`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/src/Aspire.Hosting.Kubernetes/KubernetesGatewayExtensions.cs)
and
[`CertManagerExtensions.cs`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/src/Aspire.Hosting.Kubernetes/CertManagerExtensions.cs).
The in-repo `src/data/ts-modules/Aspire.Hosting.Kubernetes.*.json`
surface matches them.

| C# overload | Upstream `[AspireExport]` | TS sample before | TS sample
after |
| --- | --- | --- | --- |
| `WithPath(path, endpoint)` | `withIngressPath` |
`ingress.withPath(...)` | `ingress.withIngressPath(...)` |
| `WithTls()` (Ingress) | `withIngressTlsAuto` | `ingress.withTls()` (TS
`withTls` requires `secretName`) | `ingress.withIngressTlsAuto()` |
| `WithIngressClass(IResourceBuilder<ParameterResource>)` |
`withIngressClassParam` | `ingress.withIngressClass(param)` |
`ingress.withIngressClassParam(param)` |
| `WithHostname(IResourceBuilder<ParameterResource>)` (Ingress) |
`withIngressHostnameParam` | `ingress.withHostname(param)` |
`ingress.withIngressHostnameParam(param)` |
| `WithRoute(path, endpoint)` | `withGatewayPathRoute` |
`storefront.withRoute(...)` | `storefront.withGatewayPathRoute(...)` |
| `WithTls(issuer)` (Gateway) | `withGatewayTlsIssuer` |
`storefront.withTls(letsencrypt)` |
`storefront.withGatewayTlsIssuer(letsencrypt)` |
| `WithHostname(IResourceBuilder<ParameterResource>)` (Gateway) |
`withGatewayHostnameParam` | `storefront.withHostname(param)` |
`storefront.withGatewayHostnameParam(param)` |

Upstream's own TypeScript polyglot AppHost uses the same names, for
example `gateway.withGatewayTlsIssuer(stagingIssuer)` in
[`tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.mts`](https://github.com/microsoft/aspire/blob/c77b0c13c34616d1ce4698771bdd445fd50c7a99/tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.mts).

This PR changes 15 sample lines in 6 TypeScript blocks:

- `deployment/kubernetes-ingress.mdx`: 3 blocks.
- `deployment/kubernetes/aks.mdx`: 3 blocks.

The C# samples and the prose are unchanged.

### How this was found

I ran a systematic TypeScript AppHost drift audit across all docs:

- **Scope:** 1,264 TS fences in 611 files. 398 are `twoslash` blocks,
which the build already type-checks.
- **Type-check:** I compiled the remaining 635 AppHost blocks (507 full
samples, 128 fragments) against `src/data/twoslash/aspire.d.ts` with the
repo's twoslash compiler options. That produced 202 English diagnostics.
- **Triage:**
- Argument-shape diagnostics were mostly gaps in the local `.d.ts`
generator, not sample errors. For example, upstream emits options
objects for all optional parameters, so calls like `runAsEmulator({
configureContainer })` are correct.
- Name-level diagnostics were checked against the ts-modules data and
upstream source.
  - The Ingress/Gateway names are the confirmed group fixed here.
  - `addAzureCosmosDb` is already handled by #2001.

### Regression test

The new `tests/unit/typescript-kubernetes-routing-apis.vitest.test.ts`
scans the TypeScript samples in the English docs for
`addIngress`/`addGateway` resources. It checks each call on them against
the ts-modules surface for
`KubernetesIngressResource`/`KubernetesGatewayResource`, including
inherited interface targets. It flags:

- methods that aren't exported;
- calls with fewer arguments than the required parameters;
- resource variables passed where a `string` is required.

On `main` it fails with 14 problems:

```
deployment/kubernetes/aks.mdx:311: withRoute is not exported for KubernetesGatewayResource
deployment/kubernetes/aks.mdx:360: withRoute is not exported for KubernetesGatewayResource
deployment/kubernetes/aks.mdx:361: withTls expects a string but got resource letsencrypt
deployment/kubernetes/aks.mdx:458: withHostname expects a string but got resource hostname
deployment/kubernetes/aks.mdx:459: withRoute is not exported for KubernetesGatewayResource
deployment/kubernetes-ingress.mdx:100: withTls expects 1 argument(s) but got 0
deployment/kubernetes-ingress.mdx:103: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:104: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:137: withTls expects 1 argument(s) but got 0
deployment/kubernetes-ingress.mdx:140: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:141: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:198: withIngressClass expects a string but got resource ingressClass
deployment/kubernetes-ingress.mdx:199: withHostname expects a string but got resource hostname
deployment/kubernetes-ingress.mdx:200: withTls expects 1 argument(s) but got 0
```

With this change, the test passes.

The 15th line, `aks.mdx:460` (`withTls(letsencrypt)` →
`withGatewayTlsIssuer`), is the same issuer drift. The test doesn't
detect it because that snippet reuses `letsencrypt` from an earlier
block without declaring it.

### Screenshots

The only visual change is the rendered TypeScript tab text. Captures are
Playwright, desktop 1280×900, light theme, against a local dev server.

| | Before (`main`) | After |
| --- | --- | --- |
| Kubernetes Ingress — Routing paths to services (desktop, light) |
![Before: Ingress TypeScript sample uses withTls() and
withPath](https://github.com/user-attachments/assets/bf1d5fab-d6bb-4a01-9eba-1ea78fb2e4a8)
| ![After: Ingress TypeScript sample uses withIngressTlsAuto() and
withIngressPath](https://github.com/user-attachments/assets/9ac6df88-51c5-41fd-b231-bb0b03af4fc0)
|
| AKS — Add automatic HTTPS with cert-manager (desktop, light) |
![Before: Gateway TypeScript sample uses withRoute and
withTls(letsencrypt)](https://github.com/user-attachments/assets/a7343a3e-0887-4014-a119-2dd3e34211c6)
| ![After: Gateway TypeScript sample uses withGatewayPathRoute and
withGatewayTlsIssuer](https://github.com/user-attachments/assets/afc3534c-6ef7-4bfd-8cb3-fde8d1f99cbd)
|

### Out of scope

The TypeScript samples in `kubernetes-ingress-aks.mdx` and
`kubernetes-gateway-aks.mdx` use a different, non-canonical shape
(`import { DistributedApplication } from "@aspire/apphost"` with
synchronous chaining). Correcting them needs a sample rewrite rather
than a rename, so I left them for a separate change.

Overlap check: no open issue or PR mentions these names. #1996 and #1868
touch other Kubernetes pages but not these samples.

## Third-party links and affiliations

None. The links above point to `microsoft/aspire` source.

## Validation

- `npx vitest run
tests/unit/typescript-kubernetes-routing-apis.vitest.test.ts`: fails on
`main` (14 problems above) and passes with this change.
- `npx vitest run`: 85 files, 1,121 passed, 1 skipped.
- `npx eslint . --max-warnings 0`: clean.
- `npx prettier --check` on the new test: clean. The two `.mdx` files
already have Prettier warnings on `main`, unchanged by this PR.
- Playwright before/after screenshots above.

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <[email protected]>
Co-authored-by: Copilot <[email protected]>

Copy link
Copy Markdown
Member

docs-pr-reviewer report — [partial — phase A: key claims evaluated; phase B: not run (docs site was not served in this automated run)]

Recommendation: approve

Source used: microsoft/aspire main via merged source PR microsoft/aspire#20847 (docs PR targets release/17.0; no matching branch checked).
PR status: draft, mergeable, opened 2026-10-11 (not stale)

Phase A — claims

  • ✅ verified: EnvVarSourceV1.FileKeyRef (FileKeySelectorV1) added in Aspire.Hosting.Kubernetes.Resources; XML doc says it requires Kubernetes 1.34+ with EnvFiles enabled.
  • ⚠️ nuance (not re-verified): 'enabled by default from Kubernetes 1.35' and 'file changes after start don't update env' come from Kubernetes behavior, not Aspire source. Sample property names (VolumeName, Path) should be checked against FileKeySelectorV1.

Phase B — doc-tester

Not run; rendering of the changed pages is not browser-checked.

🤖 Posted by aspire.dev - squad (AI Agent)

@IEvangelist
David Pine (IEvangelist) marked this pull request as ready for review November 13, 2026 14:57
Copilot AI balanced review requested due to automatic review settings November 13, 2026 14:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new APIs, Optional semantics, and Kubernetes feature-gate requirements remain unverified because upstream sources and build/runtime validation are unavailable.

No open issues 🎉

What changed in this PR

Adds documentation for Kubernetes fileKeyRef environment variable support to the existing Kubernetes integration reference for Aspire 17.0.

Changes:

  • Adds a C# example that reads an environment variable from a file generated by an init container.
  • Explains Kubernetes version and feature-gate requirements, plus environment update limitations.
  • Describes selector properties, optional-value behavior, and typed TypeScript API availability.
File Description
src/​frontend/​src/​content/​docs/​integrations/​compute/​kubernetes.mdx Adds generated-file environment variable guidance, an example, and compatibility requirements.

Review effort: Balanced

@mitchdenny

Copy link
Copy Markdown
Member

We don't document the K8S object model at this level. This was more about just making sure these properties were present we don't need to call it out specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants