Skip to content

Commit 9f90309

Browse files
Merge pull request #72 from ngopalak-redhat/ngopalak/cluster_options
Add claude interactive cluster creation, readme and destroy command
2 parents f3d87dc + dead7c0 commit 9f90309

File tree

3 files changed

+599
-17
lines changed

3 files changed

+599
-17
lines changed

plugins/openshift/README.md

Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,22 @@ This command automates the complex process of rebasing OpenShift forks following
1616

1717
### `/openshift:bump-deps`
1818

19-
Automates the process of bumping dependencies in OpenShift organization projects. It analyzes the dependency, determines
20-
the appropriate version to bump to, updates the necessary files (go.mod, go.sum, package.json, etc.), runs tests,
19+
Automates the process of bumping dependencies in OpenShift organization projects. It analyzes the dependency, determines
20+
the appropriate version to bump to, updates the necessary files (go.mod, go.sum, package.json, etc.), runs tests,
2121
and optionally creates Jira tickets and pull requests.
2222

23+
### `/openshift:create-cluster`
24+
25+
Extract OpenShift installer from release image and create an OCP cluster.
26+
27+
This command automates the process of extracting the installer from a release image and creating a new OpenShift cluster on various platforms (AWS, Azure, GCP, vSphere, OpenStack).
28+
29+
### `/openshift:destroy-cluster`
30+
31+
Destroy an OpenShift cluster created by the create-cluster command.
32+
33+
This command safely destroys a cluster and cleans up all cloud resources. Includes safety confirmations and optional backup of cluster information.
34+
2335
See the [commands/](commands/) directory for full documentation of each command.
2436

2537
## Installation
@@ -122,6 +134,119 @@ Automates dependency updates in OpenShift projects with comprehensive analysis,
122134

123135
See [commands/bump-deps.md](commands/bump-deps.md) for full documentation.
124136

