Longhorn supports MTLS to secure and encrypt the grpc communication between the control plane (longhorn-manager) and the data plane (instance-managers). For Certificate setup we use the Kubernetes secret mechanism in combination with an optional secret mount for the longhorn-manager/instance-manager.
Requirements
In a default installation mtls is disabled to enable mtls support one needs to create a secret in the longhorn-system
namespace before deployment. The secret is specified as an optional secret mount for the longhorn-manager/instance-managers so if it does not exist when these components are started, mtls will not be used and a restart of the components will be required to enable tls support.
Self Signed Certificate Setup
You should create a ca.crt
with the CA flag set which is then used to sign the tls.crt
this will allow you to rotate the tls.crt
in the future without service interruptions. You can use openssl or for the ca.crt
as well as tls.crt
certificate generation.
The tls.crt
certificate should use longhorn-backend
for the common name and the below list of entries for the Subject Alternative Name.
Setting up Kubernetes Secrets
The longhorn-grpc-tls
yaml looks like the below example, If you are having trouble getting your own certificates to work you can base decode the below certificate and compare it against your own generated certificates via openssl x509 -in tls.crt -text -noout
.
kind: Secret
metadata:
type: kubernetes.io/tls
data:
ca.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUREakNDQWZhZ0F3SUJBZ0lVU2tNdUVEOC9XYXphNmpkb1NiTE1qalFqb3JFd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0h6RWRNQnNHQTFVRUF4TVViRzl1WjJodmNtNHRaM0p3WXkxMGJITXRZMkV3SGhjTk1qSXdNVEV4TWpFeApPVEF3V2hjTk1qY3dNVEV3TWpFeE9UQXdXakFmTVIwd0d3WURWUVFERXhSc2IyNW5hRzl5YmkxbmNuQmpMWFJzCmN5MWpZVENDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DZ2dFQkFNY2grbTJhUndnNEtBa0EKT0xzdzdScWlWb1VqL2VPbVhuSE9HVE5nWE4rcFh5bDlCdzVDM1J4UDYzU29qaTVvNEhkU1htVmpwZmhmNjh1YwpvNVJJeUtXM1p6cndteDhXZldEc0dNNEtnYXBvMy84N3pVQ00vdGltOHllTzFUbTZlWVhXcWdlZ2J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GQwcjhIL3k2QkhvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFTE5BVUllSy92emloZzdrVDl3cThqdThVTnVzbnNhc3ZpaUtVR0J6ZG5WZ3ZTUnczYWM3eApFNFJCOWZnK2NGdVR6ekZoU0dGVUtVSlhpWHl3QVdnSjhRPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
For more information on creating a secret, see The secret must be created in the longhorn-system
namespace for Longhorn to access it.
History
Available since v1.3.0