Skip to content

Commit a8ff50a

Browse files
authored
Merge pull request #1353 from inteon/add_concrete_velero_example
Add a concrete example on how to restore a cert-manager installation
2 parents 2efcce5 + 6e597d4 commit a8ff50a

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

content/docs/devops-tips/backup.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,16 @@ to a situation where updates to the `Ingress` (i.e a new DNS name) are not
101101
applied to the `Certificate`.
102102

103103
To avoid this issue, in most cases `Certificate`s created via `ingress-shim`
104-
can be excluded from the backup. Given that the restore happens
104+
should be excluded from the backup. Given that the restore happens
105105
in the correct order (`Secret` with the X.509 certificate restored before
106106
the `Ingress`) `cert-manager` will be able to create a new `Certificate`
107107
for the `Ingress` and determine that the existing `Secret` is for that `Certificate`.
108108

109109
### Velero
110110

111-
We have briefly tested backup and restore with `velero` `v1.5.3` and
112-
`cert-manager` versions `v1.3.1` and `v1.3.0` as well as `velero` `v1.3.1`
113-
and `cert-manager` `v1.1.0`.
111+
We have tested backup and restore with `velero` `v1.12.2` and `cert-manager` version `v1.13.2`.
114112

115-
A few potential edge cases:
113+
A few potential edge cases:
116114

117115
- Ensure that the backups include `cert-manager` CRDs.
118116
For example, we have seen that if `--exclude-namespaces` flag is passed to
@@ -124,7 +122,7 @@ We have briefly tested backup and restore with `velero` `v1.5.3` and
124122
exclude `Order`s, `Challenge`s and `CertificateRequest`s from the backup, see
125123
[Excluding some cert-manager resources from backup](#excluding-some-cert-manager-resources-from-backup).
126124

127-
- Velero's [default restore order](https://github.com/vmware-tanzu/velero/blob/main/pkg/cmd/server/server.go#L470)(`Secrets` before `Ingress`es, Custom Resources
125+
- Velero's [default restore order](https://github.com/vmware-tanzu/velero/blob/a318e1da995a390c9f10e4aef7df356594944377/pkg/cmd/server/server.go#L511-L543) (`Secrets` before `Ingress`es, Custom Resources
128126
restored last), should ensure that there is no unnecessary certificate reissuance
129127
due to the order of restore operation, see [Order of restore](#order-of-restore).
130128

@@ -140,6 +138,41 @@ We have briefly tested backup and restore with `velero` `v1.5.3` and
140138
`Certificate`s created for `Ingress`es from the backup even when not
141139
re-creating the `Ingress` itself. See [Restoring Ingress Certificates](#restoring-ingress-certificates).
142140

141+
142+
#### Example backup and restore using Velero
143+
144+
The following command will create a backup of all Kubernetes resources in the
145+
default and cert-manager namespaces, excluding `Order`s, `Challenge`s and
146+
`CertificateRequest`s (see above):
147+
```bash
148+
velero backup create \
149+
full-backup \
150+
--include-namespaces cert-manager,default \
151+
--include-cluster-resources=true \
152+
--exclude-resources challenges.acme.cert-manager.io,orders.acme.cert-manager.io,certificaterequests.cert-manager.io
153+
```
154+
155+
To workaround Velero not restoring owner references, you can restore the backup
156+
in two steps: first restore the `Secret`s and `Ingress`es and the `cert-manager`
157+
deployment, second restore the `Certificate` resources. This will allow `cert-manager`'s
158+
controller to create the `Certificate` for the ingresses and set the owner reference.
159+
The second restore will then restore the manually created `Certificate`s and detect that
160+
the generated `Certificate`s for the `Ingress`es already exist and will not attempt to
161+
recreate them.
162+
163+
1. Restore everything except `Certificate` resources:
164+
```bash
165+
velero restore create \
166+
--from-backup full-backup \
167+
--exclude-resources certificates.cert-manager.io
168+
```
169+
170+
2. Wait for cert-manager to create the `Certificate`s for the `Ingress`es (if cert-manager is having RBAC/ webhook issues, you might have to manually restart the deployments). After the auto-generated `Certificate`s are created, restore the manually created `Certificate`s:
171+
```bash
172+
velero restore create \
173+
--from-backup full-backup
174+
```
175+
143176
## Backing up CertificateRequests
144177

145178
We no longer recommend including `CertificateRequest` resources in a backup

0 commit comments

Comments
 (0)