-
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
feat: transform imagePullPolicy when using local cluster #9495
base: main
Are you sure you want to change the base?
feat: transform imagePullPolicy when using local cluster #9495
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Hi @ericzzzzzzz, I noticed that this pull request has been pending for a while. Is there anything needed from me? Please let me know if there are any updates required. Thanks! |
Hi, @lucasrod16 Thank you for the pr! I think we should only do this transformation when using Also, this pr does the requested change when kubectl deployer is used, it needs to do the similar thing when helm deployer is used. |
4c5d0cf
to
7d4a61b
Compare
@ericzzzzzzz That makes sense, thanks for the feedback! I moved the transform logic from I will work on adding the transform logic to the helm deployer as well |
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.
Hello! Thank you for sending this PR! Please see my comments on it, thanks!.
Also for the PR description, since this PR doesn't have the helm changes needed to fully address the issue, I don't think we should close the bug when this PR is merged.
|
||
import apimachinery "k8s.io/apimachinery/pkg/runtime/schema" | ||
|
||
type ResourceSelectorImagePullPolicy struct{} |
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 unexported, since this new struct is only used as an implementor of the ResourceSelector interface.
I would also add a comment about what this ResourceSelector does/ selects. For example
resourceSelectorImagePullPolicy is an implementation of ResourceSelector to select X and do Z.
|
||
type ResourceSelectorImagePullPolicy struct{} | ||
|
||
func NewResourceSelectorImagePullPolicy() *ResourceSelectorImagePullPolicy { |
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.
Should return the interface ResourceSelector instead of *ResourceSelectorImagePullPolicy.
return &ResourceSelectorImagePullPolicy{} | ||
} | ||
|
||
func (rs *ResourceSelectorImagePullPolicy) allowByGroupKind(gk apimachinery.GroupKind) bool { |
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.
A short comment explaining the goal of the method and the criteria used would be helpful.
return false | ||
} | ||
|
||
func (rs *ResourceSelectorImagePullPolicy) allowByNavpath(gk apimachinery.GroupKind, navpath string, k string) (string, bool) { |
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.
Here too, a description of the goal would help.
return l.Visit(r, rs) | ||
} | ||
|
||
type imagePullPolicyReplacer struct{} |
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.
A comment explaining the purpose of this struct. ie imagePullPolicyReplacer implements FieldVisitor and is used to edit an entry in a YAML document.
|
||
type imagePullPolicyReplacer struct{} | ||
|
||
func (i *imagePullPolicyReplacer) Visit(gk apimachinery.GroupKind, navpath string, o map[string]interface{}, k string, v interface{}, rs ResourceSelector) bool { |
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.
Please add a comment explaining this method also. For example Visit sets the value of the "imagePullPolicy" field in a Kubernetes manifest to "Never".
@lucasrod16 |
Signed-off-by: Lucas Rodriguez <[email protected]>
7d4a61b
to
d12d62b
Compare
Hey @alphanota, thanks for the PR review! I've updated the PR description to ensure the related issue isn't closed when this PR is merged and have addressed all your feedback. I currently don't have the bandwidth to implement the helm functionality, and I appreciate your understanding. Thanks again for the feedback! |
Relates to #6992
Description
Introduces a
ReplaceImagePullPolicy
function to update theimagePullPolicy
field in Kubernetes manifests toNever
when running on a local cluster. This prevents deployment errors that occur whenimagePullPolicy
is set toAlways
, as detailed in #6992.User facing changes
Files to reproduce:
Dockerfile
FROM nginx:alpine
pod.yaml
skaffold.yaml
Before:
After: