-1

there's probably something i'm not understanding about kustomize but using a simple kustomize edit set image ... followed by kustomize build . | kubectl apply -f - is actually creating duplicate pods rather than replacing pods. It's supposed to be taking my new docker image and replacing the currently deployed pod with a pod that contains the new image. is there some way i can understand why this is happening?

here's my kustomize.yaml. it's very simple. the images section is an example result of the kustomize edit ... command above

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
- service.yaml
- ingress.yaml
images:
- name: repo.pkg.dev/PROJECT/REPO/IMAGE:TAG
  newName: repo.pkg.dev/.../.../...
  newTag: custom-tag

running a simple kubectl apply without any of the kustomize stuff used to do exactly what i want before

Naji
  • 674
  • 2
  • 14
  • 35

1 Answers1

0

Kustomize doesn't create pods (unless you're deploying a Pod manifest, but those are largely immutable and in any case you're not doing that).

You're updating a Deployment, and the Kubernetes Deployment controller is responsible for creating pods based on the replicas and strategy settings in your Deployment.

By default, the strategy.type field is RollingUpdate, which means that when you update the Deployment, Kubernetes will first spin up new pods, wait until they become healthy, and then tear down the old pods. During this period you will have "duplicate pods", because that's what you've asked for.

If you want Kubernetes to first tear down existing pods before creating new ones, use the Replace strategy instead:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example
spec:
  replicas: 1
  strategy:
    type: Recreate
  .
  .
  .
larsks
  • 277,717
  • 41
  • 399
  • 399