Skip to content

Commit 1d78be2

Browse files
committed
doc: review
Signed-off-by: Armando Ruocco <[email protected]>
1 parent f0109aa commit 1d78be2

File tree

2 files changed

+87
-51
lines changed

2 files changed

+87
-51
lines changed

web/docs/resource-name-migration.md

Lines changed: 79 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar_position: 41
88

99
:::warning
1010
Before running the migration script or applying the manifest, please:
11-
1. **Review the complete manifest** on the [Migration Manifest](migration-manifest.md) page to understand what changes will be made
11+
1. **Review the complete manifest** at [migration-rbac.yaml](/migration-rbac.yaml) to understand what changes will be made
1212
2. **Test in a non-production environment** first if possible
1313
3. **Ensure you have proper backups** of your cluster configuration
1414
4. **Verify the resource names match** your current installation (default namespace is `cnpg-system`)
@@ -50,26 +50,16 @@ Using generic names for cluster-wide resources is discouraged as they may confli
5050
The migration process is straightforward and can be completed with a few kubectl commands.
5151

5252
:::danger Verify Resources Before Deletion
53-
**IMPORTANT**: The old resource names are generic and could potentially belong to other components in your cluster. Before deleting, verify they belong to the barman plugin by checking their labels:
53+
**IMPORTANT**: The old resource names are generic and could potentially belong to other components in your cluster.
5454

55-
```bash
56-
# Check if the resources have the barman plugin labels
57-
kubectl get clusterrole metrics-auth-role -o yaml | grep -A 5 "labels:"
58-
kubectl get clusterrole metrics-reader -o yaml | grep -A 5 "labels:"
59-
kubectl get clusterrole objectstore-viewer-role -o yaml | grep -A 5 "labels:"
60-
kubectl get clusterrole objectstore-editor-role -o yaml | grep -A 5 "labels:"
61-
kubectl get clusterrolebinding metrics-auth-rolebinding -o yaml | grep -A 5 "labels:"
62-
```
55+
**Before deleting each resource, verify it belongs to the barman plugin by checking:**
56+
- For `objectstore-*` roles: Look for `barmancloud.cnpg.io` in the API groups
57+
- For `metrics-*` roles: Check if they reference the `plugin-barman-cloud` ServiceAccount in `cnpg-system` namespace
58+
- For other roles: Look for labels like `app.kubernetes.io/name: plugin-barman-cloud`
6359

64-
Look for labels like `app.kubernetes.io/name: plugin-barman-cloud` or references to `barmancloud.cnpg.io` in the rules. If the resources don't have these indicators, **DO NOT DELETE THEM** as they may belong to another application.
65-
66-
If you're unsure, you can also check what the resources manage:
67-
```bash
68-
kubectl get clusterrole objectstore-viewer-role -o yaml
69-
kubectl get clusterrole objectstore-editor-role -o yaml
70-
```
60+
If a resource doesn't have these indicators, **DO NOT DELETE IT** as it may belong to another application.
7161

72-
These should reference `barmancloud.cnpg.io` API groups. If they don't, they are not barman plugin resources.
62+
In Step 1 below, carefully review the output of each verification command before proceeding with the delete.
7363
:::
7464

7565
:::tip Dry Run First
@@ -80,24 +70,55 @@ You can add `--dry-run=client` to any `kubectl delete` command to preview what w
8070

8171
**Only proceed if you've verified these resources belong to the barman plugin (see warning above).**
8272