137+
### Cluster Management
138+
139+
#### `/openshift:create-cluster` - Create OCP Clusters
140+
141+
Extract the OpenShift installer from a release image and create a new OpenShift Container Platform cluster. This command automates installer extraction and cluster creation for development and testing purposes.
142+
143+
**⚠️ Important**: This is a last-resort tool. For most workflows, use **Cluster Bot**, **Gangway**, or **Multi-PR Testing in CI** instead. Only use this when you need full control over cluster configuration or are testing installer changes.
144+
145+
**Basic Usage:**
146+
```bash
147+
# Interactive mode (prompts for all options)
148+
/openshift:create-cluster
149+
150+
# With release image and platform
151+
/openshift:create-cluster quay.io/openshift-release-dev/ocp-release:4.21.0-ec.2-x86_64 aws
152+
153+
# With CI build
154+
/openshift:create-cluster registry.ci.openshift.org/ocp/release:4.21.0-0.ci-2025-10-27-031915 gcp
155+
```
156+
157+
**Prerequisites:**
158+
- OpenShift CLI (`oc`) installed
159+
- Cloud provider credentials configured (AWS, Azure, GCP, etc.)
160+
- Pull secret from [Red Hat Console](https://console.redhat.com/openshift/install/pull-secret)
161+
- Domain/DNS configuration (e.g., Route53 hosted zone for AWS)
162+
163+
**Supported Platforms:**
164+
- AWS (Amazon Web Services)
165+
- Azure (Microsoft Azure)
166+
- GCP (Google Cloud Platform)
167+
- vSphere (VMware vSphere)
168+
- OpenStack
169+
- none (Bare metal / platform-agnostic)
170+
171+
**Key Features:**
172+
- Automatic installer extraction from release images
173+
- Version-specific installer caching
174+
- Interactive configuration generation
175+
- Post-installation verification
176+
- Cluster credentials and access information
177+
178+
**Arguments:**
179+
- `[release-image]` (optional): OpenShift release image (prompted if not provided)
180+
- `[platform]` (optional): Target platform (prompted if not provided)
181+
182+
**Examples:**
183+
184+
1. Create cluster with production release on AWS:
185+
```bash
186+
/openshift:create-cluster quay.io/openshift-release-dev/ocp-release:4.21.0-ec.2-x86_64 aws
187+
```
188+
189+
2. Create cluster with CI build interactively:
190+
```bash
191+
/openshift:create-cluster registry.ci.openshift.org/ocp/release:4.21.0-0.ci-2025-10-27-031915
192+
```
193+
194+
3. Full interactive mode:
195+
```bash
196+
/openshift:create-cluster
197+
```
198+
199+
See [commands/create-cluster.md](commands/create-cluster.md) for full documentation.
200+
201+
#### `/openshift:destroy-cluster` - Destroy OCP Clusters
202+
203+
Safely destroy an OpenShift Container Platform cluster that was created using `/openshift:create-cluster`. This command handles cleanup of all cloud resources with built-in safety confirmations.
204+
205+
**⚠️ WARNING**: This operation is **irreversible** and permanently deletes all cluster resources and data.
206+
207+
**Basic Usage:**
208+
```bash
209+
# Interactive mode (searches for installation directories)
210+
/openshift:destroy-cluster
211+
212+
# With specific installation directory
213+
/openshift:destroy-cluster ./my-cluster-install-20251028-120000
214+
215+
# With full path
216+
/openshift:destroy-cluster /path/to/cluster-install-dir
217+
```
218+
219+
**Safety Features:**
220+
- Requires explicit "yes" confirmation before destruction
221+
- Displays cluster information before proceeding
222+
- Optional backup of cluster credentials and metadata
223+
- Validates installation directory and metadata
224+
- Provides manual cleanup instructions if automated cleanup fails
225+
226+
**What Gets Deleted:**
227+
- All cluster VMs and compute resources
228+
- Load balancers and networking resources
229+
- Storage volumes and persistent data
230+
- DNS records (if managed by installer)
231+
- All cluster configuration
232+
233+
**Arguments:**
234+
- `[install-dir]` (optional): Path to cluster installation directory (prompted if not provided)
235+
236+
**Examples:**
237+
238+
1. Destroy cluster interactively:
239+
```bash
240+
/openshift:destroy-cluster
241+
```
242+
243+
2. Destroy specific cluster:
244+
```bash
245+
/openshift:destroy-cluster ./test-cluster-install-20251028-120000
246+
```
247+
248+
See [commands/destroy-cluster.md](commands/destroy-cluster.md) for full documentation.
249+
125250
## Development
126251

127252
### Adding New Commands

plugins/openshift/commands/create-cluster.md

Lines changed: 112 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Extract OpenShift installer from release image and create an OCP cluster
3-
argument-hint: [release-image] [platform] [options]
3+
argument-hint: "[release-image] [platform] [options]"
44
---
55

66
## Name
@@ -106,8 +106,8 @@ If arguments are not provided, the command will interactively prompt for:
106106
- **base-domain** (required): Base domain for the cluster
107107
- Example: `example.com` → Cluster API will be `api.{cluster-name}.{base-domain}`
108108

109-
- **pull-secret** (optional): Path to pull secret file
110-
- Default: `~/pull-secret.txt`
109+
- **pull-secret** (required): Path to pull secret file
110+
- User will be prompted to provide the path
111111

112112
- **installer-dir** (optional): Directory to store/find installer binaries
113113
- Default: `~/.openshift-installers`
@@ -219,22 +219,118 @@ mkdir -p "$INSTALL_DIR"
219219
cd "$INSTALL_DIR"
220220
```
221221

222-
### 5. Generate install-config.yaml
222+
### 5. Collect Required Information and Generate install-config.yaml
223+
224+
**IMPORTANT**: Do NOT run the installer interactively. Instead, collect all required information from the user and generate the install-config.yaml programmatically.
225+
226+
**Step 5.1: Collect Information**
227+
228+
Prompt the user for the following information (if not already provided as arguments):
229+
230+
1. **SSH Public Key**:
231+
- Check for existing SSH keys: `ls -la ~/.ssh/*.pub`
232+
- Ask user to select from available keys or specify path
233+
- Default: `~/.ssh/id_rsa.pub`
234+
235+
2. **Platform** (if not provided as argument):
236+
- Ask user to select: aws, azure, gcp, vsphere, openstack, none
237+
238+
3. **Platform-specific details**:
239+
- For AWS:
240+
- Region (e.g., us-east-1, us-west-2)
241+
- For Azure:
242+
- Region (e.g., centralus, eastus)
243+
- Cloud name (e.g., AzurePublicCloud)
244+
- For GCP:
245+
- Project ID
246+
- Region (e.g., us-central1)
247+
- For other platforms: collect required platform-specific info
248+
249+
4. **Base Domain**:
250+
- Ask for base domain (e.g., example.com, devcluster.openshift.com)
251+
- Validate that domain is configured (e.g., Route53 hosted zone for AWS)
252+
253+
5. **Cluster Name**:
254+
- Ask for cluster name or use default: `ocp-cluster`
255+
- Validate DNS compatibility (lowercase, hyphens only)
256+
257+
6. **Pull Secret**:
258+
- **IMPORTANT**: Always ask user to provide the path to their pull secret file
259+
- Do NOT use default paths like `~/pull-secret.txt` or `~/Downloads/pull-secret.txt`
260+
- Prompt: "Please provide the path to your pull secret file (download from https://console.redhat.com/openshift/install/pull-secret):"
261+
- Read contents of pull secret file from the provided path
262+
263+
**Step 5.2: Generate install-config.yaml**
264+
265+
Create the install-config.yaml file programmatically based on collected information:
223266

224-
Run the installer's interactive config generation:
225267
```bash
226-
"$INSTALLER_PATH" create install-config --dir=.
268+
# Read SSH public key
269+
SSH_KEY=$(cat "$SSH_KEY_PATH")
270+
271+
# Read pull secret
272+
PULL_SECRET=$(cat "$PULL_SECRET_PATH")
273+
274+
# Generate install-config.yaml
275+
cat > install-config.yaml <<EOF
276+
apiVersion: v1
277+
baseDomain: ${BASE_DOMAIN}
278+
metadata:
279+
name: ${CLUSTER_NAME}
280+
compute:
281+
- name: worker
282+
replicas: 3
283+
controlPlane:
284+
name: master
285+
replicas: 3
286+
networking:
287+
networkType: OVNKubernetes
288+
clusterNetwork:
289+
- cidr: 10.128.0.0/14
290+
hostPrefix: 23
291+
serviceNetwork:
292+
- 172.30.0.0/16
293+
platform:
294+
${PLATFORM}:
295+
region: ${REGION}
296+
pullSecret: '${PULL_SECRET}'
297+
sshKey: '${SSH_KEY}'
298+
EOF
227299
```
228300

229-
This will interactively prompt for:
230-
- SSH public key
231-
- Platform selection
232-
- Platform-specific details (region, instance types, etc.)
233-
- Base domain
234-
- Cluster name
235-
- Pull secret
301+
**Platform-specific configurations**:
302+
303+
For **AWS**:
304+
```yaml
305+
platform:
306+
aws:
307+
region: us-east-1
308+
```
309+
310+
For **Azure**:
311+
```yaml
312+
platform:
313+
azure:
314+
region: centralus
315+
baseDomainResourceGroupName: ${RESOURCE_GROUP_NAME}
316+
cloudName: AzurePublicCloud
317+
```
318+
319+
For **GCP**:
320+
```yaml
321+
platform:
322+
gcp:
323+
projectID: ${PROJECT_ID}
324+
region: us-central1
325+
```
326+
327+
For **None/Baremetal**:
328+
```yaml
329+
platform:
330+
none: {}
331+
```
236332
237-
**IMPORTANT**: Always backup install-config.yaml before proceeding:
333+
**IMPORTANT**: Always backup install-config.yaml after creation:
238334
```bash
239335
cp install-config.yaml install-config.yaml.backup
240336
```
@@ -336,7 +432,8 @@ cd $INSTALL_DIR
336432

337433
1. **Pull secret not found**:
338434
- Download from https://console.redhat.com/openshift/install/pull-secret
339-
- Save to `~/pull-secret.txt`
435+
- Save to a secure location of your choice
436+
- Provide the path when prompted during cluster creation
340437

341438
2. **Insufficient cloud quotas**:
342439
- Check cloud provider quota limits

0 commit comments

Comments
 (0)