Skip to content

Commit e388d2e

Browse files
authored
Add CLAUDE.md file (#2478)
1 parent d6968d8 commit e388d2e

File tree

2 files changed

+142
-1
lines changed

2 files changed

+142
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ go.work.sum
1919
*.tmp
2020
.envrc
2121
.DS_Store
22-
CLAUDE.md
2322

2423
# Ignore preflight bundles generated during local dev
2524
preflightbundle*

CLAUDE.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Embedded Cluster is a platform by Replicated that allows you to distribute a Kubernetes cluster and your application together as a single appliance. It simplifies enterprise software deployment by consolidating all components into a single binary that handles streamlined cluster installation without external dependencies.
8+
9+
The project bundles k0s (open source Kubernetes distribution) with applications, providing a complete Kubernetes distribution that can be installed and managed as a single unit.
10+
11+
## Technology Stack
12+
13+
### Core Technologies
14+
- **Go 1.24.4** - Primary language for backend, CLI, and operators
15+
- **TypeScript/React** - Frontend web UI with Vite build system
16+
- **Kubernetes (k0s v1.31.8+k0s.0)** - Foundation Kubernetes distribution
17+
- **Docker** - Container runtime and development environment
18+
19+
### Key Dependencies
20+
- **KOTS** - Application lifecycle management
21+
- **Velero** - Backup and disaster recovery
22+
- **OpenEBS** - Storage provisioner
23+
- **SeaweedFS** - Distributed object storage for HA air gap mode
24+
- **Helm** - Package management for Kubernetes applications
25+
26+
## Development Commands
27+
28+
### Essential Build Commands
29+
```bash
30+
# Create initial installation release
31+
make initial-release
32+
33+
# Create upgrade release
34+
make upgrade-release
35+
36+
# Set up development node
37+
make create-node0
38+
39+
# Build with TTL.sh integration
40+
make build-ttl.sh
41+
```
42+
43+
### Testing Commands
44+
```bash
45+
# Run unit tests
46+
make unit-tests
47+
48+
# Run end-to-end tests
49+
make e2e-tests
50+
51+
# Code linting
52+
make lint
53+
```
54+
55+
### Build Targets
56+
- `embedded-cluster-linux-amd64` - Linux AMD64 binary
57+
- `embedded-cluster-linux-arm64` - Linux ARM64 binary
58+
- `embedded-cluster-darwin-arm64` - macOS ARM64 binary
59+
60+
## Architecture Overview
61+
62+
### Core Design Patterns
63+
- **Functional Options Pattern** - Standard for component initialization
64+
- **Interface-Driven Design** - Behavior through interfaces for mocking/testing
65+
- **Dependency Injection** - Decoupled components with clean interfaces
66+
- **State Machine** - Enforces valid state transitions for installation workflows
67+
68+
### Key Components
69+
- **Single Binary Distribution** - All components consolidated for easy deployment
70+
- **Controller-Manager Pattern** - Controllers handle workflows, managers handle subdomains
71+
- **Air Gap Support** - Complete offline installation capability
72+
- **Custom Resource Definitions** - Installation, Config, KubernetesInstallation types
73+
74+
## Code Organization
75+
76+
### Primary Directories
77+
- **`/cmd/installer/`** - Main CLI application with installation, join, reset, and management commands
78+
- **`/cmd/local-artifact-mirror/`** - Local artifact mirror for air gap deployments
79+
- **`/cmd/buildtools/`** - Build utilities and tooling
80+
81+
### API & Backend
82+
- **`/api/`** - REST API server with controllers, handlers, and state management
83+
- Controllers for auth, console, kubernetes, and linux installation
84+
- Internal managers for domain-specific functionality
85+
- Swagger documentation generation
86+
87+
### Kubernetes Components
88+
- **`/operator/`** - Kubernetes operator for managing cluster lifecycle
89+
- **`/kinds/`** - Custom Resource Definitions (CRDs)
90+
- **`/pkg/`** - Shared libraries and utilities
91+
- Addons (admin console, operator, storage, registry, etc.)
92+
- Network utilities, configuration management
93+
- Helm client, Kubernetes utilities
94+
95+
### Frontend & Testing
96+
- **`/web/`** - React/TypeScript web UI with Tailwind CSS
97+
- **`/e2e/`** - End-to-end integration tests
98+
- **`/tests/`** - Unit and integration test suites
99+
- **`/dev/`** - Development environment setup and tooling
100+
101+
## Development Guidelines
102+
103+
### Code Quality Standards
104+
- **Clean Code Principles** - Concise comments, proper file formatting
105+
- **Structured Error Handling** - Consistent error wrapping and context
106+
- **Go Best Practices** - Proper error handling, naming conventions, interface design
107+
- **API Guidelines** - Structured errors, consistent HTTP patterns
108+
109+
### Testing Requirements
110+
- Unit tests alongside source files (`*_test.go`)
111+
- Table-driven tests with `testify/assert`
112+
- Mock all external dependencies
113+
- Integration tests in dedicated directories
114+
115+
### Architecture Decisions
116+
1. **Release Metadata Independence** - API doesn't depend on CLI embedded metadata
117+
2. **Kubernetes as Linux Subset** - Kubernetes installations are subset of Linux installations
118+
3. **Interface-Driven Design** - All components use interfaces for testability
119+
120+
## Local Development Environment
121+
122+
### Requirements
123+
- macOS with Docker Desktop
124+
- Go 1.24.4+
125+
- Various CLI tools (helm, aws, kubectl, etc.)
126+
- Development uses LXD containers for multi-node testing
127+
128+
### Development Flow
129+
1. Set environment variables for Replicated API access
130+
2. Create initial release with `make initial-release`
131+
3. Spin up development nodes with `make create-node0`
132+
4. Install using generated binary with license
133+
5. Access admin console at localhost:30000
134+
135+
## Key Custom Resources
136+
137+
The system uses several custom Kubernetes resources:
138+
- **Installation** - Tracks cluster and application upgrades
139+
- **Config** - Runtime configuration management
140+
- **ClusterConfig** - k0s configuration ingestion
141+
- **Plan** - Autopilot operator configuration for upgrades
142+
- **Chart** - Helm chart tracking and management

0 commit comments

Comments
 (0)