73+
For each resource below, first verify it belongs to barman, then delete it:
74+
8375
```bash
84-
# Only delete if this belongs to barman plugin (check labels first)
85-
kubectl delete clusterrole metrics-auth-role
76+
# 1. Check metrics-auth-rolebinding FIRST (we'll check the role after)
77+
# Look for references to plugin-barman-cloud ServiceAccount
78+
kubectl describe clusterrolebinding metrics-auth-rolebinding
79+
# If it references plugin-barman-cloud ServiceAccount in cnpg-system namespace, delete it:
80+
kubectl delete clusterrolebinding metrics-auth-rolebinding
8681

87-
# Only delete if this belongs to barman plugin (check labels first)
88-
kubectl delete clusterrole metrics-reader
82+
# 2. Check metrics-auth-role
83+
# Look for references to authentication.k8s.io and authorization.k8s.io
84+
kubectl describe clusterrole metrics-auth-role
85+
# Verify it's not being used by any other rolebindings:
86+
kubectl get clusterrolebinding -o json | jq -r '.items[] | select(.roleRef.name=="metrics-auth-role") | .metadata.name'
87+
# If the above returns nothing (role is not in use) and the role looks like the barman one, delete it (see warnings section):
88+
kubectl delete clusterrole metrics-auth-role
8989

90-
# Only delete if this belongs to barman plugin (check labels first)
90+
# 3. Check objectstore-viewer-role
91+
# Look for barmancloud.cnpg.io API group or app.kubernetes.io/name: plugin-barman-cloud label
92+
kubectl describe clusterrole objectstore-viewer-role
93+
# If it shows barmancloud.cnpg.io in API groups, delete it:
9194
kubectl delete clusterrole objectstore-viewer-role
9295

93-
# Only delete if this belongs to barman plugin (check labels first)
96+
# 4. Check objectstore-editor-role
97+
# Look for barmancloud.cnpg.io API group or app.kubernetes.io/name: plugin-barman-cloud label
98+
kubectl describe clusterrole objectstore-editor-role
99+
# If it shows barmancloud.cnpg.io in API groups, delete it:
94100
kubectl delete clusterrole objectstore-editor-role
95101

96-
# Only delete if this belongs to barman plugin (check labels first)
97-
kubectl delete clusterrolebinding metrics-auth-rolebinding
102+
# 5. Check metrics-reader (MOST DANGEROUS - very generic name)
103+
# First, check if it's being used by any rolebindings OTHER than barman's:
104+
kubectl get clusterrolebinding -o json | jq -r '.items[] | select(.roleRef.name=="metrics-reader") | "\(.metadata.name) -> \(.subjects[0].name) in \(.subjects[0].namespace)"'
105+
# If this shows ANY rolebindings, review them carefully. Only proceed if they're all barman-related.
106+
# Then check the role itself:
107+
kubectl describe clusterrole metrics-reader
108+
# If it ONLY has nonResourceURLs: /metrics and NO other rolebindings use it, delete it:
109+
kubectl delete clusterrole metrics-reader
98110
```
99111

100-
If any resource is not found, that's okay - it means it was never created or already deleted.
112+
:::warning
113+
The `metrics-reader` role is particularly dangerous to delete blindly. Many monitoring systems use this exact name. Only delete it if:
114+
1. You've verified it ONLY grants access to `/metrics`
115+
2. No other rolebindings reference it (checked with the jq command above)
116+
3. You're certain it was created by the barman plugin
117+
118+
If you're unsure, it's safer to leave it and let the new `barman-plugin-metrics-reader` role coexist with it.
119+
:::
120+
121+
If any resource is not found during the `describe` command, that's okay - it means it was never created or already deleted. Simply skip the delete command for that resource.
101122

102123
### Step 2: Delete Old Namespace-scoped Resources
103124

@@ -118,17 +139,44 @@ kubectl delete rolebinding leader-election-rolebinding -n cnpg-system
118139
Download and apply the new manifest with the updated resource names:
119140

120141
```bash
121-
kubectl apply -f https://cloudnative-pg.io/plugin-barman-cloud/migration-rbac.yaml -n cnpg-system
142+
kubectl apply -f https://cloudnative-pg.io/plugin-barman-cloud/migration-rbac.yaml
122143
```
123144

124-
Alternatively, you can copy the complete YAML from the [Migration Manifest](migration-manifest.md) page, save it to a file, and apply it locally:
145+
:::caution Custom Namespace Users
146+
If you're using a **different namespace** than `cnpg-system`, you'll need to download the manifest and modify it before applying:
125147

