diff --git a/kubespawner/objects.py b/kubespawner/objects.py index 9df8bf0b..4f842c1d 100644 --- a/kubespawner/objects.py +++ b/kubespawner/objects.py @@ -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, @@ -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 diff --git a/kubespawner/spawner.py b/kubespawner/spawner.py index a69f71dd..84d29cf6 100644 --- a/kubespawner/spawner.py +++ b/kubespawner/spawner.py @@ -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 `__. - - - 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. """, ) diff --git a/tests/test_objects.py b/tests/test_objects.py index 52fb8d54..479b966e 100644 --- a/tests/test_objects.py +++ b/tests/test_objects.py @@ -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": {}}, @@ -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': [],