Skip to content

Commit 27d073a

Browse files
armrumnencia
authored andcommitted
feat(rbac)!: prefix all resource names to avoid cluster conflicts
BREAKING CHANGE: All RBAC resource names have been renamed with consistent prefixes to prevent naming conflicts with other cluster components. Users must migrate their existing installations by deleting old resources and applying the new manifest. See the migration guide for detailed instructions: https://cloudnative-pg.io/plugin-barman-cloud/resource-name-migration/ Signed-off-by: Armando Ruocco <[email protected]>
1 parent 49f1096 commit 27d073a

10 files changed

+454
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### BREAKING CHANGES
6+
7+
* **manifests:** Resource names have been prefixed to avoid cluster conflicts
8+
- All cluster-scoped and namespace-scoped resources now use the `barman-plugin-` prefix for consistency
9+
- See the [Resource Name Migration Guide](https://cloudnative-pg.io/plugin-barman-cloud/resource-name-migration/) for detailed migration instructions
10+
311
## [0.7.0](https://github.com/cloudnative-pg/plugin-barman-cloud/compare/v0.6.0...v0.7.0) (2025-09-25)
412

513

config/rbac/leader_election_role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
app.kubernetes.io/name: plugin-barman-cloud
77
app.kubernetes.io/managed-by: kustomize
8-
name: leader-election-role
8+
name: barman-plugin-leader-election-role
99
rules:
1010
- apiGroups:
1111
- ""

config/rbac/leader_election_role_binding.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ metadata:
44
labels:
55
app.kubernetes.io/name: plugin-barman-cloud
66
app.kubernetes.io/managed-by: kustomize
7-
name: leader-election-rolebinding
7+
name: barman-plugin-leader-election-rolebinding
88
roleRef:
99
apiGroup: rbac.authorization.k8s.io
1010
kind: Role
11-
name: leader-election-role
11+
name: barman-plugin-leader-election-role
1212
subjects:
1313
- kind: ServiceAccount
1414
name: plugin-barman-cloud

config/rbac/metrics_auth_role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
33
metadata:
4-
name: metrics-auth-role
4+
name: barman-plugin-metrics-auth-role
55
rules:
66
- apiGroups:
77
- authentication.k8s.io

config/rbac/metrics_auth_role_binding.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRoleBinding
33
metadata:
4-
name: metrics-auth-rolebinding
4+
name: barman-plugin-metrics-auth-rolebinding
55
roleRef:
66
apiGroup: rbac.authorization.k8s.io
77
kind: ClusterRole
8-
name: metrics-auth-role
8+
name: barman-plugin-metrics-auth-role
99
subjects:
1010
- kind: ServiceAccount
1111
name: plugin-barman-cloud

config/rbac/metrics_reader_role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
33
metadata:
4-
name: metrics-reader
4+
name: barman-plugin-metrics-reader
55
rules:
66
- nonResourceURLs:
77
- "/metrics"

config/rbac/objectstore_editor_role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
app.kubernetes.io/name: plugin-barman-cloud
77
app.kubernetes.io/managed-by: kustomize
8-
name: objectstore-editor-role
8+
name: barman-plugin-objectstore-editor-role
99
rules:
1010
- apiGroups:
1111
- barmancloud.cnpg.io

config/rbac/objectstore_viewer_role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
app.kubernetes.io/name: plugin-barman-cloud
77
app.kubernetes.io/managed-by: kustomize
8-
name: objectstore-viewer-role
8+
name: barman-plugin-objectstore-viewer-role
99
rules:
1010
- apiGroups:
1111
- barmancloud.cnpg.io
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
---
2+
sidebar_position: 41
3+
---
4+
5+
# Resource Name Migration Guide
6+
7+
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
8+
9+
:::warning
10+
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
12+
2. **Test in a non-production environment** first if possible
13+
3. **Ensure you have proper backups** of your cluster configuration
14+
4. **Verify the resource names match** your current installation (default namespace is `cnpg-system`)
15+
16+
This migration will delete old RBAC resources and create new ones. While the operation is designed to be safe, you should review and understand the changes before proceeding. The maintainers of this project are not responsible for any issues that may arise during migration.
17+
:::
18+
19+
## Overview
20+
21+
Starting from version 0.8.0, the plugin-barman-cloud deployment manifests use more specific, prefixed resource names to avoid conflicts with other components deployed in the same Kubernetes cluster.
22+
23+
## What Changed
24+
25+
The following resources have been renamed to use proper prefixes:
26+
27+
### Cluster-scoped Resources
28+
29+
| Old Name | New Name |
30+
|----------|----------|
31+
| `metrics-auth-role` | `barman-plugin-metrics-auth-role` |
32+
| `metrics-auth-rolebinding` | `barman-plugin-metrics-auth-rolebinding` |
33+
| `metrics-reader` | `barman-plugin-metrics-reader` |
34+
| `objectstore-viewer-role` | `barman-plugin-objectstore-viewer-role` |
35+
| `objectstore-editor-role` | `barman-plugin-objectstore-editor-role` |
36+
37+
### Namespace-scoped Resources
38+
39+
| Old Name | New Name | Namespace |
40+
|----------|----------|-----------|
41+
| `leader-election-role` | `barman-plugin-leader-election-role` | `cnpg-system` |
42+
| `leader-election-rolebinding` | `barman-plugin-leader-election-rolebinding` | `cnpg-system` |
43+
44+
## Why This Change?
45+
46+
Using generic names for cluster-wide resources is discouraged as they may conflict with other components deployed in the same cluster. The new names make it clear that these resources belong to the barman-cloud plugin and help avoid naming collisions.
47+
48+
## Migration Instructions
49+
50+
The migration process is straightforward and can be completed with a few kubectl commands.
51+
52+
:::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:
54+
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+
```
63+
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+
```
71+
72+
These should reference `barmancloud.cnpg.io` API groups. If they don't, they are not barman plugin resources.
73+
:::
74+
75+
:::tip Dry Run First
76+
You can add `--dry-run=client` to any `kubectl delete` command to preview what would be deleted without actually removing anything.
77+
:::
78+
79+
### Step 1: Delete Old Cluster-scoped Resources
80+
81+
**Only proceed if you've verified these resources belong to the barman plugin (see warning above).**
82+
83+
```bash
84+
# Only delete if this belongs to barman plugin (check labels first)
85+
kubectl delete clusterrole metrics-auth-role
86+
87+
# Only delete if this belongs to barman plugin (check labels first)
88+
kubectl delete clusterrole metrics-reader
89+
90+
# Only delete if this belongs to barman plugin (check labels first)
91+
kubectl delete clusterrole objectstore-viewer-role
92+
93+
# Only delete if this belongs to barman plugin (check labels first)
94+
kubectl delete clusterrole objectstore-editor-role
95+
96+
# Only delete if this belongs to barman plugin (check labels first)
97+
kubectl delete clusterrolebinding metrics-auth-rolebinding
98+
```
99+
100+
If any resource is not found, that's okay - it means it was never created or already deleted.
101+
102+
### Step 2: Delete Old Namespace-scoped Resources
103+
104+
These are less likely to conflict, but you should still verify they're in the correct namespace. Replace `cnpg-system` with your namespace if different:
105+
106+
```bash
107+
# First, verify these exist in your namespace
108+
kubectl get role leader-election-role -n cnpg-system
109+
kubectl get rolebinding leader-election-rolebinding -n cnpg-system
110+
111+
# Then delete them
112+
kubectl delete role leader-election-role -n cnpg-system
113+
kubectl delete rolebinding leader-election-rolebinding -n cnpg-system
114+
```
115+
116+
### Step 3: Apply the New RBAC Manifest
117+
118+
Download and apply the new manifest with the updated resource names:
119+
120+
```bash
121+
kubectl apply -f https://cloudnative-pg.io/plugin-barman-cloud/migration-rbac.yaml -n cnpg-system
122+
```
123+
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:
125+
126+
```bash
127+
kubectl apply -f barman-rbac-new.yaml -n cnpg-system
128+
```
129+
130+
:::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.
132+
:::
133+
134+
## Impact
135+
136+
- **Downtime:** The migration requires a brief interruption as the old resources are deleted and new ones are created. The plugin controller may need to restart.
137+
- **Permissions:** If you have custom RBAC rules or tools that reference the old resource names, they will need to be updated.
138+
- **External Users:** If end users have been granted the `objectstore-viewer-role` or `objectstore-editor-role`, they will need to be re-granted the new role names (`barman-plugin-objectstore-viewer-role` and `barman-plugin-objectstore-editor-role`).
139+
140+
## Verification
141+
142+
After migration, verify that the new resources are created:
143+
144+
```bash
145+
# Check cluster-scoped resources
146+
kubectl get clusterrole | grep barman
147+
kubectl get clusterrolebinding | grep barman
148+
149+
# Check namespace-scoped resources
150+
kubectl get role,rolebinding -n cnpg-system | grep barman
151+
```
152+
153+
You should see the new prefixed resource names.
154+
155+
## Troubleshooting
156+
157+
### Plugin Not Starting After Migration
158+
159+
If the plugin fails to start after migration, check:
160+
161+
1. **ServiceAccount permissions:** Ensure the `plugin-barman-cloud` ServiceAccount is bound to the new roles:
162+
```bash
163+
kubectl get clusterrolebinding barman-plugin-metrics-auth-rolebinding -o yaml
164+
kubectl get rolebinding barman-plugin-leader-election-rolebinding -n cnpg-system -o yaml
165+
```
166+
167+
2. **Role references:** Verify that the rolebindings reference the correct role names:
168+
```bash
169+
kubectl describe rolebinding barman-plugin-leader-election-rolebinding -n cnpg-system
170+
kubectl describe clusterrolebinding barman-plugin-metrics-auth-rolebinding
171+
```
172+
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+
187+
## Support
188+
189+
If you encounter issues during migration, please open an issue on the [GitHub repository](https://github.com/cloudnative-pg/plugin-barman-cloud/issues).

0 commit comments

Comments
 (0)