-
Notifications
You must be signed in to change notification settings - Fork 550
Adding kubernetes connector support to kaniko image builder #4070
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
base: develop
Are you sure you want to change the base?
Conversation
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. It looks promising, but still needs some work and testing.
| @@ -0,0 +1,65 @@ | |||
| import base64 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kaniko service connector is completely irrelevant:
- it's incomplete
- you're not really using it
- you don't even need it because what you really need is a Kubernetes service connector, which you're already using
| raise RuntimeError( | ||
| "`kubectl` is required to run the Kaniko image builder." | ||
| ) | ||
| raise RuntimeError("`kubectl` is required to run the Kaniko image builder.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check isn't accurate anymore. You should try testing your changes without kubectl installed.
| logger.info("streaming build context into kaniko pod.") | ||
| kubernetes.k8s_utils.stream_file_to_pod( | ||
| core_api, | ||
| namespcae=self.config.kubernetes_namespace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a typo here. Can you please test these changes and make sure they work ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adtech97 Thanks for opening up this PR. Unfortunately, there is no way this is currently working, as it's importing modules that don't exist, and simply using the wrong arguments.
Can you please fix those issues and make sure the PR is actually in a working state (=running with and without a connector works). Let me know if you need any help!
| pod_name=pod_name, | ||
| container_name="kaniko", | ||
| source_path=build_context, | ||
| destination_parh="/workspace" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo I assume?
| destination_parh="/workspace" | ||
| ) | ||
| # wait for the pod completion | ||
| kubernetes.k8s_utils.wait_pod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module doesn't exist?
| default=None, | ||
| ) | ||
|
|
||
| class KubernetesKanikoServiceConnector(ServiceConnector): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like you use this service connector anyway?
| core_api = kubernetes.client.CoreV1Api(api_client) | ||
|
|
||
| # Second step define the kaniko pod spec | ||
| container = kubernetes.client.V1Container( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this logic is duplicated from the _generate_spec_overrides method, maybe we can find a way to reuse the same code for running with or without kubectl?
| image=self.config.excutor_image, | ||
| args=[ | ||
| f"--destination={self.config.target_image}", | ||
| "--container=tar://stdin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be --context=..., and it depends on the configuration, it isn't always stdin.
Describe changes
I implemented the changes in the existing kaniko image builder to support the Kubernetes connector.
Pre-requisites
Please ensure you have done the following:
developand the open PR is targetingdevelop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.Types of changes