dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
4.58k stars 644 forks source link

Yaml serialization of Kubernetes resources generates yaml that kubectl/helm won't parse #9382

Closed abbottdev closed 10 hours ago

abbottdev commented 4 weeks ago

Is there an existing issue for this?

Describe the bug

I'm looking at the (preview) builds but found that the YAML that is generated by the new kubernetes k8s publisher is incorrect - it's serializing port and containerPorts to be an intOrString but when it's a port encoded string.

Looking through the release notes it looks like these type defs were updated to be generated based on the go files rather than an independent schema - either way - this is rake someone will stand on!

Expected Behavior

The YAML files that are generated by aspire publish work with the latest versions of helm.

Steps To Reproduce

Run:

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           9.0.105
 Commit:            b7deac6d42
 Workload version:  9.0.100-manifests.3b27a542
 MSBuild version:   17.12.32+b7deac6d4

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  24.04
 OS Platform: Linux
 RID:         ubuntu.24.04-x64
 Base Path:   /usr/lib/dotnet/sdk/9.0.105/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.4
  Architecture: x64
  Commit:       b7deac6d42

.NET SDKs installed:
  8.0.116 [/usr/lib/dotnet/sdk]
  9.0.105 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.16 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.4 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.16 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.4 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Anything else?

.NET Aspire versions:

    <PackageReference Include="Aspire.Hosting.AppHost" Version="9.3.0-preview.1.25265.1" />
    <PackageReference Include="Aspire.Hosting.Kubernetes" Version="9.3.0-preview.1.25265.1" />
char8t commented 4 weeks ago

I have the very same problem as well as:

Also use of dash for the service name in aspire causes issues with variables:

Error: parse error at (aspire/templates/ticsems-postgres/secret.yaml:10): bad character U+002D '-'

---
apiVersion: "v1"
kind: "Secret"
metadata:
  name: "ticsems-postgres-secrets"
  labels:
    app: "aspire"
    component: "ticsems-postgres"
stringData:
  POSTGRES_PASSWORD: "{{ .Values.secrets.ticsems-postgres.ticsems_postgres_password }}"
type: "Opaque"

And the POSTGRES_PASSWORD variable is parsed from the wrong section

Error: template: aspire/templates/ticsemsgrpc/secret.yaml:10:101: executing "aspire/templates/ticsemsgrpc/secret.yaml" at <.Values.secrets.ticsemsgrpc.ticsemspostgres_password>: nil pointer evaluating interface {}.ticsemspostgres_password
...
secrets:
  ticsemspostgres:
    POSTGRES_PASSWORD: "blubb"
...
abbottdev commented 4 weeks ago

Yeah, I noticed the variables aren't escaped correctly with dashes too - I could work around that with a rename but the port mapping I can't work around without post-processing steps. The file looks autogen'd based on some schema but it's not documented how to regenerate otherwise I'd send a PR! 😄

Related #830