Skip to content

Commit 7781de6

Browse files
committed
refactor: parameterize image pull policy
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent 1563b5f commit 7781de6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

gpustack_runtime/deployer/__types__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,8 @@ class Container:
685685
"""
686686
Name of the container.
687687
"""
688-
image_pull_policy: ContainerImagePullPolicyEnum = (
689-
ContainerImagePullPolicyEnum.IF_NOT_PRESENT
688+
image_pull_policy: ContainerImagePullPolicyEnum = field(
689+
default_factory=lambda: envs.GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY,
690690
)
691691
"""
692692
Image pull policy of the container.

gpustack_runtime/deployer/kuberentes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
_LABEL_COMPONENT = f"{envs.GPUSTACK_RUNTIME_DEPLOY_LABEL_PREFIX}/component"
5454

5555

56-
class KubernetesWorkloadServiceType(str, Enum):
56+
class KubernetesWorkloadServiceTypeEnum(str, Enum):
5757
"""
5858
Types for Kubernetes Service.
5959
"""
@@ -84,7 +84,7 @@ class KubernetesWorkloadPlan(WorkloadPlan):
8484
Attributes:
8585
domain_suffix (str):
8686
Domain suffix for the cluster. Default is "cluster.local".
87-
service_type (KubernetesWorkloadServiceType):
87+
service_type (KubernetesWorkloadServiceTypeEnum):
8888
Service type for the workload. Default is CLUSTER_IP.
8989
resource_key_runtime_env_mapping: (dict[str, str]):
9090
Mapping from resource names to environment variable names for device allocation,
@@ -130,7 +130,7 @@ class KubernetesWorkloadPlan(WorkloadPlan):
130130
"""
131131
Domain suffix for the cluster.
132132
"""
133-
service_type: KubernetesWorkloadServiceType = field(
133+
service_type: KubernetesWorkloadServiceTypeEnum = field(
134134
default_factory=lambda: envs.GPUSTACK_RUNTIME_KUBERNETES_SERVICE_TYPE,
135135
)
136136
"""

gpustack_runtime/envs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129
"""
130130
Correct the gpustack-runner image by rendering it with the host's detection.
131131
"""
132+
GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY: str | None = None
133+
"""
134+
Image pull policy for the deployer (e.g., Always, IfNotPresent, Never).
135+
"""
132136
GPUSTACK_RUNTIME_DEPLOY_LABEL_PREFIX: str | None = None
133137
"""
134138
Label prefix for the deployer.
@@ -313,6 +317,14 @@
313317
"GPUSTACK_RUNTIME_DEPLOY_CORRECT_RUNNER_IMAGE": lambda: to_bool(
314318
getenv("GPUSTACK_RUNTIME_DEPLOY_CORRECT_RUNNER_IMAGE", "1"),
315319
),
320+
"GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY": lambda: choice(
321+
getenv(
322+
"GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY",
323+
"IfNotPresent",
324+
),
325+
options=["Always", "IfNotPresent", "Never"],
326+
default="IfNotPresent",
327+
),
316328
"GPUSTACK_RUNTIME_DEPLOY_LABEL_PREFIX": lambda: getenv(
317329
"GPUSTACK_RUNTIME_DEPLOY_LABEL_PREFIX",
318330
"runtime.gpustack.ai",

0 commit comments

Comments
 (0)