Skip to content

Commit

Permalink
Merge pull request #807 from yuvipanda/image-pull-policy
Browse files Browse the repository at this point in the history
Omit ImagePullPolicy by default
  • Loading branch information
yuvipanda committed Nov 13, 2023
2 parents 5b000ff + 0e4ba25 commit 4984783
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
6 changes: 3 additions & 3 deletions kubespawner/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def make_pod(
cmd,
port,
image,
image_pull_policy,
image_pull_policy=None,
image_pull_secrets=None,
node_selector=None,
uid=None,
Expand Down Expand Up @@ -138,9 +138,9 @@ def make_pod(
arguments
image_pull_policy:
Image pull policy - one of 'Always', 'IfNotPresent' or 'Never'. Decides
Image pull policy - one of None, 'Always', 'IfNotPresent' or 'Never'. Decides
when kubernetes will check for a newer version of image and pull it when
running a pod.
running a pod. If set to None, it will be omitted from the spec.
image_pull_secrets:
Image pull secrets - a list of references to Kubernetes Secret resources
Expand Down
15 changes: 5 additions & 10 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,21 +737,16 @@ def _deprecated_changed(self, change):
)

image_pull_policy = Unicode(
'IfNotPresent',
None,
allow_none=True,
config=True,
help="""
The image pull policy of the docker container specified in
`image`.
Defaults to `IfNotPresent` which causes the Kubelet to NOT pull the image
specified in KubeSpawner.image if it already exists, except if the tag
is `:latest`. For more information on image pull policy,
refer to `the Kubernetes documentation <https://kubernetes.io/docs/concepts/containers/images/>`__.
This configuration is primarily used in development if you are
actively changing the `image_spec` and would like to pull the image
whenever a user container is spawned.
Defaults to `None`, which means it is omitted. This leads to it behaving
like 'Always' when a tag is absent or 'latest', and 'IfNotPresent' when
the tag is specified to be something else, per https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting.
""",
)

Expand Down
2 changes: 0 additions & 2 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def test_make_simplest_pod():
image='jupyter/singleuser:latest',
cmd=['jupyterhub-singleuser'],
port=8888,
image_pull_policy='IfNotPresent',
)
) == {
"metadata": {"name": "test", "labels": {}, "annotations": {}},
Expand All @@ -30,7 +29,6 @@ def test_make_simplest_pod():
"env": [],
"name": "notebook",
"image": "jupyter/singleuser:latest",
"imagePullPolicy": "IfNotPresent",
"args": ["jupyterhub-singleuser"],
"ports": [{"name": "notebook-port", "containerPort": 8888}],
'volumeMounts': [],
Expand Down

0 comments on commit 4984783

Please sign in to comment.