skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

feat: transform imagePullPolicy when using local cluster

Open lucasrod16 opened this issue 1 year ago • 4 comments

Fixes: #6992

Description

Introduces a ReplaceImagePullPolicy function to update the imagePullPolicy field in Kubernetes manifests to Never when running on a local cluster. This prevents deployment errors that occur when imagePullPolicy is set to Always, as detailed in #6992.

User facing changes

Files to reproduce:

  • Dockerfile

    FROM nginx:alpine
    
  • pod.yaml

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:alpine
        imagePullPolicy: Always
    
  • skaffold.yaml

    apiVersion: skaffold/v4beta11
    kind: Config
    metadata:
      name: nginx
    build:
      artifacts:
        - image: nginx
          context: .
          docker:
            dockerfile: Dockerfile
    manifests:
      rawYaml:
       - ./pod.yaml
    

Before: failed

After: success

lucasrod16 avatar Aug 12 '24 11:08 lucasrod16

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.

google-cla[bot] avatar Aug 12 '24 11:08 google-cla[bot]

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!

lucasrod16 avatar Sep 08 '24 00:09 lucasrod16

Hi, @lucasrod16 Thank you for the pr!

I think we should only do this transformation when using skaffold dev, skaffold run, skaffold debug as we know that the transformed manifests will be applied to the connected local cluster, but for skaffold render command, we're not sure how the manifests will be used, the rendered results may be used in other places even without skaffold.

Also, this pr does the requested change when kubectl deployer is used, it needs to do the similar thing when helm deployer is used.

ericzzzzzzz avatar Sep 17 '24 14:09 ericzzzzzzz

Hi, @lucasrod16 Thank you for the pr!

I think we should only do this transformation when using skaffold dev, skaffold run, skaffold debug as we know that the transformed manifests will be applied to the connected local cluster, but for skaffold render command, we're not sure how the manifests will be used, the rendered results may be used in other places even without skaffold.

Also, this pr does the requested change when kubectl deployer is used, it needs to do the similar thing when helm deployer is used.

@ericzzzzzzz That makes sense, thanks for the feedback!

I moved the transform logic from BaseTransform to kubectl Deploy and verified it works locally with dev, run, and debug.

I will work on adding the transform logic to the helm deployer as well

lucasrod16 avatar Sep 18 '24 07:09 lucasrod16

@lucasrod16 The reviewer has commented to your pull request. How about check it?

mepi262 avatar Nov 22 '24 13:11 mepi262

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!

lucasrod16 avatar Nov 25 '24 06:11 lucasrod16

Given the issue reported in #9687, this appears to cause a breaking change. I'm going to go ahead and revert this PR.

I suspect what needs to happen is you only want to replace the pull policy on images that were actually built by Skaffold as part of a skaffold dev command. But it might need more discussion.

plumpy avatar Feb 03 '25 19:02 plumpy