score-spec/score-k8s

[feature request] Support ordered container start using initContainers

オープン

#291 opened on 2026/04/14

 (1 件のコメント) (0 件のリアクション) (1 人の担当者)Go (25 件のフォーク)auto 404
enhancementgogood first issuehelp wanted

Repository metrics

Stars
 (47 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Is your feature request related to a problem? Please describe. Currently score-k8s doesn't support the before property for ordered container start (spec#104). In score-compose we already have this (score-compose#454), but score-k8s needs a different approach since Kubernetes has native initContainers.

Describe the solution you'd like Map the before property to Kubernetes initContainers:

  • ready: complete - regular initContainers entry (runs to completion before main containers start)
  • ready: started - native sidecar initContainers with restartPolicy: Always (starts before main containers, keeps running)
  • ready: healthy - return a validation error, same as score-compose K8s initContainers don't support health-based gating natively

For example, given:

containers:
  migrate:
    image: my-app:latest
    command: ["migrate"]
    before:
      app:
        ready: complete
  app:
    image: my-app:latest

The generated manifest would place migrate in spec.initContainers and app in spec.containers.

Changes would mainly go in internal/convert/workloads.go checking each container's Before field and splitting them into initContainers vs regular containers accordingly.

Describe alternatives you've considered Could also use Kubernetes lifecycle hooks or a custom controller, but initContainers is the most natural fit and is widely supported.

Additional context

  • Spec issue: score-spec/spec#104
  • score-compose implementation: score-spec/score-compose#454
  • The before type definitions already exist in score-go v1.14.0+
  • Native sidecar support (restartPolicy: Always on initContainers) is stable since K8s v1.33

Let me know if this approach makes sense or if there's anything I should adjust.

コントリビューターガイド