|
| 1 | +# OpenShift Toolset |
| 2 | + |
| 3 | +This toolset provides OpenShift-specific prompts for cluster management and troubleshooting. |
| 4 | + |
| 5 | +## Prompts |
| 6 | + |
| 7 | +### plan_mustgather |
| 8 | + |
| 9 | +Plan for collecting a must-gather archive from an OpenShift cluster. Must-gather is a tool for collecting cluster data related to debugging and troubleshooting like logs, Kubernetes resources, and more. |
| 10 | + |
| 11 | +This prompt generates YAML manifests for the must-gather resources that can be applied to the cluster. |
| 12 | + |
| 13 | +**Arguments:** |
| 14 | +- `node_name` (optional) - Specific node name to run must-gather pod on |
| 15 | +- `node_selector` (optional) - Node selector in `key=value,key2=value2` format to filter nodes for the pod |
| 16 | +- `source_dir` (optional) - Custom gather directory inside pod (default: `/must-gather`) |
| 17 | +- `namespace` (optional) - Privileged namespace to use for must-gather (auto-generated if not specified) |
| 18 | +- `gather_command` (optional) - Custom gather command e.g. `/usr/bin/gather_audit_logs` (default: `/usr/bin/gather`) |
| 19 | +- `timeout` (optional) - Timeout duration for gather command (e.g., `30m`, `1h`) |
| 20 | +- `since` (optional) - Only gather data newer than this duration (e.g., `5s`, `2m5s`, or `3h6m10s`), defaults to all data |
| 21 | +- `host_network` (optional) - Use host network for must-gather pod (`true`/`false`) |
| 22 | +- `keep_resources` (optional) - Keep pod resources after collection (`true`/`false`, default: `false`) |
| 23 | +- `all_component_images` (optional) - Include must-gather images from all installed operators (`true`/`false`) |
| 24 | +- `images` (optional) - Comma-separated list of custom must-gather container images |
| 25 | + |
| 26 | +**Example:** |
| 27 | +``` |
| 28 | +# Basic must-gather collection |
| 29 | +{} |
| 30 | +
|
| 31 | +# Collect with custom timeout and since |
| 32 | +{ |
| 33 | + "timeout": "30m", |
| 34 | + "since": "1h" |
| 35 | +} |
| 36 | +
|
| 37 | +# Collect from all component images |
| 38 | +{ |
| 39 | + "all_component_images": "true" |
| 40 | +} |
| 41 | +
|
| 42 | +# Collect from specific operator image |
| 43 | +{ |
| 44 | + "images": "registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:..." |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +## Enable the OpenShift Toolset |
| 49 | + |
| 50 | +### Option 1: Command Line |
| 51 | + |
| 52 | +```bash |
| 53 | +kubernetes-mcp-server --toolsets core,config,helm,openshift |
| 54 | +``` |
| 55 | + |
| 56 | +### Option 2: Configuration File |
| 57 | + |
| 58 | +```toml |
| 59 | +toolsets = ["core", "config", "helm", "openshift"] |
| 60 | +``` |
| 61 | + |
| 62 | +### Option 3: MCP Client Configuration |
| 63 | + |
| 64 | +```json |
| 65 | +{ |
| 66 | + "mcpServers": { |
| 67 | + "kubernetes": { |
| 68 | + "command": "npx", |
| 69 | + "args": ["-y", "kubernetes-mcp-server@latest", "--toolsets", "core,config,helm,openshift"] |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +## Prerequisites |
| 76 | + |
| 77 | +The OpenShift toolset requires: |
| 78 | + |
| 79 | +1. **OpenShift cluster** - These prompts are designed for OpenShift and automatically detect the cluster type |
| 80 | +2. **Proper RBAC** - The user/service account must have permissions to: |
| 81 | + - Create namespaces |
| 82 | + - Create service accounts |
| 83 | + - Create cluster role bindings |
| 84 | + - Create pods with privileged access |
| 85 | + - List ClusterOperators and ClusterServiceVersions (for `all_component_images`) |
| 86 | + |
| 87 | +## How It Works |
| 88 | + |
| 89 | +### Must-Gather Plan Generation |
| 90 | + |
| 91 | +The `plan_mustgather` prompt generates YAML manifests for collecting diagnostic data from an OpenShift cluster: |
| 92 | + |
| 93 | +1. **Namespace** - A temporary namespace (e.g., `openshift-must-gather-xyz`) is created unless an existing namespace is specified |
| 94 | +2. **ServiceAccount** - A service account with cluster-admin permissions is created for the must-gather pod |
| 95 | +3. **ClusterRoleBinding** - Binds the service account to the cluster-admin role |
| 96 | +4. **Pod** - Runs the must-gather container(s) with the specified configuration |
| 97 | + |
| 98 | +### Component Image Discovery |
| 99 | + |
| 100 | +When `all_component_images` is enabled, the prompt discovers must-gather images from: |
| 101 | +- **ClusterOperators** - Looks for the `operators.openshift.io/must-gather-image` annotation |
| 102 | +- **ClusterServiceVersions** - Checks OLM-installed operators for the same annotation |
| 103 | + |
| 104 | +### Multiple Images Support |
| 105 | + |
| 106 | +Up to 8 gather images can be run concurrently. Each image runs in a separate container within the same pod, sharing the output volume. |
| 107 | + |
| 108 | +## Common Use Cases |
| 109 | + |
| 110 | +### Basic Cluster Diagnostics |
| 111 | + |
| 112 | +Collect general cluster diagnostics: |
| 113 | +```json |
| 114 | +{} |
| 115 | +``` |
| 116 | + |
| 117 | +### Audit Logs Collection |
| 118 | + |
| 119 | +Collect audit logs with a custom gather command: |
| 120 | +```json |
| 121 | +{ |
| 122 | + "gather_command": "/usr/bin/gather_audit_logs", |
| 123 | + "timeout": "2h" |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +### Recent Logs Only |
| 128 | + |
| 129 | +Collect logs from the last 30 minutes: |
| 130 | +```json |
| 131 | +{ |
| 132 | + "since": "30m" |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +### Specific Operator Diagnostics |
| 137 | + |
| 138 | +Collect diagnostics for a specific operator: |
| 139 | +```json |
| 140 | +{ |
| 141 | + "images": "registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:..." |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +### Host Network Access |
| 146 | + |
| 147 | +For gather scripts that need host-level network access: |
| 148 | +```json |
| 149 | +{ |
| 150 | + "host_network": "true" |
| 151 | +} |
| 152 | +``` |
| 153 | + |
| 154 | +### All Component Diagnostics |
| 155 | + |
| 156 | +Collect diagnostics from all operators with must-gather images: |
| 157 | +```json |
| 158 | +{ |
| 159 | + "all_component_images": "true", |
| 160 | + "timeout": "1h" |
| 161 | +} |
| 162 | +``` |
| 163 | + |
| 164 | +## Troubleshooting |
| 165 | + |
| 166 | +### Permission Errors |
| 167 | + |
| 168 | +If you see permission warnings, ensure your user has the required RBAC permissions: |
| 169 | +```bash |
| 170 | +oc auth can-i create namespaces |
| 171 | +oc auth can-i create clusterrolebindings |
| 172 | +oc auth can-i create pods --as=system:serviceaccount:openshift-must-gather-xxx:must-gather-collector |
| 173 | +``` |
| 174 | + |
| 175 | +### Pod Not Starting |
| 176 | + |
| 177 | +Check if the node has enough resources and can pull the must-gather image: |
| 178 | +```bash |
| 179 | +oc get pods -n openshift-must-gather-xxx |
| 180 | +oc describe pod <pod-name> -n openshift-must-gather-xxx |
| 181 | +``` |
| 182 | + |
| 183 | +### Timeout Issues |
| 184 | + |
| 185 | +For large clusters or audit log collection, increase the timeout: |
| 186 | +```json |
| 187 | +{ |
| 188 | + "timeout": "2h" |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +### Image Pull Errors |
| 193 | + |
| 194 | +Ensure the must-gather image is accessible: |
| 195 | +```bash |
| 196 | +oc get secret -n openshift-config pull-secret |
| 197 | +``` |
| 198 | + |
| 199 | +## Security Considerations |
| 200 | + |
| 201 | +### Privileged Access |
| 202 | + |
| 203 | +The must-gather pods run with: |
| 204 | +- `cluster-admin` ClusterRoleBinding |
| 205 | +- `system-cluster-critical` priority class |
| 206 | +- Tolerations for all taints |
| 207 | +- Optional host network access |
| 208 | + |
| 209 | +### Temporary Resources |
| 210 | + |
| 211 | +By default, all created resources (namespace, service account, cluster role binding) should be cleaned up after the must-gather collection is complete. Use `"keep_resources": "true"` to retain them for debugging. |
| 212 | + |
| 213 | +### Image Sources |
| 214 | + |
| 215 | +The prompt uses these default images: |
| 216 | +- **Must-gather**: `registry.redhat.io/openshift4/ose-must-gather:latest` |
| 217 | +- **Wait container**: `registry.redhat.io/ubi9/ubi-minimal` |
| 218 | + |
| 219 | +Custom images should be from trusted sources. |
0 commit comments