Sep 21, 2021
3 min read

Managing PKCS12 Certificates in Kubernetes using the Doppler Secrets Operator

Managing PKCS12 Certificates in Kubernetes using the Doppler Secrets Operator
Back to the blog
Share

Requirements

Installing the Kubernetes Operator

The Doppler Kubernetes Operator continuously syncs secrets to Kubernetes and can auto-reload deployments when secrets change.

Install the Operator using Helm:

helm repo add doppler https://helm.doppler.com helm install --generate-name doppler/doppler-kubernetes-operator

Or kubectl:

Installing the Kubernetes Operator creates the following resources:

  • doppler-operator-system namespace
  • DopplerSecret Custom Resource Definition (CRD)
  • Service account and RBAC role for the Operator
  • Operator Deployment

Visit the Kubernetes Operator GitHub repository to learn more.

Importing the PKCS12 Certificate to Doppler

As the PKCS12 certificate is in binary format, it must be base64 encoded before importing to Doppler.

If you haven't yet created a Doppler project, you can use the CLI:

Select the appropriate environment to import the secret to:

Then create the base64 encoded PKCS12 certificate secret:

If your PKCS12 certificate is password-protected, you'll need to add that too:

Kubernetes Operator Secrets Sync

A Doppler Service Token is required to give the Operator access to the secrets for a specific project and config. It will be stored in a Kubernetes secret that the Operator will then access.

Create the Service Token and inject it as a Kubernetes secret in the doppler-operator-system namespace:

Next, we'll create a custom DopplerSecret which contains data the Operator uses to manage the Kubernetes secret containing the synced secrets.

Kubernetes secrets are base64 encoded, not for security, but to store binary values such as PKCS12 certificates. But as the PKCS12 certificate is already base64 encoded in Doppler, we'll use the optional processors: map, which tells the Operator to skip base64 encoding the PKCS12_CERT value.

Save the file contents as doppler-secret-pkcs12.yaml:

Then create the DopplerSecret in Kubernetes:

You can check the Operator created the Kubernetes synced secret by querying for secrets with the Operator's custom label:

The output should be similar to:

The final step is mounting the certificate inside a container.

Mount PKCS12 Certificate Inside a Kubernetes Deployment

The below deployment uses the doppler-pkcs12 managed secret created by the Operator to mount the certificate using a secrets volume and supply the certificate password using the PKCS12_PASS environment variable.

The command and args combine to verify the certificate by extracting its metadata for testing purposes.

Save the file contents as pkcs12-deployment.yaml:

Create the deployment in Kubernetes:

Then confirm the certificate was verified by viewing the container logs:

Summary

Awesome work!

Now you know how to store and automatically sync PKCS12 certificates from Doppler to Kubernetes using the Doppler Kubernetes Operator.

Check out the Kubernetes Operator documentation and head to the Doppler Community Forum if you need help or have any questions.

Stay up to date with new platform releases and get to know the team of experts behind them.

Related Content

Explore More