-
Notifications
You must be signed in to change notification settings - Fork 809
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When I create a custom BaseKubernetesResource for ServiceExport for my GKE setup it needs to have the same Metadata.Name as the built in KubernetesResource.Service property but if they are equal my custom BaseKubernetesResource overrides the output of service.yaml.
Expected Behavior
Expected behavior is to either merge them to a single file with separator ---
#/k8s-artifacts/templates/api/service.yaml
---
apiVersion: "v1"
kind: "Service"
metadata:
name: "api-service"
labels:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"
spec:
type: "ClusterIP"
selector:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"
ports:
- name: "http"
protocol: "TCP"
port: "{{ .Values.parameters.api.port_http }}"
targetPort: "{{ .Values.parameters.api.port_http }}"
- name: "https"
protocol: "TCP"
port: "{{ .Values.parameters.api.port_https }}"
targetPort: "{{ .Values.parameters.api.port_https }}"
---
apiVersion: "net.gke.io/v1"
kind: "ServiceExport"
metadata:
name: "api-service"
labels:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"
or support two separate files
#/k8s-artifacts/templates/api/service.yaml
---
apiVersion: "v1"
kind: "Service"
metadata:
name: "api-service"
labels:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"
spec:
type: "ClusterIP"
selector:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"
ports:
- name: "http"
protocol: "TCP"
port: "{{ .Values.parameters.api.port_http }}"
targetPort: "{{ .Values.parameters.api.port_http }}"
- name: "https"
protocol: "TCP"
port: "{{ .Values.parameters.api.port_https }}"
targetPort: "{{ .Values.parameters.api.port_https }}"#/k8s-artifacts/templates/api/service-export.yaml
---
apiVersion: "net.gke.io/v1"
kind: "ServiceExport"
metadata:
name: "api-service"
labels:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"
Steps To Reproduce
<!-- Apphost.csproj -->
<Project Sdk="Aspire.AppHost.Sdk/13.1.1">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.Kubernetes" Version="13.1.1-preview.1.26105.8" />
</ItemGroup>
</Project>
// Apphost.cs
using Aspire.Hosting.Kubernetes.Resources;
using YamlDotNet.Serialization;
var builder = DistributedApplication.CreateBuilder(args);
builder.AddKubernetesEnvironment("k8s");
var api = builder.AddProject("api", "../Api/Api.csproj")
.PublishAsKubernetesService(kubernetes =>
{
var serviceExport = new ServiceExportResource();
serviceExport.Metadata.Name = kubernetes.Service.Metadata.Name;
kubernetes.AdditionalResources.Add(serviceExport);
});
await builder.Build().RunAsync();
[YamlSerializable]
public class ServiceExportResource() : BaseKubernetesResource("net.gke.io/v1", "ServiceExport");This code generates this when running aspire publish -o ./k8s-artifacts
#/k8s-artifacts/templates/api/service.yaml
---
apiVersion: "net.gke.io/v1"
kind: "ServiceExport"
metadata:
name: "api-service"
labels:
app.kubernetes.io/name: "apphost"
app.kubernetes.io/component: "api"
app.kubernetes.io/instance: "{{.Release.Name}}"Exceptions (if any)
No response
.NET Version info
dotnet --info
.NET SDK:
Version: 10.0.102
Commit: 4452502459
Workload version: 10.0.100-manifests.e5d3dea4
MSBuild version: 18.0.7+445250245
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.102\
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.
Host:
Version: 10.0.2
Architecture: x64
Commit: 4452502459
.NET SDKs installed:
9.0.308 [C:\Program Files\dotnet\sdk]
10.0.100-rc.1.25451.107 [C:\Program Files\dotnet\sdk]
10.0.102 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0-rc.1.25451.107 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0-rc.1.25451.107 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0-rc.1.25451.107 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
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?
Aspire version 13.1.1
Aspire cli version 13.1.1