Skip to content

Commit 1b0f7b3

Browse files
MuhannadimadMuhannad.abdulkareem
andauthored
enhance restore cert-manager resources (#1694)
* enhance restore cert-manager resources Signed-off-by: Muhannad.abdulkareem <[email protected]> * Update backup.md Signed-off-by: MuhannadImad <[email protected]> * remove unneeded change Signed-off-by: MuhannadImad <[email protected]> --------- Signed-off-by: Muhannad.abdulkareem <[email protected]> Signed-off-by: MuhannadImad <[email protected]> Co-authored-by: Muhannad.abdulkareem <[email protected]>
1 parent f1d25e7 commit 1b0f7b3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

content/docs/devops-tips/backup.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ certificates, restoring to a cluster that does not already have those
2020
To backup all of your cert-manager configuration resources, run:
2121

2222
```bash
23-
kubectl get --all-namespaces -oyaml issuer,clusterissuer,cert > backup.yaml
23+
kubectl get --all-namespaces -ojson issuer,clusterissuer,cert > backup.json
2424
```
2525

2626
If you are transferring data to a new cluster, you may also need to copy across
@@ -51,9 +51,16 @@ created above after installing cert-manager, with the exception of the
5151
`uid` and `resourceVersion` fields that do not need to be restored:
5252

5353
```bash
54-
kubectl apply -f <(awk '!/^ *(resourceVersion|uid): [^ ]+$/' backup.yaml)
54+
jq 'walk(if type == "object" and has("metadata") then .metadata |= (del(.uid) | del(.resourceVersion)) else . end)' \
55+
backup.json | kubectl apply -f -
5556
```
5657

58+
Note:
59+
If your backup contains resources such as Certificate objects that were generated by annotated Ingress resources, be aware that those Certificate resources may contain `ownerReferences` with `uid` fields that are required to maintain their association with the Ingress.
60+
61+
The above command safely removes the `uid` from the top-level metadata, but preserves the `uid` in `ownerReferences`, ensuring that the ownership relationship between Ingress and Certificate is retained.
62+
63+
5764
## Full cluster backup and restore
5865

5966
This section refers to backing up and restoring 'all' Kubernetes resources in a
@@ -197,4 +204,4 @@ velero restore create \
197204
[^1]: there is an edge case where certain changes to `Certificate` spec may not
198205
trigger re-issuance if there is no `CertificateRequest` for that
199206
`Certificate`. See [documentation on when do certificates get
200-
re-issued](../faq/README.md#when-do-certs-get-re-issued).
207+
re-issued](../faq/README.md#when-do-certs-get-re-issued).

0 commit comments

Comments
 (0)