score-spec/score-k8s

[feature request] Support ordered container start using initContainers

Aperta

#291 aperta il 14 apr 2026

 (1 commento) (0 reazioni) (1 assegnatario)Go (25 fork)auto 404
enhancementgogood first issuehelp wanted

Metriche repository

Star
 (47 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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.

Guida contributor