Skip to content

Commit c84d6f4

Browse files
zmotsoSergK
authored andcommitted
chore: Update KubeRocketAI (#44)
1 parent c365aa1 commit c84d6f4

File tree

6 files changed

+94
-45
lines changed

6 files changed

+94
-45
lines changed

.cursor/rules/krci-ai/go-dev.mdc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ agent:
2121

2222
activation_prompt:
2323
- Greet the user with your name and role, inform of available commands, then HALT to await instruction
24-
- Offer to help with development tasks but wait for explicit user confirmation
24+
- Offer to help with tasks but wait for explicit user confirmation
25+
- Always show tasks as numbered options list
2526
- IMPORTANT!!! ALWAYS execute instructions from the customization field below
2627
- Only execute tasks when user explicitly requests them
27-
- "CRITICAL: When user selects a command, validate ONLY that command's required assets exist. If missing: HALT, report exact file, wait for user action."
28-
- "NEVER validate unused commands or proceed with broken references"
29-
- When loading any asset, use path resolution {project_root}/.krci-ai/{agents,tasks,data,templates}/*.md
28+
- NEVER validate unused commands or proceed with broken references
29+
- CRITICAL!!! Before running a task, resolve and load all paths in the task's YAML frontmatter `dependencies` under {project_root}/.krci-ai/{agents,tasks,data,templates}/**/*.md. If any file is missing, report exact path(s) and HALT until the user resolves or explicitly authorizes continuation.
3030

3131
principles:
3232
- "SCOPE: Go code implementation + Go code reviews. Redirect requirements→PM/PO, architecture→architect, other languages→dev."
33+
- "CRITICAL OUTPUT FORMATTING: When generating documents from templates, you will encounter XML-style tags like `<instructions>` or `<key_risks>`. These tags are internal metadata for your guidance ONLY and MUST NEVER be included in the final Markdown output presented to the user. Your final output must be clean, human-readable Markdown containing only headings, paragraphs, lists, and other standard elements."
3334
- "Write clean, readable Go code following established patterns"
3435
- "Test thoroughly with comprehensive coverage"
3536
- "Document clearly for maintainability"

.krci-ai/agents/go-dev.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ agent:
1010

1111
activation_prompt:
1212
- Greet the user with your name and role, inform of available commands, then HALT to await instruction
13-
- Offer to help with development tasks but wait for explicit user confirmation
13+
- Offer to help with tasks but wait for explicit user confirmation
14+
- Always show tasks as numbered options list
1415
- IMPORTANT!!! ALWAYS execute instructions from the customization field below
1516
- Only execute tasks when user explicitly requests them
16-
- "CRITICAL: When user selects a command, validate ONLY that command's required assets exist. If missing: HALT, report exact file, wait for user action."
17-
- "NEVER validate unused commands or proceed with broken references"
18-
- When loading any asset, use path resolution {project_root}/.krci-ai/{agents,tasks,data,templates}/*.md
17+
- NEVER validate unused commands or proceed with broken references
18+
- CRITICAL!!! Before running a task, resolve and load all paths in the task's YAML frontmatter `dependencies` under {project_root}/.krci-ai/{agents,tasks,data,templates}/**/*.md. If any file is missing, report exact path(s) and HALT until the user resolves or explicitly authorizes continuation.
1919

2020
principles:
2121
- "SCOPE: Go code implementation + Go code reviews. Redirect requirements→PM/PO, architecture→architect, other languages→dev."
22+
- "CRITICAL OUTPUT FORMATTING: When generating documents from templates, you will encounter XML-style tags like `<instructions>` or `<key_risks>`. These tags are internal metadata for your guidance ONLY and MUST NEVER be included in the final Markdown output presented to the user. Your final output must be clean, human-readable Markdown containing only headings, paragraphs, lists, and other standard elements."
2223
- "Write clean, readable Go code following established patterns"
2324
- "Test thoroughly with comprehensive coverage"
2425
- "Document clearly for maintainability"

.krci-ai/data/go-coding-standards.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Follow idiomatic Go practices and community standards when writing Go code. Thes
44

55
## General Instructions
66

7+
<general_guidelines>
78
- Write simple, clear, and idiomatic Go code
89
- Favor clarity and simplicity over cleverness
910
- Follow the principle of least surprise
@@ -12,6 +13,7 @@ Follow idiomatic Go practices and community standards when writing Go code. Thes
1213
- Make the zero value useful
1314
- Document exported types, functions, methods, and packages
1415
- Use Go modules for dependency management
16+
</general_guidelines>
1517

1618
## Naming Conventions
1719

.krci-ai/data/operator-best-practices.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Considerations for Operator developers:
1010

1111
- If there is significant orchestration and sequencing involved, an Operator should be written that represents the entire stack, in turn delegating to other Operators for orchestrating their part of it.
1212

13-
- Operators should own a CRD and only one Operator should control a CRD on a cluster. Two Operators managing the same CRD is not a recommended best practice. An API that exists with multiple implementations is a typical example of a no-op Operator. The no-op Operator doesn't have any deployment or reconciliation loop to define the shared API and other Operators depend on this Operator to provide one implementation of the API, e.g. similar to PVCs or Ingress.
13+
- Operators should own a CRD and only one Operator should control a CRD on a cluster. Two Operators managing the same CRD is not a recommended best practice. An API that exists with multiple implementations is a typical example of a no-op Operator. The no-op Operator doesn't have any deployment or reconciliation loop to define the shared API and other Operators depend on this Operator to provide one implementation of the API, e.g. similar to PVCs or Ingress.
1414

1515
- Inside an Operator, multiple controllers should be used if multiple CRDs are managed. This helps in separation of concerns and code readability. Note that this doesn't necessarily mean that we need to have one container image per controller, but rather one reconciliation loop (which could be running as part of the same Operator binary) per CRD.
1616

@@ -50,6 +50,7 @@ Considerations for Operator developers:
5050

5151
## Running On-Cluster
5252

53+
<cluster_considerations>
5354
Considerations for on-cluster behavior
5455

5556
- Like all containers on Kubernetes, Operators need not run as root unless absolutely necessary. Operators should come with their own ServiceAccount and not rely on the `default`.
@@ -62,11 +63,11 @@ Considerations for on-cluster behavior
6263

6364
- Operators need to support updating managed applications (Operands) that were set up by an older version of the Operator. There are multiple models for this:
6465

65-
| Model | Description |
66+
| Model | Description |
6667
| ------ | ----- |
67-
| **Operator fan-out** | where the Operator allows the user to specify the version in the custom resource |
68-
| **single version** | where the Operator is tied to the version of the operand. |
69-
| **hybrid approach** | where the Operator is tied to a range of versions, and the user can select some level of the version. |
68+
| Operator fan-out | where the Operator allows the user to specify the version in the custom resource |
69+
| single version | where the Operator is tied to the version of the operand. |
70+
| hybrid approach | where the Operator is tied to a range of versions, and the user can select some level of the version. |
7071

7172
- An Operator should not deploy another Operator - an additional component on cluster should take care of this (OLM).
7273

@@ -77,8 +78,9 @@ Considerations for on-cluster behavior
7778
- The Operator itself should be really modest in its requirements - it should always be able to deploy by deploying its controllers, no user input should be required to start up the Operator.
7879

7980
- If user input is required to change the configuration of the Operator itself, a Configuration CRD should be used. Init-containers as part of the Operator deployments can be used to create a default instance of those CRs and then the Operator manages their lifecycle.
81+
</cluster_considerations>
8082

81-
### Summary:
83+
### Summary
8284

8385
On the cluster, an Operator...
8486

@@ -92,4 +94,4 @@ On the cluster, an Operator...
9294
- Uses CRD conversion (webhooks) if API/CRDs change
9395
- Uses OpenAPI validation / Admission Webhooks to reject invalid CRs
9496
- Should always be able to deploy and come up without user input
95-
- Offers (pre)configuration via a `“Configuration CR”` instantiated by InitContainers
97+
- Offers (pre)configuration via a `“Configuration CR”` instantiated by InitContainers

.krci-ai/tasks/go-dev-implement-new-cr.md

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
1+
---
2+
dependencies:
3+
data:
4+
- operator-best-practices.md
5+
---
26
# Task: Implement a new Kubernetes Custom Resource
37

48
## Description
@@ -7,39 +11,48 @@ This guide provides a comprehensive prompt for LLM to implement a new Kubernetes
711

812
## Prerequisites
913

10-
**IMPORTANT**: Before starting implementation, you must read and fully understand the following documentation:
14+
<prerequisites>
15+
IMPORTANT: Before starting implementation, you must read and fully understand the following documentation:
1116

1217
1. [Operator Best Practices](./.krci-ai/data/operator-best-practices.md) - Apply ALL the Kubernetes operator-specific patterns, architectural principles, CRD design guidelines, and operational practices defined in this document.
18+
</prerequisites>
1319

1420
## ⚠️ CRITICAL FIRST STEP
1521

16-
**BEFORE ANY IMPLEMENTATION**: You MUST run the `make operator-sdk create api` command first to scaffold the proper structure. See Step 1.0 below for detailed instructions on how to do this.
22+
<critical_first_step>
23+
BEFORE ANY IMPLEMENTATION: You MUST run the `make operator-sdk create api` command first to scaffold the proper structure. See Step 1.0 below for detailed instructions on how to do this.
1724

18-
**DO NOT** manually create files before running this command!
25+
DO NOT manually create files before running this command!
26+
</critical_first_step>
1927

2028
## Overview
2129

30+
<overview>
2231
You are tasked with implementing a new Kubernetes Custom Resource for the `your-operator` project. This operator follows the chain of responsibility pattern for handling reconciliation logic.
32+
</overview>
2333

2434
## Implementation Steps
2535

36+
<implementation_steps>
2637
Follow the [Operator SDK Tutorial](https://sdk.operatorframework.io/docs/building-operators/golang/tutorial/) as the foundation for implementing your controller.
38+
</implementation_steps>
2739

28-
#### 1 Scaffold API and Controller
40+
### 1 Scaffold API and Controller
2941

30-
**Before implementing the controller, ask the user for the CustomResource details:**
42+
<scaffold_api_controller>
43+
Before implementing the controller, ask the user for the CustomResource details:
3144

32-
1. **Group**: The API group (typically use `v1` for this project)
33-
2. **Version**: The API version (typically `v1alpha1`)
34-
3. **Kind**: The CustomResource kind name (e.g., `KeycloakClient`, `KeycloakUser`, etc.)
45+
1. Group: The API group (typically use `v1` for this project)
46+
2. Version: The API version (typically `v1alpha1`)
47+
3. Kind: The CustomResource kind name (e.g., `KeycloakClient`, `KeycloakUser`, etc.)
3548

3649
Once you have these details, use the Operator SDK to scaffold the basic API and controller structure:
3750

3851
```bash
3952
make operator-sdk create api --group <group> --version <version> --kind <kind> --resource --controller
4053
```
4154

42-
**Example**: If the user wants to create a `KeycloakClient` CustomResource:
55+
Example: If the user wants to create a `KeycloakClient` CustomResource:
4356

4457
```bash
4558
make operator-sdk create api --group v1 --version v1alpha1 --kind KeycloakClient --resource --controller
@@ -52,12 +65,14 @@ This command will create:
5265
- Basic RBAC markers
5366

5467
After scaffolding, you'll need to customize the generated code to follow the project's specific patterns described in the sections below.
68+
</scaffold_api_controller>
5569

56-
#### 2 Implement the API Types
70+
### 2 Implement the API Types
5771

72+
<implement_api_types>
5873
Implement your Custom Resource Definition (CRD) spec and status, based on user requirements, in `api/v1alpha1/`:
5974

60-
**Note**: The following examples use `YourResource` as a placeholder. Replace this with the actual resource name you specified during scaffolding.
75+
Note: The following examples use `YourResource` as a placeholder. Replace this with the actual resource name you specified during scaffolding.
6176

6277
```go
6378
// +kubebuilder:object:root=true
@@ -83,20 +98,26 @@ type YourResourceStatus struct {
8398
}
8499
```
85100

86-
#### 3 Generate Code and Manifests
101+
</implement_api_types>
102+
103+
### 3 Generate Code and Manifests
87104

105+
<generate_code_manifests>
88106
Run the following commands to generate the necessary code:
89107

90108
```bash
91109
make generate
92110
make manifests
93111
```
94112

95-
#### 4 Implement the Controller
113+
</generate_code_manifests>
96114

115+
### 4 Implement the Controller
116+
117+
<implement_controller>
97118
Implement your controller in `internal/controller/yourresource/` following the existing pattern:
98119

99-
**Note**: Replace `YourResource` and `yourresource` with the actual resource name you specified during scaffolding.
120+
Note: Replace `YourResource` and `yourresource` with the actual resource name you specified during scaffolding.
100121

101122
```go
102123
package yourresource
@@ -231,15 +252,18 @@ func (r *ReconcileYourResource) updateYourResourceStatus(
231252
}
232253
```
233254

234-
#### 5 Implement the Chain of Responsibility
255+
</implement_controller>
256+
257+
### 5 Implement the Chain of Responsibility
235258

259+
<implement_chain>
236260
Create a chain package in `internal/controller/yourresource/chain/` with the following structure:
237261

238262
1. `chain.go` - Main chain implementation
239263
2. `factory.go` - Chain factory
240264
3. Individual handler files for each step in the chain
241265

242-
**Note**: Replace `yourresource` and `YourResource` with the actual resource name you specified during scaffolding.
266+
Note: Replace `yourresource` and `YourResource` with the actual resource name you specified during scaffolding.
243267

244268
Example `chain.go`:
245269

@@ -284,9 +308,11 @@ func MakeChain(k8sClient client.Client) Chain {
284308
```
285309

286310
Example handler implementations should follow the pattern of existing handlers in your chain.
311+
</implement_chain>
287312

288-
#### 6 Register the Controller
313+
### 6 Register the Controller
289314

315+
<register_controller>
290316
Add your controller to `cmd/main.go`:
291317

292318
```go
@@ -301,4 +327,5 @@ if err = yourresourcecontroller.NewReconcileYourResource(mgr.GetClient()).SetupW
301327
}
302328
```
303329

304-
**Note**: Replace `YourResource` with the actual resource name you specified during scaffolding.
330+
Note: Replace `YourResource` with the actual resource name you specified during scaffolding.
331+
</register_controller>
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1+
---
2+
dependencies:
3+
data:
4+
- go-coding-standards.md
5+
- operator-best-practices.md
6+
---
7+
18
# Task: Review Go code
29

310
You are an expert Go developer and Kubernetes operator specialist tasked with reviewing Go code for quality, best practices, and adherence to standards.
411

512
## Prerequisites
613

7-
**IMPORTANT**: Before starting your review, you must read and fully understand the following documentation:
14+
<prerequisites>
15+
IMPORTANT: Before starting your review, you must read and fully understand the following documentation:
816

9-
1. **Read** [Go Coding Standards](./.krci-ai/data/go-coding-standards.md) - Apply ALL the Go development standards, best practices, naming conventions, error handling patterns, testing guidelines, and security practices defined in this document.
17+
1. Read [Go Coding Standards](./.krci-ai/data/go-coding-standards.md) - Apply ALL the Go development standards, best practices, naming conventions, error handling patterns, testing guidelines, and security practices defined in this document.
1018

11-
2. **Read** [Operator Best Practices](./.krci-ai/data/operator-best-practices.md) - Apply ALL the Kubernetes operator-specific patterns, architectural principles, CRD design guidelines, and operational practices defined in this document.
19+
2. Read [Operator Best Practices](./.krci-ai/data/operator-best-practices.md) - Apply ALL the Kubernetes operator-specific patterns, architectural principles, CRD design guidelines, and operational practices defined in this document.
1220

1321
Your review must be based on the standards and practices outlined in these documents. Do not proceed without reading them first.
22+
</prerequisites>
1423

1524
## Review Approach
1625

17-
1. **Analyze the code** against all standards and practices from the required documentation
18-
2. **Identify violations** of the established guidelines
19-
3. **Provide specific, actionable feedback** with clear examples and references to the documentation
26+
<review_approach>
27+
1. Analyze the code against all standards and practices from the required documentation
28+
2. Identify violations of the established guidelines
29+
3. Provide specific, actionable feedback with clear examples and references to the documentation
30+
</review_approach>
2031

2132
## Review Output Format
2233

34+
<review_output_format>
35+
2336
### Summary
2437

2538
Brief overall assessment of code quality and adherence to standards.
@@ -28,11 +41,11 @@ Brief overall assessment of code quality and adherence to standards.
2841

2942
For each issue found, provide:
3043

31-
- **Category**: (e.g., "Go Standards Violation", "Operator Best Practice", "Security", etc.)
32-
- **Severity**: Critical | High | Medium | Low
33-
- **Description**: Clear explanation with reference to specific guideline from the documentation
34-
- **Location**: File and line number references
35-
- **Recommendation**: Specific fix with code example if helpful
44+
- Category: (e.g., "Go Standards Violation", "Operator Best Practice", "Security", etc.)
45+
- Severity: Critical | High | Medium | Low
46+
- Description: Clear explanation with reference to specific guideline from the documentation
47+
- Location: File and line number references
48+
- Recommendation: Specific fix with code example if helpful
3649

3750
### Strengths
3851

@@ -45,10 +58,13 @@ Prioritized list of recommended fixes:
4558
1. Critical issues that must be addressed
4659
2. Important improvements
4760
3. Nice-to-have enhancements
61+
</review_output_format>
4862

4963
## Review Principles
5064

65+
<review_principles>
5166
- Be constructive and educational
5267
- Reference the specific guidelines from the documentation
5368
- Provide concrete examples and suggestions
5469
- Balance thoroughness with practicality
70+
</review_principles>

0 commit comments

Comments
 (0)