r/devops • u/maetthew • Jun 25 '26
Architecture Containers and Internal Certificate Authorities
Hi,
We are in the process of deploying an internal PKI, and as such issuing our in house Certificate Authority.
One problem which have arisen is how to handle this inside of containers and I'm curious to see how the folks in this subreddit handled it.
I've asked this question to a couple of LLMs but so far none of the solutions seem very viable.
The one that so far seems the most reliable is building your own golden base images for our various needs and injecting the CA straight into these, and subsequently hosting them on an internal container registry, but we currently doesn't have an internal registry so before going down that route I would like to know peoples opinion.
Our use-case is both for CI/CD and Kubernetes.
So far these are the solutions we've come up with which seem somewhat viable, albeit cumbersome:
- Building custom base images and hosting them internally as stated above.
- Injecting them into every pipeline on runtime
Are there other solutions I might have overlooked?
Thanks for your time.
11
u/farnoud Jun 25 '26
I would separate this into a few trust stores instead of trying to solve it once for every container:
I would avoid injecting the CA in every pipeline as the primary pattern. It works, but it tends to become copy-pasted security plumbing. My default would be: bootstrap an internal registry, publish a few maintained base images with the CA installed, and use a Kubernetes-level trust bundle only where runtime workloads need additional trust.
2
u/forever-butlerian Solaris 8 Enjoyer Jun 25 '26
Build the custom base images.
Are you running on either AWS or GCP?
2
u/moonman407 Jun 25 '26
This is a pretty simple fix.
On your container hosts, add your root CA to the system's cert store. Mount the generated ca bundle file as read-only into each container, at it's ca bundle location. This will allow your containers to trust your internal signed certs.
Create a step-ca server with an ACME request agent (step-ra). Configure your ACME client's (Traefik, Certbot, acme.sh, lego, etc) server config value to point to the step-ra at
https://step-ra/acme/acme/directory.That will issue internal pki certs to your container services.
5
u/varunsharmalive Jun 26 '26
you can skip the registry to start, mount the CA as a configmap and run update-ca-certificates from an initContainer into a shared emptyDir. just remember node/python/java each ignore the OS trust store, so you'll still set NODE_EXTRA_CA_CERTS / REQUESTS_CA_BUNDLE / cacerts per stack regardless.
2
u/veritable_squandry Jun 26 '26
bundles with latest and last cert only. use config maps and cert-manager; trust-manager if it's warranted. k8s secrets for p keys.
2
u/marcusbell95 Jun 26 '26
for kubernetes specifically, cert-manager's trust-manager handles this cleanly. you define a Bundle resource that points at your CA and it propagates the bundle to configmaps in all (or selected) namespaces automatically. workloads mount the configmap and set SSL_CERT_FILE or NODE_EXTRA_CA_CERTS or whatever their stack needs. when the CA rotates trust-manager reconciles - no manual image rebuilds.
for CI/CD while you still don't have an internal registry: env var injection is a solid bridge. SSL_CERT_FILE for go/curl/openssl, REQUESTS_CA_BUNDLE for python, NODE_EXTRA_CA_CERTS for node. inject at the runner or job level, no image changes needed. won't help apps that use the java keystore or native windows cert store, but covers most workloads.
longer term the custom base images path is right - especially on-prem. worth standing up harbor or a lightweight OCI registry before committing to it though. the lifecycle story gets complicated without it: you want to know which base image version has which CA bundle so rotation is a controlled rebuild+redeploy, not a guessing game.
1
u/percoAi Jun 26 '26
The part I would design early is rotation and inventory not just injection. However you ship the CA you want to know which runner image app image namespace and workload trusts which root bundle and when it was last updated. Otherwise the first cert rotation turns into guessing.
For Kubernetes I'd lean toward a managed trust bundle for workloads and a maintained runner/base-image path for CI. The important bit is treating the CA bundle as a versioned deployment artifact with an owner and rollback path.
1
u/Flashy_Current9455 Jun 26 '26
Build and mount image volumes
2
u/[deleted] Jun 25 '26
[removed] — view removed comment
0
u/[deleted] Jun 29 '26
[removed] — view removed comment
-1
u/[deleted] Jun 25 '26
[removed] — view removed comment