Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit ImagePullPolicy by default #807

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -721,21 +721,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