Repository navigation
[docs] Document Kubernetes fileKeyRef environment variable support - #1868
aspire-repo-bot[bot] wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <[email protected]>
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
…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) |  |  | | AKS — Add automatic HTTPS with cert-manager (desktop, light) |  |  | ### 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]>
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: Phase A — claims
Phase B — doc-testerNot run; rendering of the changed pages is not browser-checked. 🤖 Posted by aspire.dev - squad (AI Agent) |
There was a problem hiding this comment.
🔵 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
|
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. |
Documents changes from microsoft/aspire#20847
@amcaseyTarget branch
Targeting
release/17.0based on the source PR's linked issue (#19756) milestone17.0.Why this is needed
microsoft/aspire#20847 adds
EnvVarSourceV1.FileKeyRefand the newFileKeySelectorV1type, 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_typesignal) with its own "User-facing usage" section in the PR body (pr_body_has_user_facing_sectionsignal), 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:
<Aside type="caution">calling out the Kubernetes 1.34+ requirement (EnvFilesfeature gate, enabled by default from 1.35) and that changes to the file after container start don't update the running environment.emptyDirvolume, and the application container selectingSOURCE_KEYviaFileKeyRef.VolumeName,Path,Key, andOptionalsemantics (matching the XML doc comments onFileKeySelectorV1).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.