Skip to content

Commit bab2119

Browse files
Merge pull request #1157 from rabbitmq/document-k8s-tls
Add Kubernetes TLS configuration documentation.
2 parents 6cff75c + b717ecf commit bab2119

File tree

3 files changed

+102
-13
lines changed

3 files changed

+102
-13
lines changed

site/img/mTLS.png

98.8 KB
Loading

site/kubernetes/operator/using-operator.md

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ If RabbitMQ Cluster Kubernetes Operator is not installed,
88
see the [installation guide](/kubernetes/operator/install-operator.html). For instructions on getting started quickly, see the [quickstart guide](/kubernetes/operator/quickstart-operator.html).
99
This guide is structured in the following sections:
1010

11-
* [Confirm Service Availability](#service-availability).
12-
* [Apply Pod Security Policies](#psp).
13-
* [Create a RabbitMQ Instance](#create).
14-
* [Existing examples](#examples).
15-
* [Configure a RabbitMQ Instance](#configure).
16-
* [Update a RabbitMQ Instance](#update).
17-
* [Set a Pod Disruption Budget](#set-pdb).
18-
* [Find Your RabbitmqCluster Service Name and Admin Credentials](#find).
19-
* [Verify the Instance is Running](#verify-instance).
20-
* [Use the RabbitMQ Service in Your App](#use).
21-
* [Monitor RabbitMQ Clusters](#monitoring).
22-
* [Delete a RabbitMQ Instance](#delete).
23-
* [Pause Reconciliation for a RabbitMQ Instance](#pause).
11+
* [Confirm Service Availability](#service-availability)
12+
* [Apply Pod Security Policies](#psp)
13+
* [Create a RabbitMQ Instance](#create)
14+
* [Existing examples](#examples)
15+
* [Configure a RabbitMQ Instance](#configure)
16+
* [Update a RabbitMQ Instance](#update)
17+
* [Set a Pod Disruption Budget](#set-pdb)
18+
* [Configure TLS](#tls)
19+
* [Find Your RabbitmqCluster Service Name and Admin Credentials](#find)
20+
* [Verify the Instance is Running](#verify-instance)
21+
* [Use the RabbitMQ Service in Your App](#use)
22+
* [Monitor RabbitMQ Clusters](#monitoring)
23+
* [Delete a RabbitMQ Instance](#delete)
24+
* [Pause Reconciliation for a RabbitMQ Instance](#pause)
2425

2526
## <a id='service-availability' class='anchor' href='#service-availability'>Confirm Service Availability</a>
2627

@@ -940,6 +941,92 @@ For more information about concepts mentioned above, see:
940941
</col>
941942
</table>
942943

944+
## <a id='tls' class='anchor' href='#tls'>(Optional) Configure TLS</a>
945+
946+
Transport Layer Security (TLS) is a protocol for encrypting network traffic. <a href="/ssl.html">RabbitMQ supports TLS</a>, and the cluster operator simplifies the process of configuring a RabbitMQ cluster with [TLS](#one-way-tls) or
947+
[mutual TLS (mTLS)](#mutual-tls) encrypted traffic between clients and the cluter, as well
948+
as supporting [encrypting RabbitMQ inter-node traffic with mTLS](https://github.com/rabbitmq/cluster-operator/tree/main/docs/examples/mtls-inter-node).
949+
A [basic overview of TLS](/ssl.html#certificates-and-keys) is helpful for understanding this guide.
950+
951+
### <a id='one-way-tls' class='anchor' href='#one-way-tls'>TLS encrypting traffic between clients and RabbitMQ</a>
952+
953+
In order to encrypt traffic between clients and the RabbitMQ cluster, the RabbitMQ cluster must be configured with a server certificate and key pair signed by a Certificate Authority (CA) trusted by the clients. This allows clients to verify that the server is trusted, and traffic sent between the client and server are encrypted using the server's keys.
954+
955+
The certificate's Subject Alternative Name (SAN) must contain at least the following attributes:
956+
* `*.<RabbitMQ cluster name>-nodes.<namespace>.svc.<K8s cluster domain name>`
957+
* `<RabbitMQ cluster name>.<namespace>.svc.<K8s cluster domain name>`
958+
959+
If wildcards are not permitted, the certificate must provide a SAN attribute for each RabbitMQ node in the RabbitMQ cluster.
960+
For example, if you deploy a 3-node RabbitMQ cluster named `myrabbit` in namespace `mynamespace` with the default Kubernetes cluster domain `cluster.local`, the SAN must include at least the following attributes:
961+
* `myrabbit-server-0.myrabbit-nodes.mynamespace.svc.cluster.local`
962+
* `myrabbit-server-1.myrabbit-nodes.mynamespace.svc.cluster.local`
963+
* `myrabbit-server-2.myrabbit-nodes.mynamespace.svc.cluster.local`
964+
* `myrabbit.mynamespace.svc.cluster.local`
965+
966+
Note that the last SAN attribute is the client service DNS name.
967+
Depending on the service type used (`spec.service.type`), further SAN attributes may be required.
968+
For example, if using service type `NodePort`, the SAN must include the external IP address of each Kubernetes node.
969+
970+
To enable TLS, create a Kubernetes secret containing the PEM-encoded server certificate `server.pem` and private key `server-key.pem`
971+
972+
<pre class='lang-bash'>
973+
kubectl create secret tls tls-secret --cert=server.pem --key=server-key.pem
974+
</pre>
975+
976+
or use a tool such as <a href="https://cert-manager.io/">Cert Manger</a> to generate a TLS secret.
977+
978+
Once this secret exists, a RabbitMQ cluster can be deployed following the <a href="https://github.com/rabbitmq/cluster-operator/tree/main/docs/examples/tls">TLS example</a>.
979+
980+
<pre class="lang-yaml">
981+
apiVersion: rabbitmq.com/v1beta1
982+
kind: RabbitmqCluster
983+
metadata:
984+
name: additional-port
985+
spec:
986+
replicas: 1
987+
tls:
988+
secretName: tls-secret
989+
</pre>
990+
991+
### <a id='mutual-tls' class='anchor' href='#mutual-tls'>Mutual TLS encryption between clients and RabbitMQ</a>
992+
993+
Mutual TLS (mTLS) enhances TLS by requiring that the server verify the identity of the client, in addition to the client verifying the server, which already occurs in TLS encryption. In order for this mutual verification to occur, both the client and server must be configured with certificate and key pairs, with the client pair signed by a CA trusted by the server and the server pair signed by a CA trusted by the client. The mutual verification process is shown in the following diagram:
994+
995+
<img src="/img/mTLS.png"/>
996+
997+
In addition to the [configuration required to support TLS](#one-way-tls), configuring mutual TLS requires the RabbitMQ cluster to be configured with the CA certificate
998+
used to sign the client certificate and key pair, `ca.pem`. Create a Kuberntes secret with key `ca.crt` containing this secret
999+
1000+
<pre class='lang-bash'>
1001+
kubectl create secret generic ca-secret --from-file=ca.crt=ca.pem
1002+
</pre>
1003+
1004+
or create this secret using a tool such as <a href="https://cert-manager.io/">Cert Manager</a>.
1005+
1006+
Once this secret and the `tls-secret` exist, a RabbitMQ cluster cluster can be deployed following the [mTLS example](https://github.com/rabbitmq/cluster-operator/tree/main/docs/examples/mtls).
1007+
1008+
<pre class="lang-yaml">
1009+
apiVersion: rabbitmq.com/v1beta1
1010+
kind: RabbitmqCluster
1011+
metadata:
1012+
name: mtls
1013+
spec:
1014+
replicas: 1
1015+
tls:
1016+
secretName: tls-secret
1017+
caSecretName: ca-secret
1018+
</pre>
1019+
1020+
In order to enforce client verification, RabbitMQ must be configured to reject clients that do not present certificates. This can be done by enabling [TLS peer verification](ssl.html#peer-verification) using
1021+
the `ssl_options.fail_if_no_peer_cert` option in the additional config:
1022+
1023+
<pre class="lang-yaml">
1024+
spec:
1025+
rabbitmq:
1026+
additionalConfig: |
1027+
ssl_options.fail_if_no_peer_cert = true
1028+
</pre>
1029+
9431030

9441031
## <a id='find' class='anchor' href='#find'>Find Your RabbitmqCluster Service Name and Admin Credentials</a>
9451032

site/ssl.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ TLS can be enabled for all protocols supported by RabbitMQ, not just AMQP 0-9-1,
5151
which this guide focuses on. [HTTP API](/management.html), [inter-node and CLI tool traffic](/clustering-ssl.html) can be configured
5252
to use TLS (HTTPS) as well.
5353

54+
To configure TLS on Kubernetes using the RabbitMQ Cluster Operator, see the guide for [Configuring TLS](/kubernetes/operator/using-operator.html#tls).
55+
5456
For an overview of common TLS troubleshooting techniques, see [Troubleshooting TLS-related issues](troubleshooting-ssl.html)
5557
and [Troubleshooting Networking](troubleshooting-networking.html).
5658

0 commit comments

Comments
 (0)