Skip to content

Commit bf821be

Browse files
committed
provides olmv1 capabilities for common olmv0 operations. Includes the
ability to diagnose/repair common installation issues, and a least-privilege mode of defining clusterextension service accounts. Extends knowledge of current feature gates to facilitate additional capabilities (e.g. webhooks) and provide greater insight into RBAC/SA failures. Signed-off-by: grokspawn <[email protected]> Assisted-by: claude
1 parent b8989e5 commit bf821be

File tree

12 files changed

+1672
-0
lines changed

12 files changed

+1672
-0
lines changed

.claude-plugin/marketplace.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
"name": "must-gather",
6464
"source": "./plugins/must-gather",
6565
"description": "A plugin to analyze and report on must-gather data"
66+
},
67+
{
68+
"name": "olmv1",
69+
"source": "./plugins/olmv1",
70+
"description": "A plugin for managing Kubernetes extensions using OLM v1 (operator-controller)"
6671
}
6772
]
6873
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "olmv1",
3+
"description": "A plugin for managing Kubernetes extensions using OLM v1 (operator-controller)",
4+
"version": "0.1.0",
5+
"author": {
6+
"name": "openshift-eng"
7+
}
8+
}

plugins/olmv1/README.md

Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
# OLM v1 Plugin
2+
3+
Manage Kubernetes cluster extensions using Operator Lifecycle Manager v1 (operator-controller).
4+
5+
## Overview
6+
7+
OLM v1 provides a simpler, more flexible approach to managing Kubernetes extensions including Operators, Helm charts, and other cluster extensions. This plugin helps you discover, install, upgrade, and manage extensions in your cluster.
8+
9+
## Prerequisites
10+
11+
- `kubectl` or `oc` CLI configured with cluster access
12+
- OLM v1 (operator-controller) installed in the cluster
13+
- Appropriate RBAC permissions for managing ClusterExtensions and ClusterCatalogs
14+
15+
## Key Concepts
16+
17+
- **ClusterCatalog**: A catalog of available extensions
18+
- **ClusterExtension**: An installed extension in the cluster
19+
- **Channels**: Release channels for extensions (stable, candidate, etc.)
20+
- **Version Constraints**: Semver-based version management
21+
- **ServiceAccount & RBAC**: Each extension requires a ServiceAccount with sufficient permissions to install and operate
22+
23+
## Important: RBAC Requirements in OLM v1
24+
25+
**CRITICAL DIFFERENCE FROM OLM v0**: In OLM v1, YOU (the cluster admin) must provide a ServiceAccount with all necessary RBAC permissions for each extension. OLM v1 does NOT have cluster-admin privileges like OLM v0.
26+
27+
### ServiceAccount Requirements
28+
29+
Every ClusterExtension installation requires:
30+
1. A ServiceAccount in the target namespace
31+
2. RBAC permissions (ClusterRole/Role) granting the ServiceAccount rights to:
32+
- Create and manage the extension's resources (Deployments, Services, ConfigMaps, etc.)
33+
- Create Custom Resource Definitions (CRDs)
34+
- Create RBAC resources (if the extension creates its own Roles/RoleBindings)
35+
- Any additional permissions the extension needs to operate
36+
37+
### PreflightPermissions Feature Gate
38+
39+
When the `PreflightPermissions` feature gate is enabled in operator-controller:
40+
- OLM performs a **preflight check** before installation
41+
- Missing RBAC permissions are identified and reported in the ClusterExtension status conditions
42+
- Installation fails fast with clear error messages listing exactly which permissions are missing
43+
- This helps you iteratively fix RBAC issues without trial and error
44+
45+
The `/olmv1:install` command automatically creates baseline RBAC permissions and can iteratively fix missing permissions when preflight checks fail.
46+
47+
### Webhook Feature Gates
48+
49+
Many operators include admission webhooks (mutating or validating webhook configurations). OLM v1 requires a feature gate to be enabled for webhook support:
50+
51+
**WebhookProviderCertManager** (recommended):
52+
- Enables webhook support using cert-manager to provision certificates
53+
- Requires cert-manager to be installed in the cluster
54+
- Enable with:
55+
```bash
56+
kubectl patch deployment operator-controller-controller-manager -n olmv1-system --type=json \
57+
-p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-",
58+
"value": "--feature-gates=WebhookProviderCertManager=true"}]'
59+
```
60+
61+
**WebhookProviderOpenshiftServiceCA**:
62+
- Enables webhook support using OpenShift's service CA for certificate provisioning
63+
- Only available on OpenShift clusters
64+
- Enable similarly with `--feature-gates=WebhookProviderOpenshiftServiceCA=true`
65+
66+
**What happens without webhook support:**
67+
- Operators with webhooks will fail to install with error: "unsupported bundle: webhookDefinitions are not supported"
68+
- The `/olmv1:install` and `/olmv1:status` commands will detect this and suggest enabling the appropriate feature gate
69+
- If cert-manager is installed, the commands may automatically enable WebhookProviderCertManager
70+
71+
**Additional RBAC for webhooks:**
72+
When webhooks are enabled via cert-manager, your ServiceAccount also needs permissions for cert-manager resources:
73+
```yaml
74+
- apiGroups: ["cert-manager.io"]
75+
resources: ["certificates", "issuers", "certificaterequests"]
76+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
77+
```
78+
79+
## Commands
80+
81+
### Catalog Management
82+
83+
#### `/olmv1:catalog-add <catalog-name> <image-ref> [--poll-interval <duration>]`
84+
Add a new catalog source to the cluster.
85+
86+
**Example:**
87+
```bash
88+
/olmv1:catalog-add operatorhubio quay.io/operatorhubio/catalog:latest
89+
/olmv1:catalog-add my-catalog registry.example.com/catalog:v1 --poll-interval 1h
90+
```
91+
92+
#### `/olmv1:catalog-list`
93+
List all available catalogs and their status.
94+
95+
**Example:**
96+
```bash
97+
/olmv1:catalog-list
98+
```
99+
100+
### Extension Discovery
101+
102+
#### `/olmv1:search <keyword> [--catalog <catalog-name>]`
103+
Search for available extensions across catalogs.
104+
105+
**Example:**
106+
```bash
107+
/olmv1:search cert-manager
108+
/olmv1:search prometheus --catalog operatorhubio
109+
```
110+
111+
### Extension Installation
112+
113+
#### `/olmv1:install <extension-name> [--version <version>] [--channel <channel>] [--catalog <catalog-name>] [--namespace <namespace>]`
114+
Install an extension with optional version or channel constraints.
115+
116+
**Parameters:**
117+
- `extension-name`: Name of the extension to install (required)
118+
- `--version`: Specific version or version range (e.g., "1.14.5", ">=1.14.0 <1.15.0")
119+
- `--channel`: Channel to track (e.g., "stable", "candidate")
120+
- `--catalog`: Catalog source to use
121+
- `--namespace`: Target namespace for namespaced extensions
122+
123+
**Examples:**
124+
```bash
125+
# Install latest from stable channel
126+
/olmv1:install cert-manager --channel stable
127+
128+
# Install specific version
129+
/olmv1:install argocd-operator --version 0.11.0
130+
131+
# Install with version range
132+
/olmv1:install prometheus-operator --version ">=0.68.0 <0.69.0"
133+
134+
# Install from specific catalog
135+
/olmv1:install my-extension --catalog my-catalog
136+
```
137+
138+
### Extension Management
139+
140+
#### `/olmv1:list [--all-namespaces]`
141+
List all installed extensions with their status.
142+
143+
**Example:**
144+
```bash
145+
/olmv1:list
146+
/olmv1:list --all-namespaces
147+
```
148+
149+
#### `/olmv1:status <extension-name>`
150+
Get detailed status and health information for an installed extension.
151+
152+
**Shows:**
153+
- Installation status and conditions
154+
- Resolved version and channel
155+
- ServiceAccount and RBAC configuration
156+
- Associated resources (CRDs, deployments, services)
157+
- Recent events and issues
158+
- **RBAC/preflight permission errors** (if present)
159+
160+
**Example:**
161+
```bash
162+
/olmv1:status cert-manager
163+
```
164+
165+
#### `/olmv1:fix-rbac <extension-name>`
166+
Analyze and fix RBAC permission issues for a ClusterExtension that failed preflight checks.
167+
168+
**What it does:**
169+
- Detects pre-authorization failures in the ClusterExtension status
170+
- Parses the missing RBAC permissions from error messages
171+
- Identifies the current ServiceAccount and ClusterRole
172+
- Offers to automatically update the ClusterRole with missing permissions
173+
- Or displays the required RBAC YAML for manual application
174+
175+
**When to use:**
176+
- Extension installation is stuck in "Progressing" state
177+
- Status shows "pre-authorization failed" errors
178+
- You see RBAC-related error messages
179+
180+
**Example:**
181+
```bash
182+
/olmv1:fix-rbac postgres-operator
183+
```
184+
185+
**Note:** Requires the `PreflightPermissions` feature gate to be enabled in operator-controller for detailed permission analysis.
186+
187+
### Extension Upgrades
188+
189+
#### `/olmv1:upgrade <extension-name> [--version <version>] [--channel <channel>]`
190+
Upgrade an extension using different strategies.
191+
192+
**Strategies:**
193+
- Channel-based: Track a specific channel for automatic updates
194+
- Version pinning: Upgrade to a specific version
195+
- Version range: Allow upgrades within a version range
196+
- Z-stream: Stay within the same minor version
197+
198+
**Examples:**
199+
```bash
200+
# Upgrade to latest in stable channel
201+
/olmv1:upgrade cert-manager --channel stable
202+
203+
# Upgrade to specific version
204+
/olmv1:upgrade argocd-operator --version 0.12.0
205+
206+
# Upgrade within version range (z-stream)
207+
/olmv1:upgrade prometheus-operator --version "~0.68.0"
208+
```
209+
210+
### Extension Removal
211+
212+
#### `/olmv1:uninstall <extension-name>`
213+
Safely uninstall an extension from the cluster.
214+
215+
**Example:**
216+
```bash
217+
/olmv1:uninstall cert-manager
218+
```
219+
220+
## Typical Workflows
221+
222+
### Installing a New Extension
223+
```bash
224+
# 1. Search for the extension
225+
/olmv1:search postgres-operator
226+
227+
# 2. Install with desired version/channel
228+
# This automatically creates:
229+
# - Namespace
230+
# - ServiceAccount
231+
# - ClusterRole with baseline permissions
232+
# - ClusterRoleBinding
233+
# - ClusterExtension
234+
/olmv1:install postgres-operator --channel stable --namespace postgres-operator
235+
236+
# 3. If installation fails due to RBAC issues:
237+
/olmv1:status postgres-operator
238+
# Will show missing permissions
239+
240+
# 4. Fix RBAC automatically
241+
/olmv1:fix-rbac postgres-operator
242+
243+
# 5. Verify installation succeeded
244+
/olmv1:status postgres-operator
245+
246+
# 6. List all installed extensions
247+
/olmv1:list
248+
```
249+
250+
### Managing Upgrades
251+
```bash
252+
# Check current status
253+
/olmv1:status my-extension
254+
255+
# Upgrade to latest in channel
256+
/olmv1:upgrade my-extension --channel stable
257+
258+
# Or pin to specific version
259+
/olmv1:upgrade my-extension --version 2.0.0
260+
261+
# Verify upgrade
262+
/olmv1:status my-extension
263+
```
264+
265+
### Troubleshooting
266+
```bash
267+
# Check extension status and conditions (including RBAC issues)
268+
/olmv1:status <extension-name>
269+
270+
# Fix RBAC permission issues
271+
/olmv1:fix-rbac <extension-name>
272+
273+
# Check catalog availability
274+
/olmv1:catalog-list
275+
276+
# View all extensions and their health
277+
/olmv1:list
278+
```
279+
280+
## Differences from OLM v0
281+
282+
- **Simpler API**: Uses ClusterExtension and ClusterCatalog instead of Subscription/CSV/InstallPlan
283+
- **Flexible versioning**: Supports semver ranges and version constraints
284+
- **Broader scope**: Manages any Kubernetes extension, not just Operators
285+
- **No automatic upgrades**: Explicit upgrade commands for better control
286+
- **GitOps friendly**: Declarative extension management
287+
- **⚠️ USER-MANAGED RBAC**: You must provide ServiceAccounts with proper RBAC permissions (OLM v0 had cluster-admin but best practices are to avoid this whenever possible)
288+
289+
## Troubleshooting
290+
291+
Common issues and solutions:
292+
293+
1. **Extension stuck in progressing state with RBAC errors**:
294+
- Run `/olmv1:status <extension-name>` to see missing permissions
295+
- Use `/olmv1:fix-rbac <extension-name>` to automatically fix RBAC issues
296+
- Requires `PreflightPermissions` feature gate enabled for detailed error messages
297+
298+
2. **Pre-authorization failed errors**:
299+
- These indicate the ServiceAccount lacks required RBAC permissions
300+
- Error messages show exactly which permissions are missing in format:
301+
```
302+
Namespace:"" APIGroups:[apps] Resources:[deployments] Verbs:[create,update]
303+
```
304+
- Use `/olmv1:fix-rbac` to parse and apply missing permissions automatically
305+
306+
3. **Catalog not available**:
307+
- Verify catalog image and network connectivity
308+
- Run `/olmv1:catalog-list` to check catalog status
309+
310+
4. **Version conflicts**:
311+
- Use `/olmv1:status` to see resolved dependencies
312+
- Check for conflicting version constraints
313+
314+
5. **ServiceAccount doesn't exist**:
315+
- The `/olmv1:install` command creates ServiceAccounts automatically
316+
- Ensure the namespace exists and you have permissions to create ServiceAccounts
317+
318+
6. **PreflightPermissions feature gate not enabled**:
319+
- Without this gate, RBAC errors won't be caught early
320+
- Installation will fail with less helpful error messages
321+
- Consider enabling it in operator-controller for better RBAC feedback
322+
323+
## Resources
324+
325+
- [OLM v1 Documentation](https://operator-framework.github.io/operator-controller/)
326+
- [OLM v1 GitHub Repository](https://github.com/operator-framework/operator-controller)
327+
- [Migration from OLM v0](https://operator-framework.github.io/operator-controller/concepts/olmv0-to-olmv1/)
328+
- [RBAC Permissions Checking Guide](https://github.com/operator-framework/operator-controller/blob/main/docs/draft/howto/rbac-permissions-checking.md)

0 commit comments

Comments
 (0)