Skip to content

Add Kubernetes manifest ATS API#16883

Open
sebastienros wants to merge 3 commits intomainfrom
sebastienros/sebros-kubernetes-ats-warning
Open

Add Kubernetes manifest ATS API#16883
sebastienros wants to merge 3 commits intomainfrom
sebastienros/sebros-kubernetes-ats-warning

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

Description

The Kubernetes ATS SDK dump warned because KubernetesResource.AdditionalResources exposed List<BaseKubernetesResource>, a C#-oriented customization model that is not an ATS-compatible polyglot contract. This change keeps AdditionalResources available as the C# escape hatch, but excludes it from ATS and adds a polyglot-friendly server-side manifest helper instead.

KubernetesResource.AddManifest(...) now creates a KubernetesManifestResource server-side and returns an opaque handle that can be configured with WithNamespace, WithLabel, WithAnnotation, and scalar WithField(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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

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>
Copilot AI review requested due to automatic review settings May 8, 2026 17:29
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16883

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16883"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.AdditionalResources as ATS-ignored and add KubernetesResource.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.

Comment thread src/Aspire.Hosting.Kubernetes/KubernetesManifestResource.cs
Comment thread tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs
Comment thread src/Aspire.Hosting.Kubernetes/Yaml/KubernetesManifestResourceYamlConverter.cs Outdated
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>
Comment thread src/Aspire.Hosting.Kubernetes/KubernetesManifestResource.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

🎬 CLI E2E Test Recordings — 77 recordings uploaded (commit 76640cd)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LatestCliCanStartStableChannelAppHost ▶️ View Recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25586555747

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants