|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build and Deploy Commands |
| 6 | + |
| 7 | +### Full Deployment Pipeline |
| 8 | +```bash |
| 9 | +make # Runs: bootstrap external smoke-test post-install applications |
| 10 | +``` |
| 11 | + |
| 12 | +### Individual Components |
| 13 | +```bash |
| 14 | +make metal # Bare metal provisioning (PXE boot, prerequisites, kubespray, cilium) |
| 15 | +make bootstrap # Bootstrap ArgoCD on the cluster (ansible-playbook kubernetes/bootstrap.yml) |
| 16 | +make external # Apply Terraform for Cloudflare tunnel/DNS (cd external && terraform apply) |
| 17 | +make applications # Deploy standalone ArgoCD applications (kubectl apply -f applications/) |
| 18 | +``` |
| 19 | + |
| 20 | +### Testing |
| 21 | +```bash |
| 22 | +make test # Run all Go integration tests (gotestsum) |
| 23 | +make smoke-test # Run smoke tests only (filter=Smoke) |
| 24 | +cd test && make filter=TestSmoke # Run specific test |
| 25 | +``` |
| 26 | + |
| 27 | +### Development Environment |
| 28 | +```bash |
| 29 | +make tools # Launch Nix devShell with all required tools in Docker |
| 30 | +nix develop # Direct Nix shell (requires Nix with flakes) |
| 31 | +``` |
| 32 | + |
| 33 | +### Metal/Bare Metal Commands |
| 34 | +```bash |
| 35 | +cd metal && make boot # PXE boot nodes |
| 36 | +cd metal && make prerequisites # Install prerequisites on nodes |
| 37 | +cd metal && make k8s # Deploy Kubernetes via kubespray |
| 38 | +cd metal && make cilium # Install Cilium CNI |
| 39 | +``` |
| 40 | + |
| 41 | +### External/Terraform Commands |
| 42 | +```bash |
| 43 | +cd external && make plan # Terraform plan |
| 44 | +cd external && make apply # Terraform apply (Cloudflare resources) |
| 45 | +``` |
| 46 | + |
| 47 | +### Helper Scripts |
| 48 | +```bash |
| 49 | +./scripts/argocd-admin-password # Get ArgoCD admin password |
| 50 | +./scripts/gitea-admin-password # Get Gitea admin password |
| 51 | +./scripts/grafana-admin-password # Get Grafana admin password |
| 52 | +./scripts/kanidm-reset-password # Reset Kanidm password |
| 53 | +``` |
| 54 | + |
| 55 | +## Architecture Overview |
| 56 | + |
| 57 | +### GitOps Deployment Model |
| 58 | +- **ArgoCD** is the central deployment controller, bootstrapped via Ansible (`kubernetes/bootstrap.yml`) |
| 59 | +- A single **ApplicationSet** in `kubernetes/system/argocd/values.yaml` auto-discovers and deploys all charts from: |
| 60 | + - `kubernetes/system/*` - Core infrastructure (argocd, cert-manager, ingress-nginx, monitoring, rook-ceph, etc.) |
| 61 | + - `kubernetes/platform/*` - Platform services (gitea, grafana, harbor, kanidm, woodpecker, etc.) |
| 62 | + - `kubernetes/apps/*` - User applications |
| 63 | +- **Standalone applications** in `applications/` directory are deployed separately with custom configurations |
| 64 | + |
| 65 | +### Directory Structure Conventions |
| 66 | +- Each service is a Helm chart wrapper in its directory with `Chart.yaml` and `values.yaml` |
| 67 | +- Charts typically wrap upstream Helm charts as dependencies |
| 68 | +- Custom templates go in `templates/` subdirectory when needed |
| 69 | +- Namespace matches the directory basename by default (ArgoCD convention) |
| 70 | + |
| 71 | +### Infrastructure Layers |
| 72 | +1. **Metal Layer** (`metal/`): Ansible playbooks for bare metal provisioning via PXE |
| 73 | +2. **Kubernetes Layer**: Deployed via external kubespray repository (submodule reference) |
| 74 | +3. **External Layer** (`external/`): Terraform modules for Cloudflare tunnel, DNS, and secrets |
| 75 | +4. **Platform Layer** (`kubernetes/`): All Kubernetes workloads managed by ArgoCD |
| 76 | + |
| 77 | +### Key Integrations |
| 78 | +- **Cloudflare Tunnel**: External access via `cloudflared` in `kubernetes/system/cloudflared/` |
| 79 | +- **External DNS**: Automatic DNS record management with Cloudflare |
| 80 | +- **cert-manager**: Let's Encrypt certificates via `letsencrypt-prod` ClusterIssuer |
| 81 | +- **External Secrets Operator**: Secret management in `kubernetes/platform/external-secrets/` |
| 82 | + |
| 83 | +### Kubeconfig Location |
| 84 | +The kubeconfig is at `metal/kubeconfig.yaml` - all Makefiles reference this path. |
| 85 | + |
| 86 | +## Testing Architecture |
| 87 | + |
| 88 | +Tests are in `test/` directory using Go with Terratest: |
| 89 | +- `smoke_test.go` - Verifies main services (argocd, gitea, grafana, kanidm, zot) are accessible |
| 90 | +- `integration_test.go` - Full integration tests |
| 91 | +- `external_test.go` - External access tests |
| 92 | +- Tests use `gotestsum` for better output formatting |
0 commit comments