Using Kontena Vault

Kontena Vault is a secure key-value storage system that can be used to manage secrets for Kontena Stacks and Services in your Kontena Platform. Kontena Vault has built-in integration for managing LetsEncrypt certificates.

In this chapter, we'll discover how to manage secrets with Kontena Vault:

List Secrets

$ kontena vault ls

Write a Secret to Vault

$ kontena vault write <name> <value>

Read a Secret

$ kontena vault read <name>

Note: Every read command will be added to the Kontena Master audit log

Update Secret

$ kontena vault update <name> <value>

Remove a Secret

$ kontena vault rm <name>

Using LetsEncrypt Certificates

Kontena Vault integrates natively with LetsEncrypt to provide easy-to-use certificate management for your Kontena Services.

Register for LE

To use LetsEncrypt, you must first register as a user.

$ kontena certificate register <>

By default this creates a new private key to be used with LE to identify the client.

Note: If you have already registered with other means and have an existing private key you wish to use you can import it into vault using the specific name LE_PRIVATE_KEY

$ kontena vault write LE_PRIVATE_KEY "$(cat priv_key.pem)"

The email is needed for Let's Encrypt to notify when certificates are about to expire. This registration is needed only once per Kontena Platform.

Create domain authorization

To be able to request certificates for a domain you must first prove that you are in charge of that domain. For this, Kontena certificate management supports DNS-based authorization.

$ kontena certificate authorize
Record name:_acme-challenge
Record type:TXT
Record content:5m1FCaNvneLduTN4AcPqAbyuQhBQA4ESisAQfEYvXIE

To verify that you really control the requested domain, create a DNS TXT record for the domain with content specified in the response.

Get actual certificate

Once you have created the necessary DNS proof of domain control you can request the actual certificate.

$ kontena certificate get --secret-name SSL_CERT_LE_TEST
Certificate successfully received and stored into vault with key SSL_CERT_LE_TEST

Kontena automatically stores the certificate in a secure vault in a format where it can be used for SSL termination with Kontena Load Balancer. If you omit the secret-name option, Kontena automatically generates the name using the domain name.

LetsEncrypt does not (yet) support wildcard certificates. In many cases it is necessary to serve multiple sites behind one certificate. For this, LetsEncrypt supports a concept called subject alternative names (SAN). To obtain a certificate for multiple DNS names, simply specify them in the request:

$ kontena certificate get --secret-name SSL_CERT_LE_TEST
Certificate successfully received and stored into vault with key SSL_CERT_LE_TEST

Note: For each of the domains in the certificate request, it is necessary to complete the domain authorization first! The first domain in the list becomes the common name and others are used as alternative names:

        Version: 3 (0x2)
        Serial Number:
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN=Fake LE Intermediate X1
            Not Before: Jul  1 06:31:00 2016 GMT
            Not After : Sep 29 06:31:00 2016 GMT
        Subject Public Key Info:
        X509v3 extensions:
            X509v3 Subject Alternative Name:

By default Kontena stores the full chain version of the certificate. This is because LetsEncrypt intermediaries are not trusted by all client libraries (such as some libraries associated with Ruby, Docker, and wget, for example). You can control the type of certificate stored with this command line option:

--cert-type CERT_TYPE    The type of certificate to get: fullchain, chain or cert (default: "fullchain")

Kontena Vault Integration

Upon receiving a certificate from LetsEncrypt, Kontena Platform stores three secrets at the Kontena Vault:

  • LECERTIFICATE<domain_name>_PRIVATE_KEY Private key of the certificate
  • LECERTIFICATE<domain_name>_CERTIFICATE The actual certificate
  • LECERTIFICATE<domain_name>_BUNDLE Bundle of the certificate and private key, suitable to use with Kontena Load Balancer.

These certificates may be used from any Kontena Stack. Just configure secrets section via Kontena Stack File using the details above.

results matching ""

    No results matching ""