devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.37k stars 361 forks source link

Automatically change imagePullPolicy to Never #1748

Open mnpenner opened 3 years ago

mnpenner commented 3 years ago

Is your feature request related to a problem?

Yes. I just spent about an hour trying to figure out how to fix a "ImagePullBackOff" error. I could pull myreg/myns/myimage:latest from my registry no problem, but devspace creates new versions of the images but I guess doesn't push them to my remote repo. That's good because it doesn't need to push them while I'm still developing, but it also means if you have imagePullPolicy: Always in your k8s config, it ain't gonna work because it'll keep trying to pull it from the registry even though it only exists locally.

Which solution do you suggest?

Override the imagePullPolicy to Never for all images that devspace manages, which I guess is just the ones listed under images in devspace.yaml.

Which alternative solutions exist?

Update your deployment configs yourself. This is problematic if you want to use imagePullPolicy: Always for production, but Never for development. You could fix this with a kustomize overlay probably, but the site I'm working on is too simple to warrant that.

Additional context

https://stackoverflow.com/a/54043058/65387

/kind feature

FabianKramm commented 3 years ago

@mnpenner thanks for creating this issue! How are you deploying with your devspace.yaml? Currently we do not rewrite any deployments or pods unless dev.replacePods is specified explicitly, so unfortunately we cannot just switch the imagePullPolicy to Always for the images during dev mode automatically.

mnpenner commented 3 years ago

How are you deploying with your devspace.yaml?

What do you mean? Here's my deployments bit:

deployments:
  - name: development
    kubectl:
      kustomize: true
      manifests:
        - k8s

i.e. using kubectl + kustomize. I'm not using devspace for production.

I figured since you're building the config on my behalf (by running kubectl/kustomize) you could tamper with the config a little bit too by swapping the imagePullPolicy.

I didn't know about replacePods. That looks pretty much like what I wanted, I think I could use patches to replace the imagePullPolicy.

I would still suggest an easier-to-use option for this, akin to how you have createPullSecret. Alternatively, if devspace is failing to deploy and detects an "ImagePullBackOff" you can point them towards some docs on how to fix it. Right now I think it just says "this will probably never succeed" and keeps trying.