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

fix: remote manifest image substitution #6342

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

gsquared94
Copy link
Contributor

@gsquared94 gsquared94 commented Aug 2, 2021

Fixes: #5855

Description

Skaffold expects local kubernetes manifests to define containers[i].image property exactly equal to skaffold.yaml's artifacts[i].imageName without a digest suffix or repository prefix. This works for kubectl.remoteManifests deployer only with local clusters like minikube or kind where the image is referenced without digests.

This PR separates the image substitution logic between localManifests that need the image name to match artifact imageName exactly; and remoteManifests that can specify images with digest and repository.

Testing instructions
In examples/getting-started:

  • run skaffold run
  • modify the skaffold.yaml file to:
deploy:
  kubectl:
-   manifests:
-     - k8s-*
+  remoteManifests:
+  - pod/getting-started 
  • run skaffold dev
  • change main.go to print something else
  • rebuilt and redeployed pod should now print the new output

@gsquared94 gsquared94 requested a review from tejal29 August 2, 2021 17:57
@gsquared94 gsquared94 requested a review from a team as a code owner August 2, 2021 17:57
@google-cla google-cla bot added the cla: yes label Aug 2, 2021
@codecov
Copy link

codecov bot commented Aug 2, 2021

Codecov Report

Merging #6342 (3df1a07) into main (6f64e5b) will decrease coverage by 0.09%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6342      +/-   ##
==========================================
- Coverage   70.57%   70.48%   -0.10%     
==========================================
  Files         496      498       +2     
  Lines       22457    22581     +124     
==========================================
+ Hits        15850    15917      +67     
- Misses       5584     5633      +49     
- Partials     1023     1031       +8     
Impacted Files Coverage Δ
pkg/skaffold/deploy/kubectl/kubectl.go 67.45% <45.45%> (-0.44%) ⬇️
pkg/skaffold/kubernetes/manifest/images.go 100.00% <100.00%> (ø)
pkg/skaffold/hooks/container.go 64.44% <0.00%> (-2.23%) ⬇️
pkg/skaffold/schema/versions.go 85.51% <0.00%> (ø)
pkg/skaffold/kubernetes/logger/formatter.go 83.92% <0.00%> (ø)
.../skaffold/deploy/component/kubernetes/component.go 94.73% <0.00%> (ø)
pkg/skaffold/schema/v2beta20/upgrade.go 100.00% <0.00%> (ø)
pkg/skaffold/schema/v2beta20/config.go 24.32% <0.00%> (ø)
pkg/skaffold/deploy/kpt/kpt.go 79.25% <0.00%> (+0.05%) ⬆️
pkg/skaffold/deploy/helm/deploy.go 76.82% <0.00%> (+0.07%) ⬆️
... and 6 more

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 6f64e5b...3df1a07. Read the comment docs.

Comment on lines +164 to +166
// if manifest mentions image with repository then `imageName` is parsed into `image.Name`
tag, present := tagsByImageName[image.Name]
return image.Name, tag, present
Copy link
Contributor

Choose a reason for hiding this comment

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

if I'm reading this correctly, this block is to account for the existing locally-referenced images, right?

if so, it seems that this block will always be used in selecting the images to replace. it might be a little easier to read to remove this part from the selectRemoteManifestImages() function, and then alter the if len(k.remoteManifests) > 0 ... else block to just be an if len(k.remoteManifests) > 0 ....

if len(k.RemoteManifests) > 0 {
		manifests, err = manifests.ReplaceRemoteManifestImages(ctx, builds)
}
manifests, err = manifests.ReplaceImages(ctx, builds)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made the separation between local and remote manfests cleaner. ReplaceRemoteManifestImages still needs to account for images referenced directly similar to local manifests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source changes after the first aren't pushed to the cluster when using skaffold dev
2 participants