-
Notifications
You must be signed in to change notification settings - Fork 244
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
Add support to perform kubernetes build in "odo deploy" using Kaniko build strategy #3751
Add support to perform kubernetes build in "odo deploy" using Kaniko build strategy #3751
Conversation
…o parse_dockerfile
…he projects source
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
- Downloads Dockerfile into memory rather than onto the hosts machine - Validates if a Dockerfile is present in the project source, if one isn't specified by the devfile - Validates the contents of the Dockerfile (that there is a FROM on the first non-comment/non-whitespace line) - Validates the tag passed as an arg conforms to the correct character-set - Copies all project source files into the container rather than new/updated - Additional Testing - More appropriate error/warning messages
Co-authored-by: Cameron McWilliam <cam.mcwilliam@me.com>
* Add test List URL function Signed-off-by: Steven Groeger <groeges@uk.ibm.com> * Update logging within maifest deploy Signed-off-by: Steven Groeger <groeges@uk.ibm.com> * Add preliminary support for multiple manifest in single yaml Signed-off-by: Steven Groeger <groeges@uk.ibm.com> * Update service manifest with ClusterIP value before update. Signed-off-by: Steven Groeger <groeges@uk.ibm.com> * Merge deployDelete code and update to support multiple doc in yaml Signed-off-by: Steven Groeger <groeges@uk.ibm.com> * Fix source formatting Signed-off-by: Steven Groeger <groeges@uk.ibm.com> * Add some extra checks on waitManifestDeployComplete function Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
alpha.deployment-manifest Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
* Remove CommonPushOptions and do some clean up * Move validation, add better user experience, remove devfile.yaml flag
Signed-off-by: Steven Groeger <groeges@uk.ibm.com>
Add unit tests to Kaniko build in "odo deploy"
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @jaideepr97. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
@jaideepr97: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/status blocked Also, we need to have devfile at least first draft of 2.1.0 spec first |
@kadel Makes sense |
Just for merging. |
DoesComponentExist(cmpName string) (bool, error) | ||
Deploy(parameters DeployParameters) error |
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.
I would suggest call it CreateDeployment
and DeleteDeployment
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 the feedback @girishramnani
This may be better suited for #3478 as it was introduced there and just carried over into this PR
} | ||
|
||
// Build creates Kubernetes resources to build an image for the component | ||
func (k Adapter) DeployDelete(manifest []byte) error { |
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.
instead of passing the whole manifest could we consider the minimum information that is necessary?
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 the feedback @girishramnani
This may be better suited for #3478 as it was introduced there and just carried over into this PR
"component": a.ComponentName, | ||
} | ||
|
||
if err := a.createKanikoBuilderPod(labels, initContainer(initContainerName), builderContainer(containerName, parameters.Tag, isImageRegistryInternal), regcredName); err != nil { |
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.
nit: can we make this into multiple lines
return errors.Wrap(err, "error while creating kaniko builder pod") | ||
} | ||
|
||
podSelector := fmt.Sprintf("component=%s", a.ComponentName) |
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.
we have different kind of selectors present in our component/labels package and similarly in application/labels. please consider using those
return errors.Wrapf(err, "error while waiting for pod %s", podSelector) | ||
} | ||
|
||
defer func() { |
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.
lets extract this out into a function
@@ -85,6 +85,63 @@ func (c *Client) WaitAndGetPod(watchOptions metav1.ListOptions, desiredPhase cor | |||
} | |||
} | |||
|
|||
// WaitAndGetPodOnInitContainerStarted blocks and waits until the named initiContainer is started. | |||
func (c *Client) WaitAndGetPodOnInitContainerStarted(watchOptions metav1.ListOptions, initContainerName, waitMessage string, hideSpinner bool) (*corev1.Pod, error) { |
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.
I think this function could be reduced by using the code from other functions in this package
// Create a function to wait for deploment completion of any unstructured object | ||
func (c *Client) waitForManifestDeployCompletion(applicationName string, gvr schema.GroupVersionResource, conditionTypeValue string) (*unstructured.Unstructured, error) { | ||
klog.V(4).Infof("Waiting for %s manifest deployment completion", applicationName) | ||
w, err := c.dynamicClient.Resource(gvr).Namespace(c.Namespace).Watch(metav1.ListOptions{FieldSelector: "metadata.name=" + applicationName}) |
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.
from what I understood - this function is only being used to check if knative
route is created or not. Can we actually use knative's generated library here. the dynamic client's purpose was to be used at places where the resource is provided by the user and hence cannot be associated to strongly typed resource.
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 the feedback @girishramnani
This may be better suited for #3478 as it was introduced there and just carried over into this PR
did a partial pass through of the code, will take a look again soon. |
Thanks for the feedback @girishramnani |
Closing this PR as it has diverged |
What type of PR is this?
What does does this PR do / why we need it:
This PR extends the current implementation of
odo deploy
to make it kubernetes generic and allow performing unprivileged buildsodo deploy
and pushing the built image to either an external registry or internal registryBuildConfig
path to external registriesdockerconfigjson
flag to pass reference to a config.json fileNOTE: This PR builds on top of work contained in #3478 , and must only be merged after #3478 has been merged
Which issue(s) this PR fixes:
Fixes #3583
PR acceptance criteria:
How to test changes / Special notes to the reviewer:
odo create nodejs --starter=nodejs-starter
odo url create
odo deploy --tag=<imageTag>
NOTE: setting
Rootless: true
will trigger a kaniko build. The default value is false and will trigger a build using buildConfigNOTE: Please supply complete destination under --tag
( for ex:
image-registry.openshift-image-registry.svc:5000/namespace/imagestream
ordocker.io/username/repository-name
)NOTE: (Relevant to external registry push only) if
--dockerconfigjson
is not specified, config.json is picked up from ~/.docker. Please ensure the default config.json file contains a valid auth token. External registry push is currently only configured for Dockerhub