-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Skaffold render solely perform the manifests hydration #4193
Conversation
pull from upstream
merge upstream
merge upstream
Merge upstream changes.
Codecov Report
|
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.
Added my comments - I don't think we should infer the image tags and assume that that's what the user wants.
pkg/skaffold/runner/build_deploy.go
Outdated
@@ -39,8 +39,8 @@ func (r *SkaffoldRunner) BuildAndTest(ctx context.Context, out io.Writer, artifa | |||
return nil, err | |||
} | |||
|
|||
// In dry-run mode, we don't build anything, just return the tag for each artifact. | |||
if r.runCtx.Opts.DryRun { | |||
// In dry-run mode or --digest-source set to 'remote' or 'none', we don't build anything, just return the tag for each artifact. |
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: two spaces after --digest-source
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 made a few wording suggestions, specifically related to saying that when --digest-source=none
, "image tags are used from the skaffold.yaml
", which isn't actually true - they're used from the Kubernetes manifests, which is an important distinction.
I also ran into a bug with --digest-source=none
:
- use the
getting-started
example in our repo (withskaffold-example
as the image in theskaffold.yaml
andk8s-pod.yaml
- append a
:latest
to the image in the k8s manifest - set your default-repo to something in skaffold (
skaffold config set default-repo gcr.io/my-project
) skaffold render --digest-source=none
should give me a manifest with something like
apiVersion: v1
kind: Pod
...
spec:
containers:
- image: gcr.io/my-project/skaffold-example:latest
name: getting-started
but for the image name, I actually get gcr.io/my-project/skaffold-example:v1.10.0-82-gb616768d3-dirty
, so it generated me a tag. appending the repository name to the image in the k8s manifest, however, gives me the correct result.
I'm not sure how deep this bug goes, so idk if it should be fixed in this PR or a follow-up. but --digest-source=none
will be broken for anyone using the default-repo functionality in skaffold until it's fixed (which I suspect is a sizable number of users).
pkg/skaffold/runner/build_deploy.go
Outdated
@@ -39,8 +39,8 @@ func (r *SkaffoldRunner) BuildAndTest(ctx context.Context, out io.Writer, artifa | |||
return nil, err | |||
} | |||
|
|||
// In dry-run mode, we don't build anything, just return the tag for each artifact. | |||
if r.runCtx.Opts.DryRun { | |||
// In dry-run mode or --digest-source set to 'remote' or 'none', we don't build anything, just return the tag for each artifact. |
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.
// In dry-run mode or --digest-source set to 'remote' or 'none', we don't build anything, just return the tag for each artifact. | |
// In dry-run mode or with --digest-source set to 'remote' or 'none', we don't build anything, just return the tag for each artifact. |
cmd/skaffold/app/cmd/render.go
Outdated
@@ -38,10 +38,12 @@ var ( | |||
func NewCmdRender() *cobra.Command { | |||
return NewCmd("render"). | |||
WithDescription("[alpha] Perform all image builds, and output rendered Kubernetes manifests"). | |||
WithExample("Hydrate Kubernetes manifests without building the images ", "render --digest-source=remote"). |
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.
WithExample("Hydrate Kubernetes manifests without building the images ", "render --digest-source=remote"). | |
WithExample("Hydrate Kubernetes manifests without building the images, using digest resolved from tag in remote registry", "render --digest-source=remote"). |
cmd/skaffold/app/cmd/render.go
Outdated
WithCommonFlags(). | ||
WithFlags(func(f *pflag.FlagSet) { | ||
f.BoolVar(&showBuild, "loud", false, "Show the build logs and output") | ||
f.StringVar(&renderOutputPath, "output", "", "file to write rendered manifests to") | ||
f.StringVar(&opts.DigestSource, "digest-source", "local", "Set to 'local' to build and tag images, and output templated Kubernetes manifests; Set to 'remote' to resolve the digest of the image by tag from the container registry and output templated Kubernetes manifests; Set to 'none' to output templated Kubernetes manifests with images listed in skaffold.yaml") |
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.
f.StringVar(&opts.DigestSource, "digest-source", "local", "Set to 'local' to build and tag images, and output templated Kubernetes manifests; Set to 'remote' to resolve the digest of the image by tag from the container registry and output templated Kubernetes manifests; Set to 'none' to output templated Kubernetes manifests with images listed in skaffold.yaml") | |
f.StringVar(&opts.DigestSource, "digest-source", "local", "Set to 'local' to build images locally and use digests from built images; Set to 'remote' to resolve the digest of images by tag from the remote registry; Set to 'none' to use tags directly from the Kubernetes manifests") |
pkg/skaffold/runner/render.go
Outdated
} | ||
} | ||
if r.runCtx.Opts.DigestSource == noneDigestSource { | ||
color.Default.Fprintln(out, "--digest-source set to 'none', tags listed in skaffold.yaml will be used for render") |
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.
color.Default.Fprintln(out, "--digest-source set to 'none', tags listed in skaffold.yaml will be used for render") | |
color.Default.Fprintln(out, "--digest-source set to 'none', tags listed in Kubernetes manifests will be used for render") |
Thank you for reviewing this PR. I misunderstood the use case before and I have got the issue fixed. However, there is one question regarding the example you put in the comment. The image used in k8s-pod.yaml is |
ok just tried it out with I think we do still want to respect the default repo in this case: this flag is indicating that the tag will not be touched by skaffold, but the default repo functionality should still be applied here.
I actually wouldn't mind adding |
Description
Proposal: go/skaffold-render-hydration-only
Currently skaffold render performs all image builds then outputs hydrated Kubernetes manifests. This PR modifies skaffold render to solely perform the hydration of Kubernetes manifests with the option to build artifacts.
In this PR, a new option
--skip-build
will be added to therender
command.skaffold render --skip-build
only hydrated the kubernetes manifests without building the image.