autocert

by Smallstep Labs, Inc

Helm chartv1.20.7App 0.20.6

A kubernetes add-on that automatically injects TLS/HTTPS certificates into your containers.

About this chart

Autocert

A kubernetes add-on that automatically injects TLS/HTTPS certificates into your containers.

To learn more, visit https://github.com/smallstep/certificates/tree/master/autocert.

TL;DR

helm install autocert smallstep/autocert
kubectl label namespace default autocert.step.sm=enabled

Prerequisites

  • Kubernetes 1.10+

Installing the Chart

To install the chart with the release name my-release:

helm install my-release smallstep/autocert

The command deploys Autocert on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

By default autocert helm chart installs a new step-certificates deployment. But if you already have an instance of step-certificates running you can configure it with autocert setting the values in the ca block like this:

ca:
  url: https://ca.example.com
  # provisioner is the provisioner name and password that autocert will use
  provisioner:
    name: admin
    password: my-plaintext-password
  # certs is the configmap in yaml that should contain the CA root certificate.
  certs:
    root_ca.crt: |-
      -----BEGIN CERTIFICATE-----
      MIIBdjCCAR2gAwIBAgIQNFvgRJo4ZuvaRquC9gB3WTAKBggqhkjOPQQDAjAaMRgw
      FgYDVQQDEw9FeGFtcGxlIFJvb3QgQ0EwHhcNMjExMjEzMjMxNTU4WhcNMzExMjEx
      MjMxNTU4WjAaMRgwFgYDVQQDEw9FeGFtcGxlIFJvb3QgQ0EwWTATBgcqhkjOPQIB
      BggqhkjOPQMBBwNCAAQlQRnmP9NZ2/L1iMWE1vGwOraPR3hUeashSdIWZk+snrQG
      Mt+DXBEz8AxlV5+nNtncYErtzIV8exX+fY7V8agVo0UwQzAOBgNVHQ8BAf8EBAMC
      AQYwEgYDVR0TAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUxjwLhVkVREOolv5CA/J1
      QQ6SqhowCgYIKoZIzj0EAwIDRwAwRAIgf0MmZJhkAdyXscYQXLANdMUKJXx/JPjL
      XwH5kIIJvB0CIB+aMuA8aFpK/Ld1hkqrdzuvCLiD3cSaOAFzNJqFdCuo
      -----END CERTIFICATE-----
  # config is the configmap in yaml to use. This is currently optional only.
  config:
    defaults.json: |-
      {}

And then install autocert using a config.yaml like the above one, and setting the value step-certificates.enabled to false:

helm install --set step-certificates.enabled=false -f config.yaml my-release smallstep/autocert

Note: Future version of the autocert helm-chart will not install step-certificates and it will require these values.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Enable Autocert (per namespace)

To enable Autocert for a namespace it must be labelled autocert.step.sm=enabled.

To label the default namespace run:

kubectl label namespace default autocert.step.sm=enabled

To check which namespaces have Autocert enabled run:

$ kubectl get namespace -L autocert.step.sm
NAME          STATUS   AGE   AUTOCERT.STEP.SM
default       Active   59m   enabled
...

Configuration

The following table lists the configurable parameters of the Autocert chart and their default values.

ParameterDescriptionDefault
replicaCountNumber of Autocert replicas1
nameOverrideOverrides the name of the chart""
fullnameOverrideOverrides the full name of the chart""
service.typeService typeClusterIP
service.portIncoming port to access Autocert443
service.targetPortInternal port where Autocert runs4443
autocert.image.repositoryRepository of the Autocert imagecr.step.sm/smallstep/autocert-controller
autocert.image.tagTag of the Autocert image0.12.2
autocert.image.pullPolicyAutocert image pull policyIfNotPresent
autocert.labelLabel uses to enable Autocert in a namespaces (should not be changed)autocert.step.sm
autocert.logFormatLog format, json or textjson
autocert.restrictCertificatesToNamespaceIf certificate names are restricted to the namespacefalse
autocert.closterDomainCluster domain namecluster.local
autocert.certLifetimeCertificate lifetime24h
autocert.resourcesCPU/memory resource requests/limits (YAML){requests: {cpu: 100m, memory: 20Mi}}
autocert.nodeSelectorNode labels for pod assignment (YAML){}
autocert.tolerationsToleration labels for pod assignment (YAML)[]
autocert.affinityAffinity settings for pod assignment (YAML){}
bootstrapper.image.repositoryRepository of the Autocert bootstrapper imagecr.step.sm/smallstep/autocert-bootstrapper
bootstrapper.image.tagTag of the Autocert bootstrapper image0.12.2
bootstrapper.image.pullPolicyAutocert bootstrapper image pull policyIfNotPresent
bootstrapper.resourcesCPU/memory resource requests/limits (YAML){}
renewer.image.repositoryRepository of the Autocert renewer imagecr.step.sm/smallstep/autocert-renewer
renewer.image.tagTag of the Autocert renewer image0.12.2
renewer.image.pullPolicyAutocert renewer image pull policyIfNotPresent
renewer.resourcesCPU/memory resource requests/limits (YAML){}
ingress.enabledIf true Autocert ingress will be createdfalse
ingress.annotationsAutocert ingress annotations (YAML){}
ingress.hostsAutocert ingress hostNAMES (YAML)[]
ingress.tlsAutocert ingress TLS configuration (YAML)[]
step-certificates.enabledEnables the installation of the step-certificates sub-charttrue
step-certificates.autocert.enabledEnables autocert in step-certificates sub-charttrue
ca.urlSets a custom CA URL, to be used with an existing step-certificates""
ca.provisioner.nameThe provisioner name to use""
ca.provisioner.passwordThe plaintext version of provisioner password""
ca.certsThe files to write in the certs configmap, it should contain the root_ca.crt""
ca.configThe files to write in the config configmap, it might contain a defaults.json{}

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

helm install my-release \
  --set autocert.logFormat=text,step-certificates.ca.name=Foo \
  autocert

The above command sets the Autocert provisioner Foo with the key password secretpassword.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

helm install --name my-release -f values.yaml autocert

Tip: You can use the default values.yaml

Deploy autocert with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has autocert on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartautocert is pinned at v1.20.7 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply