CertManagerExtensions Methods

ClassMethods7 members
Provides extension methods for installing cert-manager into a Kubernetes environment and declaring ClusterIssuer resources against it.
AddCertManager(IResourceBuilder<KubernetesEnvironmentResource>, string, string?)Section titled AddCertManager(IResourceBuilder<KubernetesEnvironmentResource>, string, string?)extensionIResourceBuilder<CertManagerResource>
Installs cert-manager into the Kubernetes environment and returns a typed CertManagerResource that can host issuer resources.
public static class CertManagerExtensions
{
public static IResourceBuilder<CertManagerResource> AddCertManager(
this IResourceBuilder<KubernetesEnvironmentResource> builder,
string name,
string? chartVersion = null)
{
// ...
}
}
builderIResourceBuilder<KubernetesEnvironmentResource>The Kubernetes environment resource builder.
namestringThe Aspire resource name for the cert-manager installation. Each call adds a uniquely-named resource to the application model, so multiple Kubernetes environments must each pass distinct names.
chartVersionstring?optionalThe cert-manager Helm chart version to install. Defaults to a pinned version validated against this Aspire build.
IResourceBuilder<CertManagerResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.

Internally creates a KubernetesHelmChartResource via KubernetesHelmChartExtensions.AddHelmChart pointed at oci://quay.io/jetstack/charts/cert-manager. The chart is configured with:

  • crds.enabled = true — installs the cert-manager CRDs ( ClusterIssuer, Certificate, ...) so issuer manifests can be applied immediately afterwards.
  • config.enableGatewayAPI = true — lets cert-manager watch Gateway API Gateway / HTTPRoute resources for the cluster-issuer annotation.
  • WithForceConflicts() — works around the AKS Azure Policy add-on mutating cert-manager's ValidatingWebhookConfiguration after install.
  • WithDestroy() — uninstalls the Helm release on aspire destroy.

Issuer manifests are applied directly via kubectl apply at deploy time (not as part of the Helm release), and are deleted via kubectl delete on aspire destroy before the cert-manager Helm release itself is uninstalled.

To customise additional Helm values, access the underlying chart via CertManagerResource.HelmChart.

AddIssuer(IResourceBuilder<CertManagerResource>, string)Section titled AddIssuer(IResourceBuilder<CertManagerResource>, string)extensionIResourceBuilder<CertManagerIssuerResource>
Adds a cert-manager ClusterIssuer to this cert-manager installation.
public static class CertManagerExtensions
{
public static IResourceBuilder<CertManagerIssuerResource> AddIssuer(
this IResourceBuilder<CertManagerResource> builder,
string name)
{
// ...
}
}
builderIResourceBuilder<CertManagerResource>The cert-manager resource builder.
namestringThe Aspire resource name. Also used as the metadata.name of the generated ClusterIssuer, so it must be a valid DNS-1123 label.
IResourceBuilder<CertManagerIssuerResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
WithAcmeServer(IResourceBuilder<CertManagerIssuerResource>, string, string)Section titled WithAcmeServer(IResourceBuilder<CertManagerIssuerResource>, string, string)extensionIResourceBuilder<CertManagerIssuerResource>
Configures the issuer to use an ACME directory endpoint, such as Let's Encrypt, ZeroSSL, or a private ACME server.
public static class CertManagerExtensions
{
public static IResourceBuilder<CertManagerIssuerResource> WithAcmeServer(
this IResourceBuilder<CertManagerIssuerResource> builder,
string serverUrl,
string email)
{
// ...
}
}
builderIResourceBuilder<CertManagerIssuerResource>The issuer resource builder.
serverUrlstringThe ACME directory URL (e.g., https://acme.example.com/directory).
emailstringThe contact email registered with the ACME account.
IResourceBuilder<CertManagerIssuerResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
WithAcmeServer(IResourceBuilder<CertManagerIssuerResource>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)Section titled WithAcmeServer(IResourceBuilder<CertManagerIssuerResource>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)extensionIResourceBuilder<CertManagerIssuerResource>
Configures the issuer with an ACME directory URL and contact email resolved from parameters at deploy time.
public static class CertManagerExtensions
{
public static IResourceBuilder<CertManagerIssuerResource> WithAcmeServer(
this IResourceBuilder<CertManagerIssuerResource> builder,
IResourceBuilder<ParameterResource> serverUrl,
IResourceBuilder<ParameterResource> email)
{
// ...
}
}
builderIResourceBuilder<CertManagerIssuerResource>The issuer resource builder.
serverUrlIResourceBuilder<ParameterResource>A parameter containing the ACME directory URL.
emailIResourceBuilder<ParameterResource>A parameter containing the contact email registered with the ACME account.
IResourceBuilder<CertManagerIssuerResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
ArgumentNullExceptionA required argument is null.
WithExternalAccountBinding(IResourceBuilder<CertManagerIssuerResource>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)Section titled WithExternalAccountBinding(IResourceBuilder<CertManagerIssuerResource>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>)extensionIResourceBuilder<CertManagerIssuerResource>
Configures External Account Binding (EAB) with a key identifier and secret HMAC key resolved at deploy time.
public static class CertManagerExtensions
{
public static IResourceBuilder<CertManagerIssuerResource> WithExternalAccountBinding(
this IResourceBuilder<CertManagerIssuerResource> builder,
IResourceBuilder<ParameterResource> keyId,
IResourceBuilder<ParameterResource> hmacKey)
{
// ...
}
}
builderIResourceBuilder<CertManagerIssuerResource>The issuer resource builder.
keyIdIResourceBuilder<ParameterResource>A parameter containing the key identifier supplied by the ACME provider.
hmacKeyIResourceBuilder<ParameterResource>A secret parameter containing the provider's base64url-encoded HMAC key.
IResourceBuilder<CertManagerIssuerResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
ArgumentNullExceptionA required argument is null.
ArgumentExceptionThe HMAC parameter is not secret.
Aspire applies an issuer-specific Kubernetes Secret in cert-manager's cluster resource namespace at deploy time and attempts to delete it on destroy. The HMAC key is not included in published artifacts. EAB authorizes account registration, not domain ownership. Preserve cert-manager's separate account-key Secret. See https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3.4 and https://cert-manager.io/docs/configuration/acme/#external-account-bindings. Supply fresh credential pairs from a deployment pipeline when registering a new account with a provider that uses expiring or single-use EAB credentials. Aspire does not acquire or refresh provider credentials. Existing ACME accounts are reused by cert-manager.
WithHttp01Solver(IResourceBuilder<CertManagerIssuerResource>)Section titled WithHttp01Solver(IResourceBuilder<CertManagerIssuerResource>)extensionIResourceBuilder<CertManagerIssuerResource>
Adds an HTTP-01 ACME challenge solver to the issuer. cert-manager will satisfy the challenge by provisioning a temporary HTTP route at /.well-known/acme-challenge/{token} on the same hostname being validated. This requires the hostname to be publicly reachable on port 80.
public static class CertManagerExtensions
{
public static IResourceBuilder<CertManagerIssuerResource> WithHttp01Solver(
this IResourceBuilder<CertManagerIssuerResource> builder)
{
// ...
}
}
builderIResourceBuilder<CertManagerIssuerResource>The issuer resource builder.
IResourceBuilder<CertManagerIssuerResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
HTTP-01 is the right choice for gateways exposed via Azure Application Gateway for Containers (AGC) or any ingress controller that publishes a publicly addressable hostname. Wildcard certificates require a DNS-01 solver, which is not yet supported.
WithTls(IResourceBuilder<KubernetesGatewayResource>, IResourceBuilder<CertManagerIssuerResource>)Section titled WithTls(IResourceBuilder<KubernetesGatewayResource>, IResourceBuilder<CertManagerIssuerResource>)extensionIResourceBuilder<KubernetesGatewayResource>
Adds an HTTPS listener to the gateway and wires it to the supplied cert-manager ClusterIssuer. This adds the cert-manager.io/cluster-issuer annotation to the generated Gateway resource, causing cert-manager to provision and renew a certificate for each gateway listener hostname.
public static class CertManagerExtensions
{
public static IResourceBuilder<KubernetesGatewayResource> WithTls(
this IResourceBuilder<KubernetesGatewayResource> builder,
IResourceBuilder<CertManagerIssuerResource> issuer)
{
// ...
}
}
builderIResourceBuilder<KubernetesGatewayResource>The gateway resource builder.
issuerIResourceBuilder<CertManagerIssuerResource>The cert-manager ClusterIssuer to issue certificates from.
IResourceBuilder<KubernetesGatewayResource>A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
Equivalent to calling WithTls() followed by WithGatewayAnnotation("cert-manager.io/cluster-issuer", issuer.Resource.Name), but type-safe and refactor-friendly. Throws if the gateway and the issuer's cert-manager installation are not part of the same Kubernetes environment, since cert-manager is per-cluster and would otherwise silently produce an unsatisfiable TLS configuration.