Add Kubernetes manifest ATS API#16883
Open
sebastienros wants to merge 3 commits intomainfrom
Open
Conversation
Add a polyglot-friendly Kubernetes manifest helper that creates custom manifests server-side and returns an opaque handle for configuration. Keep AdditionalResources as the C# customization escape hatch while excluding it from ATS generation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16883Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16883" |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a polyglot-friendly way to attach arbitrary Kubernetes manifests to a published Kubernetes service by introducing a server-side KubernetesManifestResource handle and excluding the C#-specific AdditionalResources list from ATS export.
Changes:
- Mark
KubernetesResource.AdditionalResourcesas ATS-ignored and addKubernetesResource.AddManifest(...)for creating/configuring custom manifest resources server-side. - Add
KubernetesManifestResource+ YAML serialization support so custom manifests can be emitted into generated Helm templates. - Update polyglot AppHost samples and add a publisher test that validates a custom manifest is emitted.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.ts | Demonstrates the new addManifest polyglot API for emitting a custom KEDA-style manifest. |
| tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/Python/apphost.py | Updates Python sample to configure a custom manifest via add_manifest. |
| tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/Java/AppHost.java | Updates Java sample to configure a custom manifest via addManifest. |
| tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/Go/apphost.go | Updates Go sample to configure a custom manifest via AddManifest. |
| tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs | Adds test coverage asserting a custom manifest template file is generated and contains expected YAML fragments. |
| src/Aspire.Hosting.Kubernetes/Yaml/KubernetesManifestResourceYamlConverter.cs | Introduces a YAML converter to serialize KubernetesManifestResource into the emitted Helm templates. |
| src/Aspire.Hosting.Kubernetes/KubernetesResource.cs | Adds AddManifest(...) API and excludes AdditionalResources from ATS export. |
| src/Aspire.Hosting.Kubernetes/KubernetesPublishingContext.cs | Registers the new YAML converter with the Kubernetes publishing serializer. |
| src/Aspire.Hosting.Kubernetes/KubernetesManifestResource.cs | Implements the exported manifest handle API (WithNamespace/WithLabel/WithAnnotation/WithField) and value normalization. |
Normalize whole-number manifest fields before YAML serialization so polyglot number inputs do not emit schema-invalid floats for integer Kubernetes fields. Clarify the unsupported YAML deserialization message and add regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
eerhardt
reviewed
May 8, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🎬 CLI E2E Test Recordings — 77 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25586555747 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Kubernetes ATS SDK dump warned because
KubernetesResource.AdditionalResourcesexposedList<BaseKubernetesResource>, a C#-oriented customization model that is not an ATS-compatible polyglot contract. This change keepsAdditionalResourcesavailable as the C# escape hatch, but excludes it from ATS and adds a polyglot-friendly server-side manifest helper instead.KubernetesResource.AddManifest(...)now creates aKubernetesManifestResourceserver-side and returns an opaque handle that can be configured withWithNamespace,WithLabel,WithAnnotation, and scalarWithField(path, value)calls. This avoids serializing locally instantiated DTO/object graphs across ATS, where opaque resource references would not preserve handle semantics.We could also add well-known helper methods for specific Kubernetes resources that we decide are mandatory first-class scenarios, such as selected ConfigMap, Secret, or KEDA-oriented helpers. This PR does not add those yet because exporting every Kubernetes resource or sub-resource would effectively expose the Kubernetes serialization object model as public polyglot API. The generic manifest handle fixes the warning and unblocks custom-resource scenarios while preserving space to add curated, scenario-specific helpers later.
Updated the Kubernetes polyglot apphost samples for TypeScript, Python, Java, and Go, and added publisher coverage for emitting a custom KEDA-style manifest.
Fixes # (issue): N/A
Checklist
<remarks />and<code />elements on your triple slash comments?