126148
```bash
127-
kubectl apply -f barman-rbac-new.yaml -n cnpg-system
149+
# Download the file
150+
curl -O https://cloudnative-pg.io/plugin-barman-cloud/migration-rbac.yaml
151+
152+
# Replace ALL occurrences of cnpg-system with your namespace
153+
sed -i.bak 's/cnpg-system/your-namespace/g' migration-rbac.yaml
154+
155+
# Review the changes
156+
cat migration-rbac.yaml
157+
158+
# Apply it
159+
kubectl apply -f migration-rbac.yaml
160+
```
161+
162+
The manifest has `cnpg-system` hardcoded in multiple places (namespace metadata and ClusterRoleBinding subjects), so all occurrences need to be replaced.
163+
:::
164+
165+
Alternatively, you can download the [migration-rbac.yaml](/migration-rbac.yaml) file and review it locally before applying:
166+
167+
```bash
168+
# Download the file
169+
curl -O https://cloudnative-pg.io/plugin-barman-cloud/migration-rbac.yaml
170+
171+
# Review it
172+
cat migration-rbac.yaml
173+
174+
# Apply it (no need to specify namespace, it's in the manifest)
175+
kubectl apply -f migration-rbac.yaml
128176
```
129177

130178
:::info
131-
The new manifest will create all RBAC resources with the `barman-plugin-` prefix. Review the [Migration Manifest](migration-manifest.md) page to see exactly what will be created.
179+
The new manifest will create all RBAC resources with the `barman-plugin-` prefix. You can review the complete YAML at [migration-rbac.yaml](/migration-rbac.yaml).
132180
:::
133181

134182
## Impact
@@ -170,20 +218,6 @@ If the plugin fails to start after migration, check:
170218
kubectl describe clusterrolebinding barman-plugin-metrics-auth-rolebinding
171219
```
172220

173-
### Old Resources Still Present
174-
175-
If old resources weren't deleted properly, you can force delete them:
176-
177-
```bash
178-
kubectl delete clusterrole metrics-auth-role --ignore-not-found
179-
kubectl delete clusterrole metrics-reader --ignore-not-found
180-
kubectl delete clusterrole objectstore-viewer-role --ignore-not-found
181-
kubectl delete clusterrole objectstore-editor-role --ignore-not-found
182-
kubectl delete clusterrolebinding metrics-auth-rolebinding --ignore-not-found
183-
kubectl delete role leader-election-role -n cnpg-system --ignore-not-found
184-
kubectl delete rolebinding leader-election-rolebinding -n cnpg-system --ignore-not-found
185-
```
186-
187221
## Support
188222

189223
If you encounter issues during migration, please open an issue on the [GitHub repository](https://github.com/cloudnative-pg/plugin-barman-cloud/issues).

web/static/migration-rbac.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# This manifest contains the RBAC resources for the plugin-barman-cloud migration.
22
#
3-
# IMPORTANT: This manifest should be applied with the namespace flag:
4-
# kubectl apply -f migration-rbac.yaml -n cnpg-system
3+
# IMPORTANT: This manifest is configured for the 'cnpg-system' namespace.
4+
# Simply apply it with:
5+
# kubectl apply -f migration-rbac.yaml
56
#
6-
# If you are using a different namespace, replace 'cnpg-system' with your namespace.
7-
# The namespace-scoped resources (ServiceAccount, Role, RoleBinding) will be created
8-
# in the namespace you specify, while cluster-scoped resources (ClusterRole, ClusterRoleBinding)
9-
# will be created globally but will reference the ServiceAccount in your specified namespace.
7+
# If you are using a different namespace, you must replace all occurrences of
8+
# 'cnpg-system' in this file with your namespace before applying.
109
#
1110
apiVersion: v1
1211
kind: ServiceAccount
@@ -15,6 +14,7 @@ metadata:
1514
app.kubernetes.io/managed-by: kustomize
1615
app.kubernetes.io/name: plugin-barman-cloud
1716
name: plugin-barman-cloud
17+
namespace: cnpg-system
1818
---
1919
apiVersion: rbac.authorization.k8s.io/v1
2020
kind: Role
@@ -23,6 +23,7 @@ metadata:
2323
app.kubernetes.io/managed-by: kustomize
2424
app.kubernetes.io/name: plugin-barman-cloud
2525
name: barman-plugin-leader-election-role
26+
namespace: cnpg-system
2627
rules:
2728
- apiGroups:
2829
- ""
@@ -209,6 +210,7 @@ metadata:
209210
app.kubernetes.io/managed-by: kustomize
210211
app.kubernetes.io/name: plugin-barman-cloud
211212
name: barman-plugin-leader-election-rolebinding
213+
namespace: cnpg-system
212214
roleRef:
213215
apiGroup: rbac.authorization.k8s.io
214216
kind: Role

0 commit comments

Comments
 (0)