Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres
1.0.0-dev.9
dotnet add package Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres --version 1.0.0-dev.9
NuGet\Install-Package Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres -Version 1.0.0-dev.9
<PackageReference Include="Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres" Version="1.0.0-dev.9" />
<PackageVersion Include="Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres" Version="1.0.0-dev.9" />
<PackageReference Include="Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres" />
paket add Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres --version 1.0.0-dev.9
#r "nuget: Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres, 1.0.0-dev.9"
#:package Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres@1.0.0-dev.9
#addin nuget:?package=Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres&version=1.0.0-dev.9&prerelease
#tool nuget:?package=Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres&version=1.0.0-dev.9&prerelease
Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres
.NET Aspire hosting extensions for publishing CloudNativePG database resources. This package maps Aspire PostgreSQL resources to CloudNativePG database manifests and credentials backed by External Secrets.
Installation
dotnet add package Arkanis.Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres
Quick Start
using Aspire.Hosting;
using Aspire.Hosting.Extensions.Kubernetes;
using Aspire.Hosting.Extensions.Kubernetes.CloudNativePostgres;
using Aspire.Hosting.Extensions.Kubernetes.ExternalSecrets;
using Aspire.Hosting.Extensions.Kubernetes.KubernetesConnections;
var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres");
var api = builder.AddProject<Projects.Api>("api");
var kubernetes = builder.AddKubernetesEnvironment("kubernetes");
postgres.WithCloudNativePostgresDatabase(database => database
.WithClusterName("production")
.WithDatabaseName("application")
.InKubernetesEnvironment(kubernetes)
.WithCredentialsSecret(credentials => credentials
.FromSourceSecret("application-credentials")
.ToTargetSecret("postgres-connection", "ConnectionStrings__ApplicationDatabase")
.UsingSecretStore(ExternalSecretStoreOptions.ClusterSecretStore("postgres-production-credentials"))
.RefreshEvery("30m")));
api.WithKubernetesConnectionString(postgres, "ApplicationDatabase");
builder.Build().Run();
WithCloudNativePostgresDatabase(...) emits the CloudNativePG Database manifest during Kubernetes publish.
Credentials are emitted as an External Secrets Operator ExternalSecret that reads the CloudNativePG credential Secret and writes an application-local connection string Secret.
WithKubernetesConnectionString(...) points the consuming workload at that generated Secret through ConnectionStrings__ApplicationDatabase.
Use configuration binding when you prefer appsettings-driven deployment details.
postgres.WithCloudNativePostgresDatabase(database =>
database.WithConfigurationFrom(builder.Configuration));
Custom Connection-String Templates
Use WithConnectionStringTemplateSuffix(...) for an additional provider-specific clause.
The CloudNativePG overload of WithKubernetesConnectionString(...) configures the source credentials and then creates the existing destination Secret reference.
api.WithKubernetesConnectionString(
postgres,
"ApplicationDatabase",
credentials => credentials.WithConnectionStringTemplateSuffix("Ssl Mode=Require"));
The same suffix can be configured through the resource-local configuration path.
{
"Kubernetes": {
"CloudNativePostgres": {
"Resources": {
"postgres": {
"CredentialsSecret": {
"ConnectionStringTemplateSuffix": "Ssl Mode=Require"
}
}
}
}
}
}
Use WithConnectionStringTemplate(...) when the complete connection-string template must differ from the default.
postgres.WithCloudNativePostgresDatabase(database => database
.WithClusterName("production")
.WithCredentialsConnectionStringTemplate(annotation =>
$"{{{{ `Host={{{{ .host }}}};Database={annotation.Credentials.DatabaseName};Ssl Mode=Require` }}}}"));
The callback returns the final Helm template value, rather than a runtime connection string.
The outer {{ ... }} is a Helm raw-string action.
It causes Helm to preserve the inner ESO expressions such as {{ .host }}.
External Secrets Operator evaluates those inner expressions after the CloudNativePG credentials Secret is extracted.
When writing the callback as a C# interpolated string, each literal brace is doubled.
Therefore {{{{ in the C# source emits {{, and }}}} emits }} in the Helm template.
A full template callback and a suffix are mutually exclusive.
For advanced External Secrets Operator changes, CustomizeExternalSecret(...) runs after the library configures the target, source extraction, and connection-string template.
It can add template data or deliberately replace the connection-string key.
postgres.WithCloudNativePostgresDatabase(database => database
.WithClusterName("production")
.CustomizeCredentialsExternalSecret((externalSecret, _) =>
externalSecret.WithTemplateData("Database__Host", "{{ `{{ .host }}` }}")));
Scope
This package emits CloudNativePG and External Secrets publishing intent during Aspire publish. It does not install CloudNativePG, install External Secrets Operator, create operator credentials, or apply generated manifests to a live cluster.
Generated Names
WithCloudNativePostgresDatabase emits a CloudNativePG Database custom resource whose spec.name is the configured DatabaseName value, or the Aspire resource name when DatabaseName is omitted.
The custom resource metadata.name defaults to {ClusterName}-{DatabaseName} after Kubernetes object-name normalization, or {ClusterName}-{ResourceName} when DatabaseName is omitted.
Use MetadataName in configuration or WithMetadataName(...) in code to preserve an existing object name or choose a different Kubernetes object name.
Credentials secret defaults remain resource-local: the source platform secret defaults to the effective database name with -credentials after normalization, while the target app secret defaults to {ResourceName}-connection after normalization.
Dependencies
This package references Arkanis.Aspire.Hosting.Extensions.Kubernetes.
This package also references Arkanis.Aspire.Hosting.Extensions.Kubernetes.ExternalSecrets.
Repository
Source, issues, and release workflow details are available at https://github.com/ArkanisCorporation/Aspire.Hosting.Extensions.Kubernetes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Arkanis.Aspire.Hosting.Extensions.Kubernetes (>= 1.0.0-dev.9)
- Arkanis.Aspire.Hosting.Extensions.Kubernetes.ExternalSecrets (>= 1.0.0-dev.9)
- Arkanis.Common.Aspire.ServiceDefaults (>= 1.0.0-dev.1)
- Aspire.Hosting (>= 13.4.6)
- Aspire.Hosting.Kubernetes (>= 13.4.6-preview.1.26319.6)
- JetBrains.Annotations (>= 2026.2.0)
- Microsoft.Extensions.Configuration (>= 10.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Logging (>= 10.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- YamlDotNet (>= 18.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-dev.9 | 51 | 8/1/2026 |
| 1.0.0-dev.8 | 33 | 8/1/2026 |
| 1.0.0-dev.7 | 178 | 7/5/2026 |
| 1.0.0-dev.6 | 62 | 7/5/2026 |
| 1.0.0-dev.5 | 93 | 7/4/2026 |
| 1.0.0-dev.4 | 75 | 7/3/2026 |
| 1.0.0-dev.3 | 67 | 7/2/2026 |
| 1.0.0-dev.2 | 309 | 6/16/2026 |
| 1.0.0-dev.1 | 92 | 6/11/2026 |