diff --git a/fuel_ccp/config/kubernetes.py b/fuel_ccp/config/kubernetes.py index 3004fb09..6e2f5d77 100644 --- a/fuel_ccp/config/kubernetes.py +++ b/fuel_ccp/config/kubernetes.py @@ -7,6 +7,7 @@ DEFAULTS = { 'cert_file': None, 'insecure': False, 'cluster_domain': 'cluster.local', + 'image_pull_policy': None, }, } @@ -22,6 +23,10 @@ SCHEMA = { 'cert_file': {'anyOf': [{'type': 'string'}, {'type': 'null'}]}, 'insecure': {'type': 'boolean'}, 'cluster_domain': {'type': 'string'}, + 'image_pull_policy': {'oneOf': [ + {'type': 'null'}, + {'enum': ['Always', 'IfNotPresent', 'Never']}, + ]}, }, }, } diff --git a/fuel_ccp/templates.py b/fuel_ccp/templates.py index e958a719..edd2a320 100644 --- a/fuel_ccp/templates.py +++ b/fuel_ccp/templates.py @@ -138,7 +138,7 @@ def serialize_daemon_container_spec(container): cont_spec = { "name": container["name"], "image": images.image_spec(container["image"]), - "imagePullPolicy": "Always", + "imagePullPolicy": CONF.kubernetes.image_pull_policy, "command": _get_start_cmd(container["name"]), "volumeMounts": serialize_volume_mounts(container), "readinessProbe": { @@ -167,7 +167,7 @@ def serialize_job_container_spec(container, job): return { "name": job["name"], "image": images.image_spec(container["image"]), - "imagePullPolicy": "Always", + "imagePullPolicy": CONF.kubernetes.image_pull_policy, "command": _get_start_cmd(job["name"]), "volumeMounts": serialize_volume_mounts(container, job), "env": serialize_env_variables(container) diff --git a/fuel_ccp/tests/test_templates.py b/fuel_ccp/tests/test_templates.py index aba0d5a5..312dc350 100644 --- a/fuel_ccp/tests/test_templates.py +++ b/fuel_ccp/tests/test_templates.py @@ -8,7 +8,6 @@ class TestDeploy(base.TestCase): container = { "name": "name_foo", "image": "image_foo", - "imagePullPolicy": "Always", "command": "command_foo", "cm_version": 1, "env": [{ @@ -30,7 +29,7 @@ class TestDeploy(base.TestCase): expected = { "name": "name_foo", "image": "ccp/image_foo:latest", - "imagePullPolicy": "Always", + "imagePullPolicy": None, "command": [ "dumb-init", "/usr/bin/python",