Skip to content

Commit 8c339fe

Browse files
committed
feat(scheduler): make the image fetching policy for slugs and docker images configurable via ENV vars
Closes #563
1 parent 4cf1761 commit 8c339fe

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

rootfs/deis/settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@
263263
random_secret = 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi*#@&*^'
264264
SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', random_secret)
265265
BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', random_secret)
266-
defaultImage = "quay.io/deisci/slugrunner:canary"
267-
SLUGRUNNER_IMAGE = os.environ.get('SLUGRUNNER_IMAGE_NAME', defaultImage)
266+
267+
# k8s image policies
268+
SLUGRUNNER_IMAGE = os.environ.get('SLUGRUNNER_IMAGE_NAME', 'quay.io/deisci/slugrunner:canary') # noqa
269+
SLUG_BUILDER_IMAGE_PULL_POLICY = os.environ.get('SLUG_BUILDER_IMAGE_PULL_POLICY', "Always") # noqa
270+
DOCKER_BUILDER_IMAGE_PULL_POLICY = os.environ.get('DOCKER_BUILDER_IMAGE_PULL_POLICY', "Always") # noqa
268271

269272
# registry settings
270273
REGISTRY_HOST = os.environ.get('DEIS_REGISTRY_SERVICE_HOST', '127.0.0.1')

rootfs/scheduler/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
{
131131
"name": "$containername",
132132
"image": "$image",
133+
"imagePullPolicy": "$image_pull_policy",
133134
"env": [
134135
{
135136
"name":"DEIS_APP",
@@ -184,7 +185,7 @@
184185
{
185186
"name": "$containername",
186187
"image": "$slugimage",
187-
"imagePullPolicy": "Always",
188+
"imagePullPolicy": "$image_pull_policy",
188189
"env": [
189190
{
190191
"name":"PORT",
@@ -495,12 +496,14 @@ def run(self, namespace, name, image, entrypoint, command, **kwargs):
495496
'id': name,
496497
'version': self.apiversion,
497498
'image': imgurl,
499+
'image_pull_policy': settings.DOCKER_BUILDER_IMAGE_PULL_POLICY,
498500
'storagetype': os.getenv("APP_STORAGE")
499501
}
500502

501503
if entrypoint == '/runner/init':
502504
POD = POD_BTEMPLATE
503505
l["image"] = image
506+
l['image_pull_policy'] = settings.SLUG_BUILDER_IMAGE_PULL_POLICY
504507
l["slugimage"] = settings.SLUGRUNNER_IMAGE
505508
l["mHost"] = os.getenv("DEIS_MINIO_SERVICE_HOST")
506509
l["mPort"] = os.getenv("DEIS_MINIO_SERVICE_PORT")
@@ -876,6 +879,7 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
876879
"appversion": kwargs.get("version"),
877880
"version": self.apiversion,
878881
"image": imgurl,
882+
'image_pull_policy': settings.DOCKER_BUILDER_IMAGE_PULL_POLICY,
879883
"replicas": kwargs.get("replicas", 0),
880884
"containername": container_name,
881885
"type": app_type,
@@ -887,6 +891,7 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
887891
# Check if it is a slug builder image.
888892
if kwargs.get('build_type') == "buildpack":
889893
l["image"] = image
894+
l['image_pull_policy'] = settings.SLUG_BUILDER_IMAGE_PULL_POLICY
890895
l["slugimage"] = settings.SLUGRUNNER_IMAGE
891896
TEMPLATE = RCB_TEMPLATE
892897

0 commit comments

Comments
 (0)