How-to guide / Package task guides
Configure cert-manager issuers
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
Kix separates the cert-manager controller from issuer configuration. Install
cert-manager, then add one cluster-issuer instance for each ClusterIssuer.
The ClusterIssuer takes the instance’s name, and config.spec is its spec
in cert-manager’s API.
Put every cluster-issuer instance in cert-manager’s namespace. cert-manager
reads a ClusterIssuer’s Secrets only from its own namespace, so the issuer’s
credentials must be there, and a Kix Secret serves only the namespace it is
declared in. Instance names are unique within a namespace, so two issuers
cannot render the same ClusterIssuer name. An instance in another namespace
fails the build and names the namespace to move it to.
Configure an ACME issuer
Section titled “Configure an ACME issuer”For public certificates, give the ACME server, the account email, and a solver. This example uses Cloudflare DNS-01:
109 instances.cert-manager.cert-manager = {110 package = packages.experimental.cert-manager;111 };112
113 # A Secret created outside Kix that holds the Cloudflare API token114 # under the key `api-token`.115 instances.cert-manager.cloudflare-api-token = {116 package = packages.secret-ref;117 config.keys = [ "api-token" ];118 };119
120 instances.cert-manager.letsencrypt = {121 package = packages.experimental.cluster-issuer;122 deps.issuerCredentials = ref.cert-manager.cloudflare-api-token;123 config.spec.acme = {124 server = "https://acme-v02.api.letsencrypt.org/directory";125 email = "<your-email>";126 solvers = [127 {128 dns01.cloudflare.apiTokenSecretRef.key = "api-token";129 selector.dnsZones = [ "example.com" ];130 }131 ];132 };133 };Replace <your-email> with your own address. Let’s Encrypt refuses
example.com, and kix deploy waits for the readiness timeout before showing
that error.
The cloudflare-api-token instance declares a Secret created outside Kix that
holds the token under the key api-token. Use
a Kix-managed Secret,
a SOPS-backed Secret,
or an externally managed Secret,
in the cert-manager namespace.
deps.issuerCredentials wires that Secret to the issuer. A Kix Secret
dependency is named for what it holds; issuerCredentials holds every key
this issuer’s Secret key selectors name. Leave name out of each selector,
such as apiTokenSecretRef, and set only key. Kix fills in the Secret’s
name and fails the build when the Secret does not declare that key, so the
ClusterIssuer cannot reach the cluster pointing at a Secret or key that is
not there. To name a Secret that Kix should not check, write
name = kix.untrackedRef "<secret>".
An issuer that needs several credentials, such as an ACME external account
binding and a DNS token, keeps them as several keys of its one
issuerCredentials Secret; each selector picks its own key.
Kix sets acme.privateKeySecretRef.name to <instance>-acme-account-key
unless the spec sets it. cert-manager creates that Secret when it registers
the ACME account. Restrict selector.dnsZones to the zones the token may
update.
The spec is checked against the ClusterIssuer CRD that the cert-manager
package vendors. A field the CRD does not define, a missing required field
such as acme.server, a value of the wrong type (such as solvers written
without list brackets), a spec with no issuer type or two, and a solver that
sets both http01 and dns01 or two DNS providers each fail the build with
the spec path and the accepted values. A field set to null is left out.
external-dns reads its Cloudflare token from a Secret in its own namespace. Give that Secret the same key, so one source feeds both.
Use a cloud identity for DNS-01
Section titled “Use a cloud identity for DNS-01”On AWS, Google Cloud, or Azure, cert-manager can authenticate to Route 53,
Cloud DNS, or Azure DNS through its controller’s ServiceAccount instead of a
static key. Pass a cloud identity to deps.controllerIdentity on the
cert-manager instance, and omit the credential fields on the DNS-01 solver.
This example configures Route 53 on EKS:
147 instances.cert-manager.cert-manager = {148 package = packages.experimental.cert-manager;149 deps.controllerIdentity = kix.cloudIdentity.aws {150 roleArn = "arn:aws:iam::111122223333:role/cert-manager";151 };152 };153
154 instances.cert-manager.letsencrypt = {155 package = packages.experimental.cluster-issuer;156 config.spec.acme = {157 server = "https://acme-staging-v02.api.letsencrypt.org/directory";158 email = "<your-email>";159 solvers = [ { dns01.route53.region = "eu-west-1"; } ];160 };161 };On Google Cloud, pass kix.cloudIdentity.gcp { ... } with a dns01.cloudDNS
solver; on Azure, pass kix.cloudIdentity.azure { ... } with a dns01.azureDNS
solver. See Cloud identities
for each constructor’s fields, EKS Pod Identity, and self-managed clusters.
Kix writes the required annotations on the controller’s ServiceAccount, adds
the azure.workload.identity/use: "true" pod label on AKS, and adds
checksum/cloud-identity to the controller’s pod template so changing the
identity restarts the controller.
To use the controller’s credentials, omit these fields from the solver:
| Solver | Fields to omit |
|---|---|
dns01.route53 | accessKeyID, accessKeyIDSecretRef, secretAccessKeySecretRef, and auth |
dns01.cloudDNS | serviceAccountSecretRef |
dns01.azureDNS | clientID and clientSecretSecretRef |
Set cloud identities in deps.controllerIdentity on cert-manager, and set
static credential Secrets in deps.issuerCredentials on cluster-issuer. Kix
rejects a Secret in deps.controllerIdentity or a cloud identity in
deps.issuerCredentials, and each error points to the other dependency. You can
combine both in one cluster: any solver that sets credential fields still reads
its Secret from deps.issuerCredentials, even when cert-manager sets
deps.controllerIdentity.
If a solver omits the fields above and targets a different cloud than
deps.controllerIdentity, evaluation fails and names both the solver and the
cert-manager instance. When deps.controllerIdentity is unset, Kix does not
check the solver’s cloud, and the controller uses whatever default credentials
the cluster gives the pod. On GKE with Workload Identity Federation, the pod
runs as its Kubernetes ServiceAccount principal, which has no IAM roles unless
you grant them. On EKS and AKS, the pod uses the node’s identity if the node
allows access to the instance metadata service. Only
ClusterIssuers can use the controller’s credentials; cert-manager allows this
for ClusterIssuers by default, and the package leaves it disabled for
namespaced Issuers.
Kix does not create cloud IAM resources. In your cloud account, grant the DNS
permissions cert-manager requires for your provider, and bind that identity to
the controller’s ServiceAccount (system:serviceaccount:cert-manager:cert-manager
in the example above). To use a separate AWS IAM role for one issuer, set
role on its dns01.route53 solver; cert-manager assumes that role using the
controller’s credentials.
Add a staging issuer
Section titled “Add a staging issuer”Every cluster-issuer instance answers the clusterIssuer dependency that
TLS-capable packages read, so a second issuer in the same namespace makes that
dependency ambiguous. Give the staging issuer an empty aliases list:
137 instances.cert-manager.letsencrypt-staging = {138 package = packages.experimental.cluster-issuer;139 # An empty list replaces the default alias `clusterIssuer`, so140 # only the production issuer answers it.141 aliases = [ ];142 deps.issuerCredentials = ref.cert-manager.cloudflare-api-token;143 config.spec.acme = {144 server = "https://acme-staging-v02.api.letsencrypt.org/directory";145 email = "<your-email>";146 solvers = [147 {148 dns01.cloudflare.apiTokenSecretRef.key = "api-token";149 selector.dnsZones = [ "example.com" ];150 }151 ];152 };153 };Instance aliases replace the package’s default alias, so the staging issuer
answers no alias. A package that needs it names it with
deps.clusterIssuer = ref.cert-manager.letsencrypt-staging.
Configure a self-signed issuer
Section titled “Configure a self-signed issuer”For a local cluster, use a self-signed issuer:
54 instances.cert-manager.cert-manager.package = packages.experimental.cert-manager;55 instances.cert-manager.selfsigned = {56 package = packages.experimental.cluster-issuer;57 config.spec.selfSigned = { };58 };A self-signed issuer tests certificate creation and TLS wiring without an ACME account or DNS provider. Clients will not trust its certificates unless you install the generated trust material, so do not use this configuration for a public service.
Use cert-manager installed outside Kix
Section titled “Use cert-manager installed outside Kix”When cert-manager and its ClusterIssuer come from Helm or a platform add-on,
Kix does not own them and the cluster-issuer package cannot be used: it
needs the cert-manager package’s CRD handle, schema, and namespace. Declare
the existing issuer with kix.mkImport and the clusterIssuer alias instead:
157 instances.external-tls.cluster-issuer = {158 package = kix.mkImport {159 out.withCert =160 args:161 args162 // {163 annotations = (args.annotations or { }) // {164 "cert-manager.io/cluster-issuer" = "letsencrypt";165 };166 };167 };168 aliases = [ "clusterIssuer" ];169 };Kix then checks nothing about the issuer beyond the name the import gives it.
Because cluster-issuer sets meta.scope = "cluster" and dependency
resolution prefers a managed instance over an import, a cluster-issuer
instance that answers clusterIssuer anywhere in the cluster takes precedence
over the import, so use one or the other. The example cluster has both, which
is why its consumer of the import sets deps.clusterIssuer explicitly.
HTTP-01 solvers
Section titled “HTTP-01 solvers”The spec accepts an http01 solver. cert-manager creates the HTTP-01 solver
pods at runtime in each Certificate’s namespace, and they listen on TCP 8089.
When the cluster enforces network policy, kix.expose admits the ingress
controller to those pods for each Ingress it builds with TLS from this issuer.
A Certificate you create another way needs that traffic admitted too, for
example with a platform intent as in
Declare platform intents for non-Kix-managed pods.
References Kix does not track
Section titled “References Kix does not track”Kix fills and checks only Secret key selectors and the ACME account key.
ca.secretName, venafi.*.credentialsRef.name,
vault.auth.kubernetes.serviceAccountRef.name, the HTTP-01 solver’s Ingress,
IngressClass, and Gateway references, and anything inside a webhook solver’s
config pass through as written. Kix does not check that those
objects exist.
Check and deploy
Section titled “Check and deploy”Evaluate the cluster before applying it:
❱ kix check doc-how-tos Deploy cert-manager, its CRDs, and the ClusterIssuers:
❱ kix deploy doc-how-tos A deploy waits for each ClusterIssuer, and each Certificate built from
certManager.out.crds.Certificate, to report Ready. An ACME ClusterIssuer
reports Ready once cert-manager has registered its account. Kix does not
wait for the Certificates that cert-manager creates from Ingress annotations.
ACME registration and DNS-01 issuance of the Certificates Kix waits for can
take longer than the default readiness timeout of 180 seconds; raise it with
--timeout on clusters that issue through ACME:
❱ kix deploy doc-how-tos --timeout 15m After deployment, inspect issuer readiness:
❱ kubectl get clusterissuers❱ kubectl describe clusterissuer letsencrypt For ACME failures, check the credential key, the zone restriction, DNS delegation, and the cert-manager controller logs.
See Add TLS through a cluster issuer to use the issuer from an application package.