Skip to content

Commit 1c4da83

Browse files
fix(docker-to-sealos): refine app rule exceptions (#30)
1 parent c2c459e commit 1c4da83

6 files changed

Lines changed: 722 additions & 56 deletions

File tree

skills/docker-to-sealos/SKILL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ If validation fails, fix template/rules/examples first.
117117
- Never use `spec.template` in App resource.
118118
- `cloud.sealos.io/app-deploy-manager` label value must equal resource `metadata.name`.
119119
- `metadata.labels.app` label value must equal resource `metadata.name` for managed app workloads.
120-
- `containers[*].name` must equal workload `metadata.name` for managed app workloads.
120+
- The primary business container name must equal workload `metadata.name` for managed app workloads; sidecar/helper containers may use distinct descriptive names.
121121
- Application `Service` resources must define `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both labels must match `spec.selector.app`.
122-
- Component-scoped `ConfigMap` resources must define `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both labels must match `metadata.name`.
122+
- Runtime component-scoped `ConfigMap` resources must define `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both labels must match `metadata.name`; bootstrap-only ConfigMaps used only by init containers to copy initial config into persistent storage must not define either label.
123123
- Application `Service` resources must use the same component name across `metadata.name`, `metadata.labels.app`, `metadata.labels.cloud.sealos.io/app-deploy-manager`, and `spec.selector.app`.
124-
- Application `Ingress` resources must use the same component name across `metadata.name`, `metadata.labels.cloud.sealos.io/app-deploy-manager`, and backend `service.name`.
124+
- Root-path `Ingress` resources (`pathType: Prefix`, `path: /`) must use the same component name across `metadata.name`, `metadata.labels.cloud.sealos.io/app-deploy-manager`, and backend `service.name`; non-root or non-Prefix Ingress rules may route to a different backend service.
125125
- Service `spec.ports[*].name` must be explicitly set (required for multi-port services).
126126
- HTTP Ingress must include required nginx annotations (`kubernetes.io/ingress.class`, `nginx.ingress.kubernetes.io/proxy-body-size`, `nginx.ingress.kubernetes.io/server-snippet`, `nginx.ingress.kubernetes.io/ssl-redirect`, `nginx.ingress.kubernetes.io/backend-protocol`, `nginx.ingress.kubernetes.io/client-body-buffer-size`, `nginx.ingress.kubernetes.io/proxy-buffer-size`, `nginx.ingress.kubernetes.io/proxy-send-timeout`, `nginx.ingress.kubernetes.io/proxy-read-timeout`, `nginx.ingress.kubernetes.io/configuration-snippet`) with expected defaults.
127127
- CronJob resources must define labels `cloud.sealos.io/cronjob`, `cronjob-launchpad-name`, and `cronjob-type`; `cloud.sealos.io/cronjob` must equal `metadata.name`, `cronjob-launchpad-name` must be `""`, and `cronjob-type` must be `image`.
@@ -188,7 +188,7 @@ Unless source docs explicitly require otherwise, use the lightweight app ladder
188188
- container limits: `cpu=200m`, `memory=256Mi`
189189
- container requests: `cpu=20m`, `memory=25Mi`
190190
- `revisionHistoryLimit: 1`
191-
- `automountServiceAccountToken: false`
191+
- `automountServiceAccountToken: false` by default; set it to `true` only when the application has explicit Kubernetes API/service account token requirements, evidenced by Kubernetes integration settings, `serviceAccountName`, or a `sealos.io/service-account-token-reason` workload annotation.
192192

193193
For higher resource needs, move only to another allowed `limits` ladder entry and recompute `requests` from that `limits` value.
194194

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ must_rules:
6868
enforcement:
6969
type: rule
7070
target: R034
71-
- must: "`containers[*].name` must equal workload `metadata.name` for managed app workloads."
71+
- must: "The primary business container name must equal workload `metadata.name` for managed app workloads; sidecar/helper containers may use distinct descriptive names."
7272
enforcement:
7373
type: rule
7474
target: R028
7575
- must: "Application `Service` resources must define `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both labels must match `spec.selector.app`."
7676
enforcement:
7777
type: rule
7878
target: R029
79-
- must: "Component-scoped `ConfigMap` resources must define `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both labels must match `metadata.name`."
79+
- must: "Runtime component-scoped `ConfigMap` resources must define `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both labels must match `metadata.name`; bootstrap-only ConfigMaps used only by init containers to copy initial config into persistent storage must not define either label."
8080
enforcement:
8181
type: rule
8282
target: R030
8383
- must: "Application `Service` resources must use the same component name across `metadata.name`, `metadata.labels.app`, `metadata.labels.cloud.sealos.io/app-deploy-manager`, and `spec.selector.app`."
8484
enforcement:
8585
type: rule
8686
target: R029
87-
- must: "Application `Ingress` resources must use the same component name across `metadata.name`, `metadata.labels.cloud.sealos.io/app-deploy-manager`, and backend `service.name`."
87+
- must: "Root-path `Ingress` resources (`pathType: Prefix`, `path: /`) must use the same component name across `metadata.name`, `metadata.labels.cloud.sealos.io/app-deploy-manager`, and backend `service.name`; non-root or non-Prefix Ingress rules may route to a different backend service."
8888
enforcement:
8989
type: rule
9090
target: R031
@@ -240,6 +240,42 @@ must_rules:
240240
enforcement:
241241
type: rule
242242
target: R038
243+
- must: "Do not treat a short smoke test as proof of a stable minimum memory value."
244+
enforcement:
245+
type: manual
246+
note: "Review browser/remote desktop templates and smoke evidence before lowering memory."
247+
- must: "Validate memory with a fresh deployment, not only a patched warm pod."
248+
enforcement:
249+
type: manual
250+
note: "Requires deployment evidence outside static YAML validation."
251+
- must: "Exercise cold start until readiness, a lightweight page, a real/medium page, an interactive/search page, and a 60s post-smoke stability check."
252+
enforcement:
253+
type: manual
254+
note: "Requires runtime smoke coverage evidence."
255+
- must: "If observed cgroup memory reaches more than 80% of the limit during smoke, move to the next allowed Sealos memory ladder value."
256+
enforcement:
257+
type: manual
258+
note: "Requires runtime memory observation."
259+
- must: "Keep requests derived from limits according to the Sealos resource ladder."
260+
enforcement:
261+
type: rule
262+
target: R038
263+
- must: "Bad: Chrome passes a short smoke at `512Mi` but reaches `503Mi`; shipping `512Mi` as the stable minimum is unsafe."
264+
enforcement:
265+
type: manual
266+
note: "Negative example for reviewer guidance."
267+
- must: "Good: raise to `1024Mi`, set request to `102Mi`, rerun smoke and stability checks."
268+
enforcement:
269+
type: manual
270+
note: "Positive example for reviewer guidance."
271+
- must: "limits: `cpu=200m`, `memory=1024Mi`"
272+
enforcement:
273+
type: manual
274+
note: "Browser/remote desktop minimum; applied when source workload matches that class."
275+
- must: "requests: `cpu=20m`, `memory=102Mi`"
276+
enforcement:
277+
type: manual
278+
note: "Browser/remote desktop minimum request; applied when source workload matches that class."
243279
- must: "MongoDB: `${{ defaults.app_name }}-mongo-mongodb-account-root` (or `${{ defaults.app_name }}-mongodb-mongodb-account-root` when the MongoDB cluster name uses `-mongodb`)"
244280
enforcement:
245281
type: rule
@@ -268,7 +304,7 @@ must_rules:
268304
enforcement:
269305
type: rule
270306
target: R009
271-
- must: "`automountServiceAccountToken: false`"
307+
- must: "`automountServiceAccountToken: false` by default; set it to `true` only when the application has explicit Kubernetes API/service account token requirements, evidenced by Kubernetes integration settings, `serviceAccountName`, or a `sealos.io/service-account-token-reason` workload annotation."
272308
enforcement:
273309
type: rule
274310
target: R010

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,22 @@ rules:
9898
description: Managed app workloads must define metadata.labels.app and match metadata.name.
9999
severity: error
100100
- id: R028
101-
description: Managed app workload container names must exactly match metadata.name.
101+
description: Managed app workloads must include a primary business container whose name exactly matches metadata.name.
102102
severity: error
103103
- id: R029
104104
description: Application Services must use one component name across metadata.name, labels.app, cloud.sealos.io/app-deploy-manager, and spec.selector.app.
105105
severity: error
106106
- id: R030
107-
description: Component ConfigMaps must use one component name across metadata.name, labels.app, and cloud.sealos.io/app-deploy-manager.
107+
description: Runtime component ConfigMaps must use one component name across metadata.name, labels.app, and cloud.sealos.io/app-deploy-manager; bootstrap-only init-copy ConfigMaps must not define either managed label.
108108
severity: error
109109
- id: R031
110-
description: Application Ingress resources must use one component name across metadata.name, cloud.sealos.io/app-deploy-manager, and backend service names.
110+
description: Root-path Prefix Ingress resources must use one component name across metadata.name, cloud.sealos.io/app-deploy-manager, and backend service names; non-root or non-Prefix routes may differ.
111111
severity: error
112112
- id: R009
113113
description: Managed app workloads must explicitly set revisionHistoryLimit to 1.
114114
severity: error
115115
- id: R010
116-
description: Managed app workloads must explicitly set automountServiceAccountToken to false.
116+
description: Managed app workloads must explicitly set automountServiceAccountToken to false unless Kubernetes API/service account token usage is evidenced by integration settings, serviceAccountName, or a service-account-token reason annotation.
117117
severity: error
118118
- id: R035
119119
description: Managed app workloads must reference the app-scoped image pull secret name via template.spec.imagePullSecrets.

skills/docker-to-sealos/references/sealos-specs.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,14 @@ spec:
493493
- `${{ defaults.app_name }}-ml`
494494
- `${{ defaults.app_name }}-redis`
495495
5. Application Service must include `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and `metadata.name`, both labels, and `spec.selector.app` must be exactly the same
496-
6. Component-level ConfigMap must include `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both must be consistent with `metadata.name`
497-
7. Application Ingress's `metadata.name` must be consistent with `metadata.labels.cloud.sealos.io/app-deploy-manager` and the backend `service.name`
496+
6. Runtime component-level ConfigMap must include `metadata.labels.app` and `metadata.labels.cloud.sealos.io/app-deploy-manager`, and both must be consistent with `metadata.name`; ConfigMaps used only by init containers to copy initial config into persistent storage must not include either label
497+
7. Root-path Ingress rules (`pathType: Prefix`, `path: /`) must keep `metadata.name` consistent with `metadata.labels.cloud.sealos.io/app-deploy-manager` and backend `service.name`; non-root or non-Prefix Ingress rules may use a distinct Ingress name and backend service
498498

499499
### Container Naming Rules
500500

501-
The `containers.name` must be consistent with the `metadata.name` value.
501+
The primary business container name must be consistent with the workload
502+
`metadata.name` value. Sidecar/helper containers may use distinct descriptive
503+
names when they are not the main business container.
502504

503505
```yaml
504506
# Correct example
@@ -509,6 +511,7 @@ spec:
509511
spec:
510512
containers:
511513
- name: ${{ defaults.app_name }} # Must be consistent with metadata.name
514+
- name: metrics-sidecar # Allowed: helper/sidecar container
512515
513516
# Correct example for sub-components
514517
metadata:
@@ -827,7 +830,7 @@ This is because Kubernetes parses environment variables in the order they appear
827830

828831
All application Deployments or StatefulSets must include the following configurations:
829832

830-
1. **automountServiceAccountToken**: Must be set to `false` to avoid unnecessary permission exposure
833+
1. **automountServiceAccountToken**: Must be set to `false` to avoid unnecessary permission exposure. Set it to `true` only when the application explicitly needs the Kubernetes API/service account token, evidenced by Kubernetes integration settings, `serviceAccountName`, or `sealos.io/service-account-token-reason` in workload annotations.
831834
2. **revisionHistoryLimit**: Must be set to `1` to reduce resources consumed by historical revisions
832835
3. **imagePullSecrets**: Must reference the app-scoped image pull Secret `${{ defaults.app_name }}`
833836
4. **metadata.annotations**: Must include the following annotations:
@@ -857,7 +860,7 @@ spec:
857860
revisionHistoryLimit: 1 # Must be set to 1
858861
template:
859862
spec:
860-
automountServiceAccountToken: false # Must be set to false
863+
automountServiceAccountToken: false # Default; only set true with evidenced Kubernetes API token need
861864
imagePullSecrets:
862865
- name: ${{ defaults.app_name }}
863866
containers:

0 commit comments

Comments
 (0)