Pod startup from images

  • How ordered init copies prepare runtime, dependencies and release files before OBRH starts, and what repeats on replacement.
100%

Worked design example · evaluate before adopting

IMAGE INPUTS · pinned runtime, dependencies and release contentONE PODPod startup: copy runtime, dependencies and release filesOrder / release gateFailure alternativeCopy / read filesexecute imageexecute imageexecute imageA OKB OKC OKcopy runtimecopy JARscopy release + overridesmount read-onlyA failsB failsC failscontainer restartreusePod replacementrepeat A, B and CThe pinned runtime image carries /payload/runtime, including the executable launcher. Init A executes the carrier and copies its files; image, execution and destination volume are distinct objects. OCI IMAGERuntime filesThe pinned dependency image carries /payload/dependencies, including packaged SMS/APIGW dependencies where required. Init B copies these packaged files. Compatibility with the full release set needs prior validation. OCI IMAGEDependency JARsThe third pinned image carries release-specific files and overrides. copy-release-and-overrides selects this image; the dependency copy does not supply these separate inputs. OCI IMAGERelease + overridesFirst regular init container copies /payload/runtime into /assembled/runtime. Init A must complete successfully before Init B starts. The example uses sh -ec to propagate copy failures.INIT ACopy runtimeSecond regular init container copies /payload/dependencies into /assembled/dependencies in the same emptyDir. It starts after Init A succeeds; Init C starts only after Init B succeeds. Each copy step owns a separate destination directory.INIT BCopy dependenciesThird regular init container copy-release-and-overrides copies /payload/release and /payload/overrides into their separate assembled directories. The application stays unstarted until Init C also succeeds. Release files and overrides are explicit inputs, not implicitly part of dependency copying.INIT CRelease + overridesThe ordinary application container starts only after all three regular init containers have completed successfully. It mounts assembled files read-only at /artifacts. The custom launcher writes expansion/config/work/temp/logs beneath separate Pod-local /local storage.APP CONTAINERRead assembled filesOne assembled emptyDir belongs to this Pod. All three init steps write owned directories; the application consumes them read-only. Application-container restart can reuse it; Pod replacement gives fresh storage. Separate writable local/tmp emptyDirs are outside this artifact-flow view.emptyDirRuntime / JARsRelease / overridesIf any regular init step A, B or C cannot complete, normal application startup remains blocked. Retries follow the Pod restart policy. Copies must be idempotent because retries can encounter partial files. The example repeats copies into owned directories; archive cleanup and integrity checks need explicit implementation.INIT FAILUREApp stays unstartedAlternative: only the application container restarts while the same Pod and its emptyDir remain. Completed regular init containers normally are not rerun for this application-container restart. Files remain tied to the same pinned Pod template.SAME PODReuse existing filesAlternative: a replacement Pod gets a fresh emptyDir and runs Init A followed by Init B and Init C. A warm node may reuse cached image bytes while still repeating file copying or extraction. No startup-duration saving is assumed without measurements.NEW PODRepeat A, B and Cexecute imageexecute imageexecute imageA OKB OKC OKcopy runtimecopy JARscopy release +overridesmount read-onlyA failsB failsC failscontainer restartreusePod replacementrepeat A, B and C

Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.

  • Order: runtime A → dependencies B → release/overrides C → application start. All three write owned directories in one Pod-owned emptyDir.
  • Failure: a failed A, B or C blocks startup. Retried copies must tolerate partial files.
  • Lifetime alternatives: an application-container restart in the same Pod reuses files; a replacement Pod gets fresh storage and repeats all three copies.
  • The consumer mounts assembled artifacts read-only; writable local/tmp storage is separate. Image caching does not eliminate copying; measure startup before claiming a gain.
Pod startup from image contents

Pod startup from image contents

Kubernetes v1 Pods, apps/v1 and batch/v1 · Node.js >=24 teaching protocol · illustrative release identities

Follow the files, not an image inheritance tree

  • Image inputs: runtime carrier, dependency carrier, release/override carrier and consumer image have separate digest identities.
  • Execution: three regular init containers copy those packaged files, in order, into this Pod’s assembled emptyDir.
  • Consumption: the consumer mounts assembled files read-only; expansion, generated configuration, work, temp and logs use writable local volumes.
  • SMS/APIGW dependencies are packaged content in the dependency image. Copying them is not proof of Direct integration or compatible local-call contracts.
  • This composed Pod teaches the mechanism. It does not replace the source-bound inventory or assert that Current has only these inputs.
Illustrative Pod — ordered image-to-emptyDir copiesyaml
# Illustrative composed Pod, not an exact OBRH chart or deployable image set.
# Replace example digests; carriers must contain sh, cp and the stated /payload dirs.
# /payload/runtime includes executable start; UID/GID and permissions are image contracts.
apiVersion: v1
kind: Pod
metadata:
  name: delivery-init-example
