Add HTTPS/RPC/gossip encryption and setup script #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempts to resolve #49 by emulating and expanding upon the pattern used in autopilotpattern/vault.
Needs to be rebased once #48 is merged.
Summary
CONSUL_TLS_PATH
specifies a directory that will be created which is used to sideload certs and key material. We can't reuseCONSUL_CACERT
,CONSUL_CLIENT_CERT
,CONSUL_CLIENT_KEY
because ContainerPilot would expect the files to exist as soon as it started up and terminates immediately if they're missing. We can elect to surface these to ContainerPilot and trigger a reload, but it doesn't need the certificates and key since it'll be connecting to the unencrypted http port that's bound to a private address.Instead, the
preStart
job blocks until the files are injected and sets ConsulCONSUL_CACERT
,CONSUL_CLIENT_CERT
,CONSUL_CLIENT_KEY
values in the configuration file. It is possible to usecontainerpilot -putenv
if configuring ContainerPilot to use the encrypted connection is desired, but this doesn't seem necessary given the private listening address used for plain http. Keeping the automated Consul configuration we apply in the config makes it easy to inspect and debug.preStop
has been updated to skipconsul leave
ifconsul info
fails. This was part of eliminating a warning that occurred previously while I was callingcontainerpilot -reload
but is slightly irrelevant now. On the other hand, it does make some sense to only try to leave if you were registered in the first place, so I'm tempted to leave this in.The README updates should provide all the necessary context, but things have shifted around enough that they might be slightly inaccurate, please let me know if anything seems off!
To make it easier for users to generate certificates the process described in this blogpost referenced from Consul's encryption docs has been compressed into
ca/Dockerfile
.setup-encryption.sh
provides three commands:ca
directory to build a CA containerdocker cp
Additional notes
examples/triton/setup.sh
andexamples/triton/setup-multi-dc.sh
now accept-t/--tls-path
and-g/--gossip-path
parameters for setting the expected cert directory and injecting the gossip secret key respectively.setup.sh
has also been modified to accept./setup.sh -h
since./setup.sh help
seems unintuitiveThe
ca
folder contains a really crude translation of the above-mentioned blogpost as a Docker container. Volume-mounting the/ssl
folder in that container seems like a good idea to prevent losing CA state. I've been told having an intermediate CA cert would make things easier to manage, but my experience with certs is limited so I'll be delaying this improvement until testing is complete with the current super-minimalist certificate chain.The
upload
command can be used to inject arbitrary files into running containers. This decoupling allows users to bring in their own certs as desired by ignoring the first two commands, but it also presents a security risk if not used carefully. Advice for how to make this more intuitive and secure is welcome.