Skip to content

Commit c877023

Browse files
authored
K8SPXC- 1494 Documented custom duration setup for TLS and CA (#271)
K8SPXC-1494 Documented TLS certificate and CA certificate validity durations in operator and cert-manager documentation. Added rules and limitations for customizing certificate durations. modified: docs/operator.md modified: docs/tls-cert-manager.md
1 parent e9f5712 commit c877023

File tree

7 files changed

+85
-15
lines changed

7 files changed

+85
-15
lines changed

docs/backups-restore-to-new-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Configure the `PerconaXtraDBClusterRestore` Custom Resource. Specify the followi
7171
and the backup name.
7272
* the necessary [storage configuration keys](backups-storage.md#configure-storage-for-backups), just like in the `deploy/cr.yaml` file of the source cluster.
7373
* `verifyTLS` to verify the storage server TLS certificate
74-
* the custom TLS configuration if you use it for backups. Refer to the [backups-storage.md#configure-tls-verification-with-custom-certificates-for-s3-storage] section for more information.
74+
* the custom TLS configuration if you use it for backups. Refer to the [Configure TLS verification with custom certificates for S3 storage](backups-storage.md#configure-tls-verification-with-custom-certificates-for-s3-storage) section for more information.
7575

7676
```yaml
7777
...

docs/backups-storage.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ Before configuring the storage, you need to create a [Kubernetes Secret :octicon
8181
bucket: S3-BACKUP-BUCKET-NAME-HERE
8282
region: us-west-2
8383
credentialsSecret: my-cluster-name-backup-s3
84+
caBundle:
85+
name: minio-ca-bundle
86+
key: tls.cert
8487
...
8588
```
8689
@@ -102,11 +105,11 @@ Before configuring the storage, you need to create a [Kubernetes Secret :octicon
102105

103106
To configure TLS verification with custom certificates, do the following:
104107

105-
1. Create the Secret object that contains the CA certificate used for authentication to S3 storage
108+
1. Create the Secret object that contains the TLS certificate to access the S3 storage, the certificate's private key and the CA certificate.
106109
2. Modify the S3 storage configuration in the Custom Resource and specify the following information:
107110

108111
* `storages.<NAME>.s3.caBundle.name` is the name of the Secret object you created previously
109-
* `storages.<NAME>.s3.caBundle.key` is the CA certificate to use.
112+
* `storages.<NAME>.s3.caBundle.key` is the CA certificate.
110113
111114
Here's the example configuration:
112115

docs/operator.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ Enables or disables the [TLS encryption](TLS.md). If set to `false`,
239239
| ----------- | ---------- |
240240
| :material-toggle-switch-outline: boolean | `true` |
241241

242+
### `tls.certValidityDuration`
243+
244+
Validity period for TLS certificates. Minimum required validity is 1 hour. Durations lower than 1 hour are rejected. Setting the duration to exactly 1 hour prevents the Operator from generating the correct certificate object.
245+
246+
| Value type | Example |
247+
| ----------- | ---------- |
248+
| :material-code-string: string | `2160h` |
249+
250+
### `tls.caValidityDuration`
251+
252+
Validity period for CA certificate. Minimum accepted duration is 730 hours (approximately 30 days). Setting this value to exactly 730 hours prevents the Operator from generating the correct certificate object. You must set this value greater than 730 hours.
253+
254+
| Value type | Example |
255+
| ----------- | ---------- |
256+
| :material-code-string: string | `26280h` |
257+
242258
### `tls.SANs`
243259

244260
Additional domains (SAN) to be added to the TLS certificate within the extended cert-manager configuration.
@@ -2540,7 +2556,7 @@ The timeout value in seconds, after which backup job will automatically fail.
25402556
| ----------- | ---------- |
25412557
| :material-numeric-1-box: int | `3600` |
25422558

2543-
### backup.startingDeadlineSeconds
2559+
### `backup.startingDeadlineSeconds`
25442560

25452561
The maximum time in seconds for a backup to start. The Operator compares the timestamp of the backup object against the current time. If the backup is not started within the set time, the Operator automatically marks it as "failed".
25462562

@@ -3023,6 +3039,14 @@ configuration file. This Custom Resource contains the following options:
30233039
| credentialsSecret| string | The Secret name for the backup | true |
30243040
| endpointUrl | string | A valid endpoint URL | false |
30253041
| region | string | The region corresponding to the S3 bucket | false |
3042+
| caBundle | subdoc | Configuration for custom self-issued TLS certificates | false
3043+
3044+
#### backupSource.s3.caBundle subsection
3045+
3046+
| Key | Value type | Description | Required |
3047+
| ---------------- | ----------------- | ---------------------------------------------- | -------- |
3048+
| name | string | The name of the Secret object that stores custom TLS certificates | true |
3049+
| key | string | The custom CA certificate file used to sign TLS certificates | true |
30263050

30273051
### <a name="operator-restore-azure-options-section"></a>backupSource.azure subsection
30283052

docs/tls-cert-manager.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,48 @@ The steps to install the *cert-manager* are the following:
6565
cert-manager-webhook-58f4cff74d-th4pp 1/1 Running 0 65s
6666
```
6767

68-
Once you create the database with the Operator, it will automatically trigger the cert-manager to create certificates. Whenever you check certificates for expiration, you will find that they are valid and short-term.
68+
At this point, you can move on to [deploying the Operator and your database cluster](kubectl.md).
69+
70+
## Customize certificate duration for cert-manager
71+
72+
When you deploy the cluster using the default configuration, the Operator triggers the cert-manager to create certificates
73+
with default duration of 90 days.
74+
75+
You can also customize the certificate duration. For example, to align certificate lifetimes with your organization’s security and compliance policies.
76+
77+
### Rules and limitations
78+
79+
Check the following rules and limitations for setting up the certificate duration:
80+
81+
1. You can set the duration **only when you create a new cluster**. Updating it in a running cluster is not supported.
82+
2. The TLS certificate duration is subject to the following requirements:
83+
84+
- The minimum accepted value is 1 hour. Durations below 1 hour are rejected.
85+
- Do **not** set the duration to exactly 1 hour; the Operator will fail to generate the correct certificate object if you do.
86+
- By default, cert-manager starts the renewal process when a certificate has one-third of its lifetime remaining, ensuring renewal before expiration. For example, if a certificate is valid for 1 hour, renewal will begin after approximately 40 minutes.
87+
88+
3. Minimum CA certificate duration is 730 hours (approximately 30 days). Do not set the duration to exactly 730 hours; the Operator will fail to generate the correct certificate object if you do.
89+
90+
### Configuration
91+
92+
To set the custom duration, specify the following options in the Custom Resource:
93+
94+
* `.spec.tls.certValidityDuration` – validity period for TLS certificates
95+
* `.spec.tls.caValidityDuration` – validity period for the Certificate Authority (CA)
96+
97+
Here's the example configuration:
98+
99+
```yaml
100+
tls:
101+
enabled: true
102+
certValidityDuration: 2160h
103+
caValidityDuration: 26280h
104+
```
105+
106+
Create a new cluster with this configuration:
107+
108+
```bash
109+
kubectl -f deploy/cr.yaml -n <namespace>
110+
```
111+
112+
To verify the durations, you can [check certificates for expiration](tls-update.md#check-your-certificates-for-expiration) at any time. This ensures your certificates are valid and helps you plan for renewals before they expire.

docs/tls-manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ You can generate TLS certificates manually instead of using the Operator's autom
77

88
When you follow the steps from this guide, you'll generate these certificate files:
99

10-
* `server.pem` - Server certificate for MongoDB nodes
10+
* `server.pem` - Server certificate for Percona XtraDB Cluster nodes
1111
* `server-key.pem` - Private key for the server certificate
1212
* `client.pem` - Client certificate for external connections
1313
* `client-key.pem` - Private key for the client certificate

docs/tls-update.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you [use cert-manager](tls-cert-manager.md):
1717
1. Check the necessary secrets names (`cluster1-ssl` and
1818
`cluster1-ssl-internal` by default):
1919

20-
``` {.bash data-prompt="$" }
20+
```bash
2121
kubectl get certificate
2222
```
2323

@@ -90,9 +90,9 @@ as follows.
9090
and the TLS certificate key (`tls.key.old`):
9191
9292
```bash
93-
kubectl get secret/ps-cluster1-ssl -o jsonpath='{.data.ca\.crt}' | base64 --decode > ca.pem.old
94-
kubectl get secret/ps-cluster1-ssl -o jsonpath='{.data.tls\.crt}' | base64 --decode > tls.pem.old
95-
kubectl get secret/ps-cluster1-ssl -o jsonpath='{.data.tls\.key}' | base64 --decode > tls.key.old
93+
kubectl get secret/cluster1-ssl -o jsonpath='{.data.ca\.crt}' | base64 --decode > ca.pem.old
94+
kubectl get secret/cluster1-ssl -o jsonpath='{.data.tls\.crt}' | base64 --decode > tls.pem.old
95+
kubectl get secret/cluster1-ssl -o jsonpath='{.data.tls\.key}' | base64 --decode > tls.key.old
9696
```
9797
9898
3. Combine new and current `ca.pem` into a `ca.pem.combined` file:
@@ -104,11 +104,11 @@ as follows.
104104
4. Create a new Secrets object with the *old* TLS certificate (`tls.pem.old`) and key (`tls.key.old`), but a *new combined* `ca.pem` (`ca.pem.combined`):
105105
106106
``` bash
107-
kubectl create secret generic ps-cluster1-ssl \
107+
kubectl create secret generic cluster1-ssl \
108108
--from-file=tls.crt=server.pem.old \
109109
--from-file=tls.key=server-key.pem.old \
110110
--from-file=ca.crt=ca.pem.combined \
111-
--type=Opague -o yaml --dry-run=client | kubectl apply -f -
111+
--type=kubernetes.io/tls -o yaml --dry-run=client | kubectl apply -f -
112112
```
113113
114114
5. The cluster will go through a rolling restart. This process will not cause issues, because every node has the old TLS certificate/key, and both new
@@ -117,7 +117,7 @@ as follows.
117117
6. Create a new Secrets object again. This time use a new TLS certificate (`server.pem` in the example) and a new TLS key (`server-key.pem`), and again the combined CA certificate (`ca.pem.combined`):
118118
119119
``` bash
120-
kubectl create secret generic ps-cluster1-ssl \
120+
kubectl create secret generic cluster1-ssl \
121121
--from-file=tls.crt=server.pem \
122122
--from-file=tls.key=server-key.pem \
123123
--from-file=ca.crt=ca.pem.combined \
@@ -133,7 +133,7 @@ as follows.
133133
its key (`server-key.pem`), and only the new CA certificate (`ca.pem`):
134134
135135
``` bash
136-
kubectl create secret generic ps-cluster1-ssl \
136+
kubectl create secret generic cluster1-ssl \
137137
--from-file=tls.crt=server.pem \
138138
--from-file=tls.key=server-key.pem \
139139
--from-file=ca.crt=ca.pem \

mkdocs-base.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ not_in_nav: |
167167
168168
# Common navigation for percona.com, render.com and PDF
169169
nav:
170-
171170
- Welcome: index.md
172171
- get-help.md
173172
- Features:

0 commit comments

Comments
 (0)