feat: add R8sCluster recipe — opinionated cluster foundation - #59
Merged
Conversation
Stack sets up a complete cluster foundation in one component: - cert-manager for TLS certificate automation - external-dns with TSIG for secure RFC 2136 DNS updates - Envoy Gateway for Gateway API routing - OpenBao VSO for secrets management - Prometheus for metrics and alerting - Loki + FluentBit for log aggregation of all user pods All 7 operators are declared automatically. Children inherit namespace, routing (gateway), secrets (OpenBao), and DNS (external-dns with TSIG) contexts — just add apps. Includes 12 tests covering operator declaration, Namespace materialization, LokiStack/Logging/Flow/Output creation, context propagation to children, and operator dedup.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Stack recipe component intended to provision an opinionated “cluster foundation” (operators + baseline resources) and propagate shared contexts (namespace/routing/secrets/DNS) to child recipes, plus integrates it into the recipes export surface and CLI catalog with accompanying tests.
Changes:
- Introduces
Stackrecipe that declares a fixed set of cluster operators and creates baseline logging resources (LokiStack + Logging Operator Flow/Output). - Exports
Stackfrom@r8s/recipesand adds it to the CLI component catalog (r8s info/explain). - Adds a new Vitest suite covering operator declaration, resource materialization, and context propagation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| packages/recipes/src/stack.tsx | New Stack recipe: operator declaration, provider wiring, and baseline Loki/logging resources. |
| packages/recipes/src/index.ts | Exports Stack from the recipes package entrypoint. |
| packages/recipes/tests/stack.test.ts | Adds test coverage for Stack behavior and context propagation. |
| packages/cli/src/catalog.ts | Adds Stack to CLI catalog metadata for info/explain. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,295 @@ | |||
| import { jsx, Fragment, useContext, declareOperator } from '@r8s/core' | |||
Comment on lines
+70
to
+74
| /** | ||
| * Application components (App, Database, Auth, etc.). | ||
| */ | ||
| children: unknown | ||
| } |
Comment on lines
+168
to
+170
| // Cluster-level logging: FluentBit collects logs from ALL pods in | ||
| // the namespace and ships to Loki. A ClusterFlow matches everything. | ||
| const loggingName = `${namespace}-logging` |
Comment on lines
+181
to
+188
| spec: { | ||
| size: '1x.small', | ||
| storageClassName: logsStorageClass, | ||
| storage: { | ||
| schemas: [{ version: 'v13', effectiveDate: '2024-01-01' }], | ||
| secret: { name: lokiStorageSecret, type: 's3' }, | ||
| }, | ||
| tenants: { |
Comment on lines
+275
to
+279
| // Apply operators context (all declared + preinstalled) | ||
| const allOperators = [...preinstalled, ...declared] | ||
| if (allOperators.length > 0) { | ||
| result = jsx(OperatorContext.Provider, { value: allOperators, children: result }) | ||
| } |
Comment on lines
+256
to
+261
| { | ||
| name: 'children', | ||
| type: 'unknown', | ||
| required: true, | ||
| description: 'App/Database/Auth components', | ||
| }, |
Avoids collision with CNPG's Cluster CRD. Cluster-scoped, no namespace prop. Logging infra in dedicated namespace (default 'logging'). - Rename stack.tsx → r8s-cluster.tsx, Stack → R8sCluster - Update catalog: remove namespace/domain/logsRetention props, add logsNamespace prop - 19 tests covering operators, logging, DNS, secrets, routing, cluster-scoped behavior, and complete cluster rendering
- Remove unused declareOperator import - Make children optional (R8sCluster can set up infra standalone) - Merge parent OperatorContext instead of overwriting it - Mark children as not required in CLI catalog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new
R8sClustercomponent that sets up a complete cluster foundation in one call. Renamed fromStackto avoid collision with CNPG'sClusterCRD.What R8sCluster does
All 7 operators are declared automatically. Children inherit routing (gateway), secrets (OpenBao), and DNS (external-dns with TSIG) contexts.
Cluster-scoped — does not take a
namespaceprop. Operators install to their own namespaces. Logging infrastructure lives in a dedicated namespace (defaultlogging). App namespaces are managed byPlatformor the apps themselves.Usage
What it creates
loggingnamespace (log backend)loggingloggingexternal-dnsnamespaceProps
secrets{ mount, path, authRef? }dns{ server, zone, tsigPath, tsigKey? }gatewayClassNamestring"eg"labelsRecord<string, string>operatorsOperator[]logsNamespacestring"logging"logsStorageClassstring"standard"childrenunknownTests
19 tests covering: operator declaration (7 operators), operator dedup, LokiStack/Logging/Flow/Output creation in logging namespace, custom logs namespace, custom storage class, TSIG secret in external-dns namespace, DNS context propagation to children, secrets context propagation to children, gateway routing context propagation, custom gatewayClassName, cluster-scoped behavior (no namespace prop, no Namespace resource), Platform integration, and complete cluster rendering with apps.
CLI
r8s info R8sClusterandr8s explain R8sClusterwork — R8sCluster is in the catalog.