Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

allow caching and overriding single_snapshot for kaniko #554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions kubeflow/fairing/builders/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def __init__(self,
namespace=None,
dockerfile_path=None,
cleanup=False,
executable_path_prefix=None):
executable_path_prefix=None,
cache=False,
single_snapshot=True):
super().__init__(
registry=registry,
image_name=image_name,
Expand All @@ -43,6 +45,8 @@ def __init__(self,
self.namespace = namespace or utils.get_default_target_namespace()
self.cleanup = cleanup
self.executable_path_prefix = executable_path_prefix
self.cache = cache
self.single_snapshot = single_snapshot

def build(self):
logging.info("Building image using cluster builder.")
Expand All @@ -68,7 +72,7 @@ def build(self):
labels = {'fairing-builder': 'kaniko'}
labels['fairing-build-id'] = str(uuid.uuid1())
pod_spec = self.context_source.generate_pod_spec(
self.image_tag, self.push)
self.image_tag, self.push, self.cache, self.single_snapshot)
for fn in self.pod_spec_mutators:
fn(self.manager, pod_spec, self.namespace)

Expand Down
11 changes: 8 additions & 3 deletions kubeflow/fairing/builders/cluster/minio_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,25 @@ def upload_context(self, context_filename):
bucket_name=bucket_name,
file_to_upload=context_filename)

def generate_pod_spec(self, image_name, push): # pylint: disable=arguments-differ
def generate_pod_spec(self, image_name, push, cache=False, single_snapshot=True): # pylint: disable=arguments-differ
"""
:param image_name: name of image to be built
:param push: whether to push image to given registry or not
"""
args = [
"--dockerfile=Dockerfile",
"--destination=" + image_name,
"--context=" + self.uploaded_context_url,
"--single-snapshot"
"--context=" + self.uploaded_context_url
]
if single_snapshot:
args.append("--single-snapshot")

if not push:
args.append("--no-push")

if cache:
args.append("--cache=true")

return client.V1PodSpec(
containers=[
client.V1Container(
Expand Down