Skip to content

fix: default imagePullPolicy to IfNotPresent for air-gapped environments#95

Merged
Iamlovingit merged 1 commit intoYuan-lab-LLM:mainfrom
hippoley:fix/image-pull-policy-configurable
Apr 27, 2026
Merged

fix: default imagePullPolicy to IfNotPresent for air-gapped environments#95
Iamlovingit merged 1 commit intoYuan-lab-LLM:mainfrom
hippoley:fix/image-pull-policy-configurable

Conversation

@hippoley
Copy link
Copy Markdown
Contributor

Summary

Fixes #94 — Pods fail to start in air-gapped / enterprise environments because Kubernetes defaults imagePullPolicy to Always for images tagged :latest.

Root Cause

defaultSystemImageSettings["openclaw"] resolves to ghcr.io/yuan-lab-llm/clawmanager-openclaw-image/openclaw:latest. When no explicit imagePullPolicy is set on the container spec, Kubernetes applies its default rule: :latest tag → Always. Nodes in air-gapped networks cannot reach ghcr.io, so the pod stays in ImagePullBackOff.

Changes

File Change
pod_service.go Add ImagePullPolicy field to PodConfig; default to IfNotPresent in CreatePod
instance_runtime.go Add defaultImagePullPolicy() — reads IMAGE_PULL_POLICY env var, falls back to IfNotPresent
instance_service.go Pass ImagePullPolicy in both CreateInstance and StartInstance pod config paths
instance_runtime_test.go 5 new tests: default value, env var override (Always/Never/IfNotPresent), whitespace fallback

Operator Configuration

Set the IMAGE_PULL_POLICY environment variable on the backend deployment to override the default:

Impact

  • Air-gapped environments: pods now start successfully using locally cached images.
  • Connected environments: behavior unchanged for non-:latest tags (K8s already defaults to IfNotPresent). For :latest tags, operators can set IMAGE_PULL_POLICY=Always to restore the previous behavior.
  • Zero breaking changes: ImagePullPolicy is an additive struct field; callers that omit it get the safe default.

Testing

  • All existing tests pass (zero regression)
  • 5 new unit tests for defaultImagePullPolicy()
  • Full build verified

Kubernetes defaults imagePullPolicy to Always when the image tag is
:latest. This causes pod creation failures in air-gapped and enterprise
environments where nodes cannot reach external registries.

Changes:
- Add ImagePullPolicy field to PodConfig struct
- Default to IfNotPresent in CreatePod when not explicitly set
- Support IMAGE_PULL_POLICY env var for operator override
- Apply policy to both CreateInstance and StartInstance paths

Closes Yuan-lab-LLM#94
@Iamlovingit
Copy link
Copy Markdown
Collaborator

/lgtm

@Iamlovingit Iamlovingit merged commit 30abf94 into Yuan-lab-LLM:main Apr 27, 2026
5 checks passed
@Iamlovingit
Copy link
Copy Markdown
Collaborator

@hippoley Thanks for your contributions !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClawManager上创建openclaw实例,POD里imagePullPolicy: Always,导致本地即使有openclaw镜像也会去远端拉取,导致POD启动不了

2 participants