spec:
  restartPolicy: Always
  securityContext: {runAsUser: 1000, runAsGroup: 1000, fsGroup: 1000}
  initContainers:
    - name: copy-runtime
      image: registry.example/runtime@sha256:1111111111111111111111111111111111111111111111111111111111111111
      command: [sh, -ec]
      args: ['mkdir -p /assembled/runtime; cp -R /payload/runtime/. /assembled/runtime/']
      volumeMounts:
        - {name: assembled, mountPath: /assembled}
    - name: copy-dependencies
      # SMS/APIGW dependencies are packaged files here, not service-call boxes.
      image: registry.example/dependencies@sha256:2222222222222222222222222222222222222222222222222222222222222222
      command: [sh, -ec]
      args: ['mkdir -p /assembled/dependencies; cp -R /payload/dependencies/. /assembled/dependencies/']
      volumeMounts:
        - {name: assembled, mountPath: /assembled}
    - name: copy-release-and-overrides
      image: registry.example/release@sha256:5555555555555555555555555555555555555555555555555555555555555555
      command: [sh, -ec]
      args:
        - mkdir -p /assembled/release /assembled/overrides;
          cp -R /payload/release/. /assembled/release/;
          cp -R /payload/overrides/. /assembled/overrides/
      volumeMounts:
        - {name: assembled, mountPath: /assembled}
  containers:
    - name: consumer
      image: registry.example/consumer@sha256:3333333333333333333333333333333333333333333333333333333333333333
      # Custom launcher contract: consume artifacts read-only, write below /local.
      command: [/artifacts/runtime/start]
      env:
        - {name: ARTIFACT_ROOT, value: /artifacts}
        - {name: RUNTIME_WRITE_ROOT, value: /local}
      securityContext: {readOnlyRootFilesystem: true}
      volumeMounts:
        - {name: assembled, mountPath: /artifacts, readOnly: true}
        - {name: local, mountPath: /local} # expanded apps/config/work/temp/logs
        - {name: tmp, mountPath: /tmp}
  volumes:
    - {name: assembled, emptyDir: {sizeLimit: 2Gi}}
    - {name: local, emptyDir: {sizeLimit: 2Gi}}
    - {name: tmp, emptyDir: {sizeLimit: 128Mi}}
# Copy steps are repeatable into their own directories. Add checksums and clean
# extraction semantics for archives; a directory-exists shortcut is not integrity.
# Existing external-artifacts PVC inputs, if required, remain separately mounted.

Trace startup and the failure branch

  • Runtime copy must finish before dependency copy; dependency copy must finish before release/override copy. The consumer starts after all succeed.
  • A failed copy prevents the consumer from starting. Retry behavior follows the Pod restart policy; repeated init work must be safe against partial files.
  • The example writes each carrier into its own directory. For real archives, validate checksums and extraction results; an existing directory alone does not establish completeness.
  • Image layers already present on a node can avoid downloads. They do not copy those bytes into a replacement Pod’s new volume.

Distinguish restart from replacement

  • An application-container crash preserves the same Pod’s emptyDir. Removing that Pod deletes its emptyDir; the replacement assembles a fresh one.
  • Init work can be retried or rerun in documented Pod restart situations. Keep it idempotent; do not assume a durable release cache in emptyDir.
Event Prepared bytes Operational consequence
Consumer container restarts in the same Pod emptyDir remains No guaranteed reassembly; still validate application recovery.
Failed init retries Partial copied files may remain Retry must overwrite safely or reject incomplete extraction.
Pod replaced on a warm node New emptyDir is empty Image may be local; filesystem copy still repeats.
Node local storage exhausted Copy/work volume may fail Size limits do not reserve node capacity.

Evaluate repeated work explicitly

  • Illustrative calculation: 12 replacement Pods × 600 MiB copied = 7,200 MiB of destination writes, even if every image is already local.
  • Illustrative timing: a 6 s assembly step on each Pod is 72 Pod-seconds of work. Parallel scheduling means this is not automatically 72 s of rollout delay.
  • Measure image resolution/pull, copy/extract, writable preparation and readiness separately. Shared storage may remove repeated immutable preparation while leaving local expansion and warm-up.
Choice Benefit Cost / limit
Per-Pod emptyDir Independent prepared copy; no artifact-PV mount for these files Repeated writes and init failure path on replacement.
Versioned persistent files Reuse already prepared compatible bytes Backend/mount availability, publication gate and retention ownership.
Init writes to PVC Can prepare persistent content Needs the same locking/immutability rules; init does not mean ephemeral.