-
Notifications
You must be signed in to change notification settings - Fork 3
Writing a Plugin: Cluster Support
It is about Casket v1.
Join the Casket Community Forum to chat with other Casket developers!
Casket can work well behind load balancers or in any fleet configuration, including the use and synchronization of shared TLS resources such as certificates, OCSP staples, etc.
You have to implement certmagic.Storage interface, which requires a backend that can support atomic operations. (Please read the godoc carefully!)
You can use certmagic.FileStorage as an example. It's the default cluster support for Casket.
Then register your implementation with a unique name.
Here's a skeleton:
import (
"github.com/mholt/casket/caskettls"
"github.com/mholt/certmagic"
)
func init() {
caskettls.RegisterClusterPlugin("name", func (certmagic.Storage, error) {
// obviously, replace this with a valid instance of yours
return MyClustering{}, nil
})
}
// implement your Storage type here
Then at runtime, users configure to use your clustering plugin by setting the CASKET_CLUSTERING
environment variable.
You can configure your own clustering support however you choose, but environment variables are a good way to go (or you can add command line flags if you absolutely have to). Keep the configuration as simple as possible. It is recommended for environment variables to conform to Casket convention: CASKET_CLUSTERING_<YOURS>_<CONFIG_OPTION>
, so for example, a clustering plugin called consul
might have an option: CASKET_CLUSTERING_CONSUL_PREFIX
.