|
| 1 | +--- |
| 2 | +categories: |
| 3 | +- docs |
| 4 | +- operate |
| 5 | +- kubernetes |
| 6 | +description: Store Redis Enterprise configuration items in Kubernetes Secrets for automatic updates and secure management. |
| 7 | +linkTitle: Configuration secrets |
| 8 | +title: Store configuration in Kubernetes Secrets |
| 9 | +weight: 96 |
| 10 | +--- |
| 11 | + |
| 12 | +When using Redis Enterprise for Kubernetes, you can store certain configuration items in Kubernetes Secrets. This approach has the advantage that updates to these Secrets, once configured, are read immediately by the Operator and propagated to the Redis Enterprise Cluster (REC). |
| 13 | + |
| 14 | +## License configuration |
| 15 | + |
| 16 | +Redis Enterprise clusters require a valid license to operate. You can apply licenses using Kubernetes Secrets or by embedding them directly in the cluster specification. This section covers how to determine your cluster's FQDN for licensing purposes and demonstrates both methods for license configuration. |
| 17 | + |
| 18 | +### Determine your cluster FQDN |
| 19 | + |
| 20 | +For licensing purposes, you need to know your Redis Enterprise cluster's fully qualified domain name (FQDN). In Kubernetes, the REC's FQDN is the fully qualified name of the REC API service and follows this format: |
| 21 | + |
| 22 | +``` |
| 23 | +<REC name>.<namespace>.svc.cluster.local |
| 24 | +``` |
| 25 | + |
| 26 | +For example, if a REC is named `my-rec` and is deployed in the namespace `my-ns`, the FQDN will be `my-rec.my-ns.svc.cluster.local`. |
| 27 | + |
| 28 | +### Method 1: Using a Kubernetes Secret (Recommended) |
| 29 | + |
| 30 | +You can set the license in the REC through the `licenseSecretName` YAML property. |
| 31 | + |
| 32 | +1. Add your raw license to a text file (for example, `license.txt`). |
| 33 | + |
| 34 | +2. Execute the following command to create the Secret (in this example called `rec-license`) with a key called `license`: |
| 35 | + |
| 36 | + ```sh |
| 37 | + kubectl -n <namespace> create secret generic rec-license --from-file=license=./license.txt |
| 38 | + ``` |
| 39 | + |
| 40 | +3. Edit the REC definition and add the property `licenseSecretName: rec-license`. This will be immediately read by the Operator. |
| 41 | + |
| 42 | + ```sh |
| 43 | + kubectl edit rec <rec-name> |
| 44 | + ``` |
| 45 | + |
| 46 | + Add the following to the spec: |
| 47 | + |
| 48 | + ```yaml |
| 49 | + spec: |
| 50 | + licenseSecretName: rec-license |
| 51 | + ``` |
| 52 | + |
| 53 | +### Method 2: Direct license in REC specification |
| 54 | + |
| 55 | +Alternatively, you can specify the license key string directly in the REC YAML: |
| 56 | + |
| 57 | +```yaml |
| 58 | +spec: |
| 59 | + nodes: 3 |
| 60 | + license: | |
| 61 | + ----- LICENSE START ----- |
| 62 | + eai14c/y6XNVykffDQSPUsHKcmpgOFUlmyTBDUEZEz+GLbXAgQFOmxcdbR9J |
| 63 | + ...remaining license key content... |
| 64 | + ----- LICENSE END ----- |
| 65 | +``` |
| 66 | + |
| 67 | +{{<note>}} |
| 68 | +Pay attention to the indentation and spaces in the file and make sure the pipe symbol (`|`) is included after `license:`. |
| 69 | +{{</note>}} |
| 70 | + |
| 71 | +## TLS certificate configuration |
| 72 | + |
| 73 | +TLS certificates are essential for securing communication between clients and Redis Enterprise databases, as well as between internal cluster components. This section explains how to store client certificates for mutual TLS authentication and how to configure certificates for different Redis Enterprise services using Kubernetes Secrets. |
| 74 | + |
| 75 | +### Client certificates for mTLS |
| 76 | + |
| 77 | +Here's how to set a client certificate for mutual TLS (mTLS). |
| 78 | +
|
| 79 | +1. Create a Secret called `client-cert-secret` with a property named `cert` using the following command: |
| 80 | +
|
| 81 | + ```sh |
| 82 | + kubectl -n <namespace> create secret generic client-cert-secret --from-file=cert=<path-to-cert> |
| 83 | + ``` |
| 84 | +
|
| 85 | +2. Add this secret to the relevant Redis Enterprise Database (REDB) using the `clientAuthenticationCertificates` property as documented in [Add client certificates]({{< relref "/operate/kubernetes/security/add-client-certificates" >}}). |
| 86 | +
|
| 87 | +{{<note>}} |
| 88 | +At the time of writing (November 14, 2023), the public documentation describes creating the secret directly in YAML. This approach has the disadvantage that it requires the user to ensure the certificate is correctly encoded to base64. This can be done using a command like `cat my-cert.pem | openssl base64`. Then paste the output into the YAML source file. |
| 89 | +{{</note>}} |
| 90 | +
|
| 91 | +### Certificates for different services |
| 92 | +
|
| 93 | +The notes above were valid for a client certificate. If you want to create a secret for proxy, API, or other services, they expect different keys: |
| 94 | +
|
| 95 | +```sh |
| 96 | +kubectl create secret generic <secret-name> \ |
| 97 | + --from-file=certificate=</PATH/TO/certificate.pem> \ |
| 98 | + --from-file=key=</PATH/TO/key.pem> \ |
| 99 | + --from-literal=name=<proxy | api | cm | syncer | metrics_exporter> |
| 100 | +``` |
| 101 | +
|
| 102 | +## Best practices |
| 103 | +
|
| 104 | +- Store sensitive configuration items like licenses and certificates in Secrets rather than directly in YAML files |
| 105 | +- Use the `--from-file` option when creating secrets to avoid manual base64 encoding |
| 106 | +- Ensure secrets are created in the same namespace as your REC or REDB resources |
| 107 | +- Use descriptive names for your secrets to make them easy to identify and manage |
| 108 | +- Regularly rotate certificates and update the corresponding secrets |
| 109 | +
|
| 110 | +## See also |
| 111 | +
|
| 112 | +- [Manage REC credentials]({{< relref "/operate/kubernetes/security/manage-rec-credentials" >}}) |
| 113 | +- [Manage REC certificates]({{< relref "/operate/kubernetes/security/manage-rec-certificates" >}}) |
| 114 | +- [Add client certificates]({{< relref "/operate/kubernetes/security/add-client-certificates" >}}) |
| 115 | +- [Redis Enterprise Cluster API reference]({{< relref "/operate/kubernetes/reference/redis_enterprise_cluster_api" >}}) |
0 commit comments