Skip to content

Commit 30d99c0

Browse files
fix(docker-to-sealos): enforce runtime bundle consistency (#52)
1 parent a3be0d3 commit 30d99c0

8 files changed

Lines changed: 934 additions & 1 deletion

File tree

skills/docker-to-sealos/SKILL.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Extract from Docker Compose/docs:
3535
- multi-service web roles: browser entry, REST API, OpenAI/API gateway, docs, workers, and one-shot jobs
3636
- resource limits/requests and health checks
3737
- if official Kubernetes installation docs/manifests are available, also extract app-runtime behavior from them (bootstrap admin fields, external endpoint/protocol assumptions, health probes, startup/init flow, migration ordering)
38+
- if official compose/docs provide multiple cooperating services, record the official runtime bundle source, component list, image versions, public entry routes, and critical env vars
3839

3940
### Step 2: Infer metadata
4041

@@ -70,6 +71,7 @@ Apply field-level mappings from `references/conversion-mappings.md`, including:
7071
- URL topology: browser-facing env vars must use public HTTPS URLs, while server-to-server env vars must use Kubernetes Service FQDNs unless the app explicitly requires public callbacks
7172
- prefer `scripts/compose_to_template.py --kompose-mode always` as deterministic conversion entrypoint (require `kompose` for reproducible workload shaping)
7273
- when official Kubernetes installation docs/manifests exist, perform a dual-source merge: use Compose as baseline topology, then align app-runtime semantics with official Kubernetes guidance
74+
- when official compose/docs define a multi-component runtime bundle, keep runtime-required components, entry routes, critical env vars, and component image versions aligned to one official release/compose source
7375

7476
### Step 5: Apply database strategy
7577

@@ -144,6 +146,8 @@ If validation fails, fix template/rules/examples first.
144146

145147
- If official Kubernetes installation docs/manifests are available, conversion must reference them and align critical runtime settings before emitting template artifacts.
146148
- When official Kubernetes docs/manifests and Compose differ, prefer official Kubernetes runtime semantics for app behavior (bootstrap admin fields, external endpoint/env/protocol, health probes), unless doing so violates higher-priority Sealos MUST/security constraints.
149+
- When official compose/docs provide a multi-component runtime bundle, template artifacts must preserve runtime-required components, public entry routes, critical env vars, and image versions from the same official release/compose source.
150+
- Templates using official multi-component runtime evidence must provide a separate `RuntimeBundleEvidence` YAML file during validation, while final Sealos Template artifacts stay free of runtime-bundle validator metadata.
147151

148152
### Images and pull policy
149153

skills/docker-to-sealos/references/conversion-mappings.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,54 @@ When the official Kubernetes method conflicts with Compose:
2929
- For all other application behavior, default to aligning with the official Kubernetes method
3030
- Record key decisions in the output (only record items with ambiguity)
3131

32+
## Runtime Bundle Consistency
33+
34+
When official compose/docs define multiple cooperating runtime services, treat the service set as a single versioned runtime bundle. Use one official release, compose file, or docs artifact as the evidence source for API, frontend/console, worker, realtime, gateway, and other required components.
35+
36+
Do not upgrade one bundle component independently. Keep component image tags, public entry routes, and critical env vars aligned with the same evidence source.
37+
38+
Record the evidence contract in a separate validator-only YAML file, such as `.sealos/runtime-bundle-evidence.yaml`. Do not write this evidence into `template/<app>/index.yaml`.
39+
40+
```yaml
41+
apiVersion: docker-to-sealos/v1
42+
kind: RuntimeBundleEvidence
43+
metadata:
44+
name: demo-runtime-bundle
45+
spec:
46+
appName: demo
47+
source: https://example.com/releases/v1/docker-compose.yml
48+
images:
49+
- ghcr.io/example/api:1.0.0
50+
- ghcr.io/example/console:1.0.0
51+
components:
52+
- ${{ defaults.app_name }}
53+
- ${{ defaults.app_name }}-console
54+
routes:
55+
- path: /
56+
service: ${{ defaults.app_name }}
57+
- path: /console
58+
service: ${{ defaults.app_name }}-console
59+
env:
60+
- PUBLIC_ENDPOINT
61+
```
62+
63+
Evidence contract:
64+
65+
- `spec.appName`: Template `metadata.name` that this evidence validates.
66+
- `spec.source`: official compose/docs/release artifact URL or identifier.
67+
- `spec.images`: exact image refs expected from that source.
68+
- `spec.components`: workload names that must be emitted as managed app workloads.
69+
- `spec.routes`: `path` plus `service` entries that must appear in Service and Ingress resources.
70+
- `spec.env`: critical env var names that must remain present on managed workloads.
71+
72+
Run validation with both files included:
73+
74+
```bash
75+
python scripts/check_consistency.py --skill SKILL.md --references references --rules-file references/rules-registry.yaml --artifacts template/demo/index.yaml,.sealos/runtime-bundle-evidence.yaml
76+
```
77+
78+
For web consoles or frontends, keep the official public entry path reachable through an explicit Service and Ingress rule. A frontend/console component may be merged into the API workload only when the official image embeds that entry and runtime validation proves the route works after login.
79+
3280
## Core Concept Mapping
3381

3482
### Docker Compose Service → Sealos Resources

skills/docker-to-sealos/references/must-rules-map.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ must_rules:
136136
enforcement:
137137
type: manual
138138
note: "Conflict resolution depends on semantic comparison plus platform/security guardrails."
139+
- must: "When official compose/docs provide a multi-component runtime bundle, template artifacts must preserve runtime-required components, public entry routes, critical env vars, and image versions from the same official release/compose source."
140+
enforcement:
141+
type: rule
142+
target: R046
143+
- must: "Templates using official multi-component runtime evidence must provide a separate `RuntimeBundleEvidence` YAML file during validation, while final Sealos Template artifacts stay free of runtime-bundle validator metadata."
144+
enforcement:
145+
type: rule
146+
target: R046
139147
- must: "Do not use `:latest`."
140148
enforcement:
141149
type: rule

skills/docker-to-sealos/references/rules-registry.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ rules:
5555
- id: R024
5656
description: Workloads with official health checks must define livenessProbe/readinessProbe and startupProbe using official endpoints/commands.
5757
severity: error
58+
- id: R046
59+
description: Official multi-component RuntimeBundleEvidence must match emitted images, components, routes, and critical env vars.
60+
severity: error
5861
- id: R036
5962
description: CronJob resources must define cloud.sealos.io/cronjob, cronjob-launchpad-name, and cronjob-type labels with required values.
6063
severity: error

0 commit comments

Comments
 (0)