Environment overlays in Skaffold with Kustomize are how you apply environment-specific configurations to your Kubernetes manifests without duplicating YAML files.

Here’s Skaffold running a simple web app with Kustomize overlays for dev and prod environments:

apiVersion: skaffold/v2beta29
kind: Config
deploy:
  kustomize:
    paths:
    - overlays/dev
    - overlays/prod
build:
  local:
    push: false
  artifacts:
  - image: my-webapp
    docker:
      dockerfile: Dockerfile

And here’s the Kustomize setup:

.
├── Dockerfile
├── kustomization.yaml
├── overlays
│   ├── dev
│   │   ├── kustomization.yaml
│   │   └── patches
│   │       └── replicas.yaml
│   └── prod
│       ├── kustomization.yaml
│       └── patches
│           └── ingress.yaml
└── src
    └── main.go

kustomization.yaml (base):

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml

overlays/dev/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../
patchesStrategicMerge:
- patches/replicas.yaml

overlays/dev/patches/replicas.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-webapp
spec:
  replicas: 1

overlays/prod/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../
patchesStrategicMerge:
- patches/ingress.yaml

overlays/prod/patches/ingress.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-webapp-ingress
spec:
  rules:
  - host: my-webapp.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-webapp
            port:
              number: 80

When you run skaffold dev, Skaffold will first build your my-webapp image. Then, it will iterate through the deploy.kustomize.paths you’ve specified. For overlays/dev, it will apply the replicas.yaml patch to the base manifests and deploy them. If you then change skaffold.yaml to point to overlays/prod, Skaffold will apply the ingress.yaml patch and deploy those manifests.

The core problem Kustomize overlays solve is managing configuration drift across environments. Instead of having separate dev-deployment.yaml, staging-deployment.yaml, and prod-deployment.yaml files, you maintain a single base deployment.yaml and then create small, targeted patches for each environment. This dramatically reduces duplication and makes it easier to see what differs between environments. Skaffold leverages this by allowing you to specify which overlay directory to use for deployment. When you run skaffold dev --profile dev (assuming you have a profile for dev), Skaffold will use the Kustomize configuration found in overlays/dev.

The bases field in an overlay’s kustomization.yaml points to the directory containing the common resources (like deployment.yaml, service.yaml). The patchesStrategicMerge field then lists YAML files that contain modifications or additions to those base resources. Kustomize intelligently merges these patches based on Kubernetes object metadata (like apiVersion, kind, name, namespace). For example, the replicas.yaml patch targets the Deployment object named my-webapp and sets its spec.replicas field to 1. This means Skaffold, when deploying with the dev overlay, will ensure your deployment runs with exactly one replica.

The power here is that Kustomize’s patching mechanism is declarative and idempotent. When Skaffold reruns a deployment, Kustomize reapplies the patches. If the target object already exists, Kustomize merges the patch again. If the patch adds a field that already exists, it updates it. If the patch removes a field, it removes it. This makes it robust for continuous development loops.

A common misconception is that patchesStrategicMerge is the only way to patch. Kustomize also supports patchesJson6902 for more granular JSON patch operations and patches which allows for more complex overlay scenarios, though patchesStrategicMerge is usually sufficient for common environment variations.

The next step is integrating Skaffold profiles with your Kustomize overlays to easily switch between environments without manually editing skaffold.yaml.

Want structured learning?

Take the full Skaffold course →