Skip to content
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

Initial support for Knative Build #851

Closed
wants to merge 1 commit into from

Conversation

dgageot
Copy link
Contributor

@dgageot dgageot commented Jul 24, 2018

This PR brings initial support for https://github.com/knative/build. It currently focused on supporting Docker build artifacts. Bazel artifacts should be easy to add.

Signed-off-by: David Gageot david@gageot.net

}

func waitForCompletion(builds build_v1alpha1.BuildInterface, build *v1alpha1.Build) error {
for {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why busy wait?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AkihiroSuda I'm not sure I understand your comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not this loop consume CPU too much?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's done just after the logs are done tailing so it usually succeeds i getting the status the first time. But since there's a few ms between the logs being done and the status being updated, it sometimes requires a retry.

Custom: &v1.Container{
Image: "gcr.io/cloud-builders/gsutil", // TODO(dgageot) way too big
Command: []string{"sh", "-c"},
Args: []string{fmt.Sprintf("gsutil cp gs://%s/%s - | tar xvz", cfg.GCSBucket, tarName)},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these escaped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This piece needs fixing.

@dgageot dgageot force-pushed the knative branch 4 times, most recently from 2fd02c4 to 78a16f7 Compare July 28, 2018 18:38
@dgageot dgageot requested a review from balopat as a code owner August 4, 2018 06:35
@dgageot dgageot force-pushed the knative branch 7 times, most recently from 04d0bbd to 1639bf6 Compare August 8, 2018 08:01
@codecov-io
Copy link

codecov-io commented Aug 8, 2018

Codecov Report

Merging #851 into master will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #851      +/-   ##
=========================================
- Coverage   43.55%   43.5%   -0.05%     
=========================================
  Files          63      63              
  Lines        2645    2648       +3     
=========================================
  Hits         1152    1152              
- Misses       1373    1376       +3     
  Partials      120     120
Impacted Files Coverage Δ
pkg/skaffold/runner/runner.go 55.31% <0%> (-0.9%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0592b2b...d0de097. Read the comment docs.

@bobcatfish
Copy link
Contributor

very cool @dgageot ! How would you feel about including some docs in this PR that explain how to use it? (makes reviewing easier too)

var builds []Artifact

for _, artifact := range artifacts {
fmt.Fprintf(out, "Building [%s]...\n", artifact.ImageName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about outputting this in color (blue?)?

@dgageot dgageot force-pushed the knative branch 2 times, most recently from e17d117 to eeef9c2 Compare August 15, 2018 09:59
@dgageot dgageot force-pushed the knative branch 5 times, most recently from 568fd6c to a4a1a3b Compare August 24, 2018 08:41
@dgageot dgageot added the wip label Aug 24, 2018
@dgageot dgageot force-pushed the knative branch 2 times, most recently from 6cdd90a to d0de097 Compare September 6, 2018 04:28
@dlorenc
Copy link
Contributor

dlorenc commented Sep 7, 2018

Is this ready for a look yet?

Currently focused on supporting Docker build artifacts

Signed-off-by: David Gageot <david@gageot.net>
@dlorenc
Copy link
Contributor

dlorenc commented Sep 17, 2018

Ping, what's left here?

@ajbouh
Copy link
Contributor

ajbouh commented Sep 25, 2018

I think this is the right approach to use for using skaffold in a kubernetes-hosted CI job.

Have other folks tried this PR yet?

@dgageot
Copy link
Contributor Author

dgageot commented Sep 25, 2018

I need to rebase this code, sync it with recent knative build and fix the TODOs. Might have time to do that this week

@balopat
Copy link
Contributor

balopat commented Oct 29, 2018

ping @dgageot are you okay with me to fork this and continue where you left it?

@bkuschel
Copy link

This is a pretty tight integration. It would be neat if skaffold had the capability to use pre-existing Build and BuildTemplate resources rather than create fixed implementations with gcs/kaniko.

@bkuschel
Copy link

bkuschel commented Nov 9, 2018

I can take a look at this as well now. I'll pull this code down and see if i can help take it forward.

@bkuschel
Copy link

bkuschel commented Nov 9, 2018

@dgageot so i'm thinking about adding support for knative build resources. Tricky part is generating the input from the local build context. This current implementation uses an object store as a drop-off.
Since we have access to the k8s control plane, it could be feasible transfer the files to a custom "skaffold" knative initcontainer responsible for populating the knative build workspace.

So the sequence would be something like:

  1. Skaffold starts the build, tgz's the build context
  2. It loads the build resource specified in the skaffold.yaml. Ensure the build input source is using a "skaffold" "custom" input container. ( Not sure what to do if an input source specified therein, as it would need a very specific setup here, perhaps it will be overwritten. Perhaps some flexibility of using an object store drop-off etc. ).
  3. Skaffold creates the build resource in k8s
  4. knative build starts up and "skaffold" input container immediately goes into a waiting state, waiting for a tar process to start
  5. Skaffold execs into the waiting "skaffold" container, having it untar the tgz build context that was sent to it
  6. "skaffold" input container sees the tar process exit and exits

Thoughts?

@dgageot
Copy link
Contributor Author

dgageot commented Nov 9, 2018

@bkuschel Hi! I just heard that Knative Build is going to evolve a LOT in the upcoming weeks. You might want to hold on any effort and see how it turns out

@csantanapr
Copy link

@dgageot Is there some doc or example on how to use it with knative?

@dgageot dgageot deleted the knative branch December 28, 2018